blob: 851811c8662c4a468820807489626f334a51b478 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
string Last_file = "";
int main(int argc, const char* argv[]) {
Last_file = flag_value("--until", argc, argv);
if (flag("test", argc, argv))
return run_tests();
return tangle_files_in_cwd();
}
bool eof(istream& in) {
in.peek();
return in.eof();
}
bool flag(const string& flag, int argc, const char* argv[]) {
for (int i = 1; i < argc; ++i)
if (string(argv[i]) == flag)
return true;
return false;
}
string flag_value(const string& flag, int argc, const char* argv[]) {
for (int i = 1; i < argc-1; ++i)
if (string(argv[i]) == flag)
return argv[i+1];
return "";
}
//// test harness
int run_tests() {
time_t t; time(&t);
cerr << "C tests: " << ctime(&t);
for (unsigned long i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) {
START_TRACING_UNTIL_END_OF_SCOPE;
setup();
(*Tests[i])();
verify();
}
cerr << '\n';
if (Num_failures > 0)
cerr << Num_failures << " failure"
<< (Num_failures > 1 ? "s" : "")
<< '\n';
return Num_failures;
}
void verify() {
Hide_warnings = false;
if (!Passed)
;
else
cerr << ".";
}
void setup() {
Hide_warnings = false;
Passed = true;
}
|