Mercurial > projects > ldc
annotate 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 |
rev | line source |
---|---|
341
1bb99290e03a
[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
lindquist
parents:
100
diff
changeset
|
1 module runminitest; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
2 |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
3 import std.file; |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
4 import std.path; |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
5 import std.process; |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
6 import std.stdio; |
342
d8b165faae9b
[svn r363] Fixed a problem with the mini-test-driver.
lindquist
parents:
341
diff
changeset
|
7 import std.string; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
8 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
9 int main(string[] args) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
10 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
11 enum : int |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
12 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
13 COMPILE, |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
14 NOCOMPILE, |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
15 RUN, |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
16 NORUN |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
17 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
18 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
19 string[] compilefailed; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
20 string[] nocompilefailed; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
21 string[] runfailed; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
22 string[] norunfailed; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
23 |
341
1bb99290e03a
[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
lindquist
parents:
100
diff
changeset
|
24 chdir("mini"); |
383
c028fd91b3b0
.hgignore updates. runminitest stores object files separately.
Christian Kamm <kamm incasoftware de>
parents:
342
diff
changeset
|
25 if(!exists("obj")) |
c028fd91b3b0
.hgignore updates. runminitest stores object files separately.
Christian Kamm <kamm incasoftware de>
parents:
342
diff
changeset
|
26 mkdir("obj"); |
38
27b2f40bdb58
[svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
lindquist
parents:
14
diff
changeset
|
27 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
28 static int classify(char[] name) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
29 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
30 if (find(name, "compile_") == 0) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
31 return COMPILE; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
32 else if (find(name, "nocompile_") == 0) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
33 return NOCOMPILE; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
34 else if (find(name, "run_") == 0) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
35 return RUN; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
36 else if (find(name, "norun_") == 0) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
37 return NORUN; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
38 return RUN; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
39 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
40 |
38
27b2f40bdb58
[svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
lindquist
parents:
14
diff
changeset
|
41 auto contents = listdir(".", "*.d"); |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
42 foreach(c; contents) { |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
43 auto testname = getName(getBaseName(c)); |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
44 writefln("TEST NAME: ", testname); |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
45 string cmd = format("llvmdc %s -quiet -ofobj/%s -odobj", c, testname); |
100 | 46 foreach(v; args[1..$]) { |
47 cmd ~= ' '; | |
48 cmd ~= v; | |
49 } | |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
50 int cl = classify(testname); |
38
27b2f40bdb58
[svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
lindquist
parents:
14
diff
changeset
|
51 writefln(cmd); |
27b2f40bdb58
[svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
lindquist
parents:
14
diff
changeset
|
52 if (system(cmd) != 0) { |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
53 if (cl != NOCOMPILE) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
54 compilefailed ~= c; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
55 } |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
56 else if (cl == RUN || cl == NORUN) { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
57 if (system("obj/" ~ testname) != 0) { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
58 if (cl == RUN) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
59 runfailed ~= c; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
60 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
61 else { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
62 if (cl == NORUN) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
63 norunfailed ~= c; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
64 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
65 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
66 else { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
67 if (cl == NOCOMPILE) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
68 nocompilefailed ~= c; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
69 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
70 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
71 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
72 size_t nerrors = 0; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
73 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
74 if (compilefailed.length > 0) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
75 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
76 writefln(compilefailed.length, '/', contents.length, " of the tests failed to compile:"); |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
77 foreach(b; compilefailed) { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
78 writefln(" ",b); |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
79 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
80 nerrors += compilefailed.length; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
81 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
82 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
83 if (nocompilefailed.length > 0) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
84 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
85 writefln(nocompilefailed.length, '/', contents.length, " of the tests failed to NOT compile:"); |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
86 foreach(b; nocompilefailed) { |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
87 writefln(" ",b); |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
88 } |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
89 nerrors += nocompilefailed.length; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
90 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
91 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
92 if (runfailed.length > 0) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
93 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
94 writefln(runfailed.length, '/', contents.length, " of the tests failed to run:"); |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
95 foreach(b; runfailed) { |
12 | 96 writefln(" ",b); |
97 } | |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
98 nerrors += runfailed.length; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
99 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
100 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
101 if (norunfailed.length > 0) |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
102 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
103 writefln(norunfailed.length, '/', contents.length, " of the tests failed to NOT run:"); |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
104 foreach(b; norunfailed) { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
105 writefln(" ",b); |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
106 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
107 nerrors += norunfailed.length; |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
108 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
109 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
110 writefln(contents.length - nerrors, '/', contents.length, " of the tests passed"); |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
111 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
112 return nerrors ? 1 : 0; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
113 } |