annotate tests/runminitest.d @ 468:45a67b6f1310

Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially in this regard. Code for accessing nested variables and contexts rewritten. Probably more. Fairly well tested.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 04 Aug 2008 02:59:34 +0200
parents ea991021a56a
children 6aaa3d3c1183
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
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
463
ea991021a56a Use path separator to make minitests work on windows.
Christian Kamm <kamm incasoftware de>
parents: 418
diff changeset
52 string cmd = format("llvmdc %s -quiet -ofobj" ~ std.path.sep ~ "%s -odobj", c, testname);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 42
diff changeset
53 foreach(v; args[1..$]) {
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 42
diff changeset
54 cmd ~= ' ';
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 42
diff changeset
55 cmd ~= v;
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 42
diff changeset
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);
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
58 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
59 cmd ~= " -c";
38
27b2f40bdb58 [svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
lindquist
parents: 14
diff changeset
60 writefln(cmd);
27b2f40bdb58 [svn r42] Disabled the extensive logging by default. Use the -vv flag to get it back.
lindquist
parents: 14
diff changeset
61 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
62 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
63 compilefailed ~= c;
11
d3ee9efe20e2 [svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff changeset
64 }
415
76bf1eaaf4dc Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 383
diff changeset
65 else if (cl == RUN || cl == NORUN) {
463
ea991021a56a Use path separator to make minitests work on windows.
Christian Kamm <kamm incasoftware de>
parents: 418
diff changeset
66 if (system("obj" ~ std.path.sep ~ 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
67 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
68 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
69 }
76bf1eaaf4dc Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 383
diff changeset
70 else {
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 == NORUN)
76bf1eaaf4dc Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 383
diff changeset
72 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
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 }
76bf1eaaf4dc Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 383
diff changeset
75 else {
76bf1eaaf4dc Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 383
diff changeset
76 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
77 nocompilefailed ~= c;
11
d3ee9efe20e2 [svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff changeset
78 }
d3ee9efe20e2 [svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff changeset
79 }
d3ee9efe20e2 [svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff changeset
80
415
76bf1eaaf4dc Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 383
diff changeset
81 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
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 (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
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(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
86 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
87 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
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 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
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 (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
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(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
95 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
96 writefln(" ",b);
d3ee9efe20e2 [svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff changeset
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 += 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
99 }
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 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
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(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
104 foreach(b; runfailed) {
12
ee302fe07296 [svn r16] * Updated all tests to have a main
lindquist
parents: 11
diff changeset
105 writefln(" ",b);
ee302fe07296 [svn r16] * Updated all tests to have a main
lindquist
parents: 11
diff changeset
106 }
415
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 += runfailed.length;
11
d3ee9efe20e2 [svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff changeset
108 }
d3ee9efe20e2 [svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
diff changeset
109
415
76bf1eaaf4dc Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 383
diff changeset
110 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
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 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
113 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
114 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
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 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
117 }
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 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
120
76bf1eaaf4dc Updated the mini test runner to allow classified tests as
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 383
diff changeset
121 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
122 }