Mercurial > projects > ldc
annotate tests/runminitest.d @ 418:94c4e090c1af
clean out obj dir before running mini test.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Mon, 28 Jul 2008 07:25:13 +0200 |
parents | 76bf1eaaf4dc |
children | ea991021a56a |
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"); |
418
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
25 |
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
26 if (!exists("obj")) |
383
c028fd91b3b0
.hgignore updates. runminitest stores object files separately.
Christian Kamm <kamm incasoftware de>
parents:
342
diff
changeset
|
27 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
|
28 |
418
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
29 foreach(f; listdir("./obj", "*")) |
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
30 { |
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
31 std.file.remove(f); |
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
32 } |
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
33 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
34 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
|
35 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
46 |
38
27b2f40bdb58
[svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
lindquist
parents:
14
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 writefln("TEST NAME: ", testname); |
418
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
51 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
52 string cmd = format("llvmdc %s -quiet -ofobj/%s -odobj", c, testname); |
100 | 53 foreach(v; args[1..$]) { |
54 cmd ~= ' '; | |
55 cmd ~= v; | |
56 } | |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
57 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
|
58 writefln(cmd); |
27b2f40bdb58
[svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
lindquist
parents:
14
diff
changeset
|
59 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
|
60 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
|
61 compilefailed ~= c; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
62 } |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 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
|
67 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
68 else { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
69 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
|
70 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
|
71 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
72 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
73 else { |
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 (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
|
75 nocompilefailed ~= c; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
76 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
77 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
78 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
79 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
|
80 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
81 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
|
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 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
|
84 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
|
85 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
|
86 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
87 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
|
88 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
89 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
90 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
|
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 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
|
93 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
|
94 writefln(" ",b); |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
95 } |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
96 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
|
97 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
98 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
99 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
|
100 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
101 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
|
102 foreach(b; runfailed) { |
12 | 103 writefln(" ",b); |
104 } | |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
105 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
|
106 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
107 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
108 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
|
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(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
|
111 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
|
112 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
|
113 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
114 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
|
115 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
116 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
117 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
|
118 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
119 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
|
120 } |