View previous topic :: View next topic |
Author |
Message |
lloyd
Joined: 16 May 2011 Posts: 18 Location: Australia
|
Posted: Mon Jun 20, 2011 10:58 am Post subject: Unittest |
|
|
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 !
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 |
|
|
sagitario
Joined: 03 Mar 2007 Posts: 292
|
Posted: Mon Jun 20, 2011 4:42 pm Post subject: |
|
|
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 |
|
|
lloyd
Joined: 16 May 2011 Posts: 18 Location: Australia
|
Posted: Mon Jun 20, 2011 5:24 pm Post subject: |
|
|
Thanks!
Good idea! I'll give it a try tonight... |
|
Back to top |
|
|
|