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

Commit

Permalink
Merge pull request #1171 from andralex/unittest-names
Browse files Browse the repository at this point in the history
Better printed information in unittests
  • Loading branch information
WalterBright committed Feb 15, 2015
2 parents 4a2810c + a62fa84 commit 52982cf
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/test_runner.d
Expand Up @@ -15,7 +15,13 @@ bool tester()
immutable pkg = ".package";
immutable pkgLen = pkg.length;

if(name.length > pkgLen && name[$ - pkgLen .. $] == pkg)
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)
Expand All @@ -24,15 +30,18 @@ bool tester()
{
immutable t0 = MonoTime.currTime;
fp();
immutable t1 = MonoTime.currTime;
printf("%.3fs PASS %.*s\n", (t1 - t0).total!"msecs" / 1000.0,
cast(int)name.length, name.ptr);
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\n%.*s\n", cast(int)name.length, name.ptr,
cast(int)msg.length, msg.ptr);
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;
}
}
Expand Down

0 comments on commit 52982cf

Please sign in to comment.