Shared static this() not executed for unittest

Neia Neutuladh neia at ikeran.org
Sat Dec 15 17:27:36 UTC 2018


On Sat, 15 Dec 2018 17:19:05 +0000, Timoses wrote:
> Running `dub test` will output:
> Running ./unit-test-library writeln: unittest All unit tests have been
> run successfully.
> 
> Why is the `shared static this()` not executed?

Run `dub clean; dub test -v` and you'll see that main.d isn't compiled 
into the test library.

dub test substitutes its own main() function over yours. In order to do 
this, it needs to not compile in your main() and to compile in its own. 
dmd doesn't have an option to replace main(), so dub drops that entire 
source file.


More information about the Digitalmars-d-learn mailing list