Mercurial > projects > ldc
annotate tests/runminitest.d @ 1198:f48500f9350c
Ported script to Tango
author | larsivi@larsivi-gutsy |
---|---|
date | Tue, 07 Apr 2009 18:37:19 +0200 |
parents | 28d9cbcd7580 |
children | 498c484f3a03 |
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 |
1198 | 3 import tango.io.FileSystem, |
4 tango.io.Stdout, | |
5 tango.io.vfs.FileFolder; | |
6 import Path = tango.io.Path; | |
7 import Util = tango.text.Util; | |
8 import tango.text.convert.Format; | |
9 import tango.stdc.stdlib, | |
10 tango.stdc.stringz; | |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
11 |
1198 | 12 int main(char[][] args) |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
13 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
14 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
|
15 { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
16 COMPILE, |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
17 NOCOMPILE, |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
18 RUN, |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
19 NORUN |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
20 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
21 |
1198 | 22 char[][] compilefailed; |
23 char[][] nocompilefailed; | |
24 char[][] runfailed; | |
25 char[][] norunfailed; | |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
26 |
1198 | 27 FileSystem.setDirectory("mini"); |
418
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
28 |
1198 | 29 if (!Path.exists("obj")) |
30 Path.createFolder("obj"); | |
38
27b2f40bdb58
[svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
lindquist
parents:
14
diff
changeset
|
31 |
1198 | 32 foreach(f; Path.children("./obj")) |
418
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
33 { |
1198 | 34 Path.remove(f.path ~ f.name); |
418
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
35 } |
94c4e090c1af
clean out obj dir before running mini test.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
415
diff
changeset
|
36 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
37 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
|
38 { |
1198 | 39 if (Util.containsPattern(name, "compile_")) |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
40 return COMPILE; |
1198 | 41 else if (Util.containsPattern(name, "nocompile_")) |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
42 return NOCOMPILE; |
1198 | 43 else if (Util.containsPattern(name, "run_")) |
415
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; |
1198 | 45 else if (Util.containsPattern(name, "norun_")) |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
46 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
|
47 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
|
48 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
49 |
1198 | 50 auto scan = new FileFolder ("."); |
51 auto contents = scan.tree.catalog("*.d"); | |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
52 foreach(c; contents) { |
1198 | 53 auto testname = Path.parse(c.name).name; |
54 Stdout.formatln("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
|
55 |
1198 | 56 char[] cmd = Format.convert("ldc {} -quiet -L-s -ofobj/{} -odobj", c, testname); |
100 | 57 foreach(v; args[1..$]) { |
58 cmd ~= ' '; | |
59 cmd ~= v; | |
60 } | |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
61 int cl = classify(testname); |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
463
diff
changeset
|
62 if (cl == COMPILE || cl == NOCOMPILE) |
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
463
diff
changeset
|
63 cmd ~= " -c"; |
1198 | 64 Stdout(cmd).newline; |
65 if (system(toStringz(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
|
66 if (cl != NOCOMPILE) |
1198 | 67 compilefailed ~= c.toString; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
68 } |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
69 else if (cl == RUN || cl == NORUN) { |
1198 | 70 if (system(toStringz("obj/" ~ testname)) != 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
|
71 if (cl == RUN) |
1198 | 72 runfailed ~= c.toString; |
415
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 else { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
75 if (cl == NORUN) |
1198 | 76 norunfailed ~= c.toString; |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
77 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
78 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
79 else { |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
80 if (cl == NOCOMPILE) |
1198 | 81 nocompilefailed ~= c.toString; |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
82 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
83 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
84 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
85 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
|
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 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
|
88 { |
1198 | 89 Stdout.formatln("{}{}{}{}", compilefailed.length, '/', contents.files, " of the tests failed to compile:"); |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
90 foreach(b; compilefailed) { |
1198 | 91 Stdout.formatln(" {}",b); |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
92 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
93 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
|
94 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
95 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
96 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
|
97 { |
1198 | 98 Stdout.formatln("{}{}{}{}", nocompilefailed.length, '/', contents.files, " of the tests failed to NOT compile:"); |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
99 foreach(b; nocompilefailed) { |
1198 | 100 Stdout.formatln(" {}",b); |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
101 } |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
102 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
|
103 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
104 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
105 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
|
106 { |
1198 | 107 Stdout.formatln("{}{}{}{}", runfailed.length, '/', contents.files, " of the tests failed to run:"); |
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 foreach(b; runfailed) { |
1198 | 109 Stdout.formatln(" {}",b); |
12 | 110 } |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
111 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
|
112 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff
changeset
|
113 |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
114 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
|
115 { |
1198 | 116 Stdout.formatln("{}{}{}{}", norunfailed.length, '/', contents.files, " of the tests failed to NOT run:"); |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
117 foreach(b; norunfailed) { |
1198 | 118 Stdout.formatln(" {}",b); |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
119 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
120 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
|
121 } |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
122 |
1198 | 123 Stdout.formatln("{}{}{}{}", contents.files - nerrors, '/', contents.files, " of the tests passed"); |
415
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
124 |
76bf1eaaf4dc
Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
383
diff
changeset
|
125 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
|
126 } |