This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #447 from dawgfoto/SharedRuntime_7
unittests with shared library
- Loading branch information
Showing
3 changed files
with
73 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import core.runtime; | ||
import core.stdc.stdio; | ||
|
||
ModuleInfo* getModuleInfo(string name) | ||
{ | ||
foreach (m; ModuleInfo) | ||
if (m.name == name) return m; | ||
assert(0, "module '"~name~"' not found"); | ||
} | ||
|
||
bool tester() | ||
{ | ||
assert(Runtime.args().length == 2); | ||
auto name = Runtime.args()[1]; | ||
|
||
auto m = getModuleInfo(name); | ||
if (auto fp = m.unitTest) | ||
{ | ||
printf("Testing %.*s\n", cast(int)name.length, name.ptr); | ||
fp(); | ||
} | ||
return true; | ||
} | ||
|
||
shared static this() | ||
{ | ||
Runtime.moduleUnitTester = &tester; | ||
} | ||
|
||
void main() | ||
{ | ||
} |