Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
print more information for tests
Browse files Browse the repository at this point in the history
- OK or FAIL
- exception message (traceback) for failures
- test duration (in ms)
  • Loading branch information
MartinNowak committed Aug 13, 2013
1 parent 29a2d66 commit 26960c3
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/test_runner.d
@@ -1,4 +1,4 @@
import core.runtime;
import core.runtime, core.time : TickDuration;
import core.stdc.stdio;

ModuleInfo* getModuleInfo(string name)
Expand All @@ -13,11 +13,23 @@ bool tester()
assert(Runtime.args.length == 2);
auto name = Runtime.args[1];

auto m = getModuleInfo(name);
if (auto fp = m.unitTest)
if (auto fp = getModuleInfo(name).unitTest)
{
printf("Testing %.*s\n", cast(int)name.length, name.ptr);
fp();
printf("Testing %.*s", cast(int)name.length, name.ptr);

try
{
immutable t0 = TickDuration.currSystemTick;
fp();
immutable t1 = TickDuration.currSystemTick;
printf(" OK (took %dms)\n", (t1 - t0).msecs);
}
catch (Throwable e)
{
auto msg = e.toString();
printf(" FAIL\n%.*s", cast(int)msg.length, msg.ptr);
return false;
}
}
return true;
}
Expand Down

0 comments on commit 26960c3

Please sign in to comment.