FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Unittest

 
Post new topic   Reply to topic     Forum Index -> Visual D
View previous topic :: View next topic  
Author Message
lloyd



Joined: 16 May 2011
Posts: 18
Location: Australia

PostPosted: Mon Jun 20, 2011 10:58 am    Post subject: Unittest Reply with quote

This is not really related to Visual D, but you might have an idea seeing how it's so easy to do more with Visual D ! Razz

At any rate, I have a bunch a D project in my solution. Most of them static library. And one 1 exe.
The unittest in my libraries are not run! (even though I link with the exe, and use the module containing the unittest!)

Any tips on how to run unit test in a static library probject?
Or should I make a unittest build target where my lib is an exe (can I? how?)
Back to top
View user's profile Send private message AIM Address
sagitario



Joined: 03 Mar 2007
Posts: 292

PostPosted: Mon Jun 20, 2011 4:42 pm    Post subject: Reply with quote

If dmd generates a library. it splits a module into a lot of small objects (e.g. each function is placed into its own object file) to reduce dependencies. These objects are then combined into the library.
This unittests are emitted into their own chunk, but they are not referenced from anywhere, so that they do not end up in the executable.

If it works with your dependencies, setting up a configuration to build an executable for each library is the easiest solution, You will need to add an empty main function somewhere to link successfully:
Code:
version(unittest) void main() {}


The Visual C++ compiler has an option to link the object files of depending libraries directly without using the library. A similar approach could work with Visual D, but that would need to be added.
Back to top
View user's profile Send private message
lloyd



Joined: 16 May 2011
Posts: 18
Location: Australia

PostPosted: Mon Jun 20, 2011 5:24 pm    Post subject: Reply with quote

Thanks!
Good idea! I'll give it a try tonight...
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Visual D All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group