Created
April 6, 2018 11:00
-
-
Save atilaneves/760cfc46f81005ed0d9503cd89c49acd to your computer and use it in GitHub Desktop.
__traits(getUnitTests) with separate compilation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
unittest { | |
writeln("mod1 test1"); | |
} | |
unittest { | |
writeln("mod1 test2"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
unittest { | |
writeln("mod2 test1"); | |
} | |
unittest { | |
writeln("mod2 test2"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
clear | |
dmd -c -unittest mod1.d | |
dmd -c -unittest mod2.d | |
dmd -c -unittest runner.d | |
dmd -ofrunner runner.o mod1.o mod2.o | |
./runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shared static this() { | |
import core.runtime: Runtime; | |
Runtime.moduleUnitTester = () => true; | |
} | |
void main() { | |
import mod1; | |
import mod2; | |
foreach(test1; __traits(getUnitTests, mod1)) { | |
test1(); | |
} | |
foreach(test2; __traits(getUnitTests, mod2)) { | |
test2(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment