Commit | Line | Data |
8d063cd8 |
1 | #!./perl |
2 | |
fe14fcc3 |
3 | # $Header: TEST,v 4.0 91/03/20 01:40:22 lwall Locked $ |
8d063cd8 |
4 | |
5 | # This is written in a peculiar style, since we're trying to avoid |
6 | # most of the constructs we'll be testing for. |
7 | |
a687059c |
8 | $| = 1; |
9 | |
8d063cd8 |
10 | if ($ARGV[0] eq '-v') { |
11 | $verbose = 1; |
12 | shift; |
13 | } |
14 | |
378cc40b |
15 | chdir 't' if -f 't/TEST'; |
16 | |
8d063cd8 |
17 | if ($ARGV[0] eq '') { |
fe14fcc3 |
18 | @ARGV = split(/[ \n]/, |
19 | `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`); |
8d063cd8 |
20 | } |
21 | |
5303340c |
22 | open(CONFIG,"../config.sh"); |
23 | while (<CONFIG>) { |
135863df |
24 | if (/sharpbang='(.*)'/) { |
25 | $sharpbang = ($1 eq '#!'); |
26 | last; |
27 | } |
28 | } |
8d063cd8 |
29 | $bad = 0; |
30 | while ($test = shift) { |
fe14fcc3 |
31 | if ($test =~ /^$/) { |
378cc40b |
32 | next; |
33 | } |
fe14fcc3 |
34 | $te = $test; |
35 | chop($te); |
36 | print "$te" . '.' x (15 - length($te)); |
135863df |
37 | if ($sharpbang) { |
378cc40b |
38 | open(results,"./$test|") || (print "can't run.\n"); |
135863df |
39 | } else { |
378cc40b |
40 | open(script,"$test") || die "Can't run $test.\n"; |
135863df |
41 | $_ = <script>; |
42 | close(script); |
43 | if (/#!..perl(.*)/) { |
44 | $switch = $1; |
45 | } else { |
46 | $switch = ''; |
47 | } |
48 | open(results,"./perl$switch $test|") || (print "can't run.\n"); |
49 | } |
8d063cd8 |
50 | $ok = 0; |
378cc40b |
51 | $next = 0; |
8d063cd8 |
52 | while (<results>) { |
53 | if ($verbose) { |
54 | print $_; |
55 | } |
56 | unless (/^#/) { |
57 | if (/^1\.\.([0-9]+)/) { |
58 | $max = $1; |
59 | $next = 1; |
60 | $ok = 1; |
61 | } else { |
7e1cf235 |
62 | $next = $1, $ok = 0, last if /^not ok ([0-9]*)/; |
8d063cd8 |
63 | if (/^ok (.*)/ && $1 == $next) { |
64 | $next = $next + 1; |
65 | } else { |
66 | $ok = 0; |
67 | } |
68 | } |
69 | } |
70 | } |
71 | $next = $next - 1; |
72 | if ($ok && $next == $max) { |
73 | print "ok\n"; |
74 | } else { |
75 | $next += 1; |
76 | print "FAILED on test $next\n"; |
77 | $bad = $bad + 1; |
78 | $_ = $test; |
79 | if (/^base/) { |
378cc40b |
80 | die "Failed a basic test--cannot continue.\n"; |
8d063cd8 |
81 | } |
82 | } |
83 | } |
84 | |
85 | if ($bad == 0) { |
86 | if ($ok) { |
87 | print "All tests successful.\n"; |
88 | } else { |
378cc40b |
89 | die "FAILED--no tests were run for some reason.\n"; |
8d063cd8 |
90 | } |
91 | } else { |
92 | if ($bad == 1) { |
378cc40b |
93 | die "Failed 1 test.\n"; |
8d063cd8 |
94 | } else { |
378cc40b |
95 | die "Failed $bad tests.\n"; |
8d063cd8 |
96 | } |
97 | } |
98 | ($user,$sys,$cuser,$csys) = times; |
99 | print sprintf("u=%g s=%g cu=%g cs=%g\n",$user,$sys,$cuser,$csys); |