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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
3 import tango.io.FileSystem,
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
4 tango.io.Stdout,
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
5 tango.io.vfs.FileFolder;
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
6 import Path = tango.io.Path;
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
7 import Util = tango.text.Util;
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
8 import tango.text.convert.Format;
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
9 import tango.stdc.stdlib,
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
22 char[][] compilefailed;
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
23 char[][] nocompilefailed;
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
24 char[][] runfailed;
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
29 if (!Path.exists("obj"))
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
50 auto scan = new FileFolder (".");
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
53 auto testname = Path.parse(c.name).name;
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
56 char[] cmd = Format.convert("ldc {} -quiet -L-s -ofobj/{} -odobj", c, testname);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 42
diff changeset
57 foreach(v; args[1..$]) {
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 42
diff changeset
58 cmd ~= ' ';
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 42
diff changeset
59 cmd ~= v;
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 42
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
64 Stdout(cmd).newline;
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
109 Stdout.formatln(" {}",b);
12
ee302fe07296 [svn r16] * Updated all tests to have a main
lindquist
parents: 11
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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
f48500f9350c Ported script to Tango
larsivi@larsivi-gutsy
parents: 781
diff changeset
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 }