unittestで最後まで

こういう意見があったので,こんな感じでどうでしょうか!

// Written in the D programming language.

module testhelper;

import std.stdio : write, writeln;

private uint failures;

static this()
{
    write("Unittest started...");
}

static ~this()
{
    switch (failures) {
      case 0:  writeln("All green!");                         break;
      case 1:  writeln("\nYou failed 1 test.");               break;
      default: writeln("\nYou failed ", failures, " tests."); break;
    }
}

extern (C) void _d_assert(char[] filename, uint line)
{
    static char[] file;

    if (!failures++)
        writeln("\n");

    if (file != filename) {
        file  = filename;
        writeln(file, ".d");
    }

    writeln("  Failed at line ", line);
}

後は

$ dmd -testhelper.d -unittest -run foo.d

とかみたいに一緒にやってやれば最後までやってくれるはず.まぁ他のテストツールに慣れてると,こういうの勝手にやって欲しいなぁとか思う.
それはそうと,rdmdだとコマンドラインオプションでimport出来たっけ?2.040のrdmdがMacだと動かなくて確認出来ない.