comparison tests/runminitest.d @ 415:76bf1eaaf4dc

Updated the mini test runner to allow classified tests as compile,nocompile,run,norun.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 28 Jul 2008 03:03:44 +0200
parents c028fd91b3b0
children 94c4e090c1af
comparison
equal deleted inserted replaced
414:ac1fcc138e42 415:76bf1eaaf4dc
4 import std.path; 4 import std.path;
5 import std.process; 5 import std.process;
6 import std.stdio; 6 import std.stdio;
7 import std.string; 7 import std.string;
8 8
9 int main(string[] args) { 9 int main(string[] args)
10 string[] bad; 10 {
11 string[] badrun; 11 enum : int
12 {
13 COMPILE,
14 NOCOMPILE,
15 RUN,
16 NORUN
17 }
18
19 string[] compilefailed;
20 string[] nocompilefailed;
21 string[] runfailed;
22 string[] norunfailed;
12 23
13 chdir("mini"); 24 chdir("mini");
14 if(!exists("obj")) 25 if(!exists("obj"))
15 mkdir("obj"); 26 mkdir("obj");
16 27
28 static int classify(char[] name)
29 {
30 if (find(name, "compile_") == 0)
31 return COMPILE;
32 else if (find(name, "nocompile_") == 0)
33 return NOCOMPILE;
34 else if (find(name, "run_") == 0)
35 return RUN;
36 else if (find(name, "norun_") == 0)
37 return NORUN;
38 return RUN;
39 }
40
17 auto contents = listdir(".", "*.d"); 41 auto contents = listdir(".", "*.d");
18 foreach(c; contents) { 42 foreach(c; contents) {
19 string cmd = format("llvmdc %s -quiet -ofobj/%s", c, getName(c)); 43 auto testname = getName(getBaseName(c));
44 writefln("TEST NAME: ", testname);
45 string cmd = format("llvmdc %s -quiet -ofobj/%s -odobj", c, testname);
20 foreach(v; args[1..$]) { 46 foreach(v; args[1..$]) {
21 cmd ~= ' '; 47 cmd ~= ' ';
22 cmd ~= v; 48 cmd ~= v;
23 } 49 }
50 int cl = classify(testname);
24 writefln(cmd); 51 writefln(cmd);
25 if (system(cmd) != 0) { 52 if (system(cmd) != 0) {
26 bad ~= c; 53 if (cl != NOCOMPILE)
54 compilefailed ~= c;
27 } 55 }
28 else if (system("obj/" ~ getName(c)) != 0) { 56 else if (cl == RUN || cl == NORUN) {
29 badrun ~= c; 57 if (system("obj/" ~ testname) != 0) {
58 if (cl == RUN)
59 runfailed ~= c;
60 }
61 else {
62 if (cl == NORUN)
63 norunfailed ~= c;
64 }
65 }
66 else {
67 if (cl == NOCOMPILE)
68 nocompilefailed ~= c;
30 } 69 }
31 } 70 }
32 71
33 int ret = 0; 72 size_t nerrors = 0;
34 if (bad.length > 0 || badrun.length > 0) { 73
35 writefln(bad.length, '/', contents.length, " of the tests failed to compile:"); 74 if (compilefailed.length > 0)
36 foreach(b; bad) { 75 {
76 writefln(compilefailed.length, '/', contents.length, " of the tests failed to compile:");
77 foreach(b; compilefailed) {
37 writefln(" ",b); 78 writefln(" ",b);
38 } 79 }
39 writefln(badrun.length, '/', contents.length - bad.length, " of the compiled tests failed to run:"); 80 nerrors += compilefailed.length;
40 foreach(b; badrun) { 81 }
82
83 if (nocompilefailed.length > 0)
84 {
85 writefln(nocompilefailed.length, '/', contents.length, " of the tests failed to NOT compile:");
86 foreach(b; nocompilefailed) {
41 writefln(" ",b); 87 writefln(" ",b);
42 } 88 }
43 ret = 1; 89 nerrors += nocompilefailed.length;
44 } 90 }
45 91
46 writefln(contents.length - bad.length - badrun.length, '/', contents.length, " of the tests passed"); 92 if (runfailed.length > 0)
47 return ret; 93 {
94 writefln(runfailed.length, '/', contents.length, " of the tests failed to run:");
95 foreach(b; runfailed) {
96 writefln(" ",b);
97 }
98 nerrors += runfailed.length;
99 }
100
101 if (norunfailed.length > 0)
102 {
103 writefln(norunfailed.length, '/', contents.length, " of the tests failed to NOT run:");
104 foreach(b; norunfailed) {
105 writefln(" ",b);
106 }
107 nerrors += norunfailed.length;
108 }
109
110 writefln(contents.length - nerrors, '/', contents.length, " of the tests passed");
111
112 return nerrors ? 1 : 0;
48 } 113 }