view tests/runminitest.d @ 715:30b42a283c8e

Removed TypeOpaque from DMD. Changed runtime functions taking opaque[] to void[]. Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[]. Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86. Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing. Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way... Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8. Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 22 Oct 2008 14:55:33 +0200
parents 6aaa3d3c1183
children 28d9cbcd7580
line wrap: on
line source

module runminitest;

import std.file;
import std.path;
import std.process;
import std.stdio;
import std.string;

int main(string[] args)
{
    enum : int
    {
        COMPILE,
        NOCOMPILE,
        RUN,
        NORUN
    }

    string[] compilefailed;
    string[] nocompilefailed;
    string[] runfailed;
    string[] norunfailed;

    chdir("mini");

    if (!exists("obj"))
        mkdir("obj");

    foreach(f; listdir("./obj", "*"))
    {
        std.file.remove(f);
    }

    static int classify(char[] name)
    {
        if (find(name, "compile_") == 0)
            return COMPILE;
        else if (find(name, "nocompile_") == 0)
            return NOCOMPILE;
        else if (find(name, "run_") == 0)
            return RUN;
        else if (find(name, "norun_") == 0)
            return NORUN;
        return RUN;
    }

    auto contents = listdir(".", "*.d");
    foreach(c; contents) {
        auto testname = getName(getBaseName(c));
        writefln("TEST NAME: ", testname);

        string cmd = format("ldc %s -quiet -ofobj" ~ std.path.sep ~ "%s -odobj", c, testname);
        foreach(v; args[1..$]) {
            cmd ~= ' ';
            cmd ~= v;
        }
        int cl = classify(testname);
        if (cl == COMPILE || cl == NOCOMPILE)
            cmd ~= " -c";
        writefln(cmd);
        if (system(cmd) != 0) {
            if (cl != NOCOMPILE)
                compilefailed ~= c;
        }
        else if (cl == RUN || cl == NORUN) {
            if (system("obj" ~ std.path.sep ~ testname) != 0) {
                if (cl == RUN)
                    runfailed ~= c;
            }
            else {
                if (cl == NORUN)
                    norunfailed ~= c;
            }
        }
        else {
            if (cl == NOCOMPILE)
                nocompilefailed ~= c;
        }
    }

    size_t nerrors = 0;

    if (compilefailed.length > 0)
    {
        writefln(compilefailed.length, '/', contents.length, " of the tests failed to compile:");
        foreach(b; compilefailed) {
            writefln("  ",b);
        }
        nerrors += compilefailed.length;
    }

    if (nocompilefailed.length > 0)
    {
        writefln(nocompilefailed.length, '/', contents.length, " of the tests failed to NOT compile:");
        foreach(b; nocompilefailed) {
            writefln("  ",b);
        }
        nerrors += nocompilefailed.length;
    }

    if (runfailed.length > 0)
    {
        writefln(runfailed.length, '/', contents.length, " of the tests failed to run:");
        foreach(b; runfailed) {
            writefln("  ",b);
        }
        nerrors += runfailed.length;
    }

    if (norunfailed.length > 0)
    {
        writefln(norunfailed.length, '/', contents.length, " of the tests failed to NOT run:");
        foreach(b; norunfailed) {
            writefln("  ",b);
        }
        nerrors += norunfailed.length;
    }

    writefln(contents.length - nerrors, '/', contents.length, " of the tests passed");

    return nerrors ? 1 : 0;
}