forked from ldc-developers/druntime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_runner.d
61 lines (54 loc) · 1.49 KB
/
test_runner.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import core.runtime, core.time : MonoTime;
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];
immutable pkg = ".package";
immutable pkgLen = pkg.length;
debug string mode = "debug";
else string mode = "release";
static if ((void*).sizeof == 4) mode ~= "32";
else static if ((void*).sizeof == 8) mode ~= "64";
else static assert(0, "You must be from the future!");
if (name.length > pkgLen && name[$ - pkgLen .. $] == pkg)
name = name[0 .. $ - pkgLen];
if (auto fp = getModuleInfo(name).unitTest)
{
/*
try
{
immutable t0 = MonoTime.currTime;
fp();
printf("%.3fs PASS %.*s %.*s\n",
(MonoTime.currTime - t0).total!"msecs" / 1000.0,
cast(uint)mode.length, mode.ptr,
cast(uint)name.length, name.ptr);
}
catch (Throwable e)
{
auto msg = e.toString();
printf("****** FAIL %.*s %.*s\n%.*s\n",
cast(uint)mode.length, mode.ptr,
cast(uint)name.length, name.ptr,
cast(uint)msg.length, msg.ptr);
return false;
}
*/
fp();
}
return true;
}
shared static this()
{
Runtime.moduleUnitTester = &tester;
}
void main()
{
}