Commit | Line | Data |
---|---|---|
8d063cd8 LW |
1 | #!./perl |
2 | ||
79072805 | 3 | # $RCSfile: TEST,v $$Revision: 4.1 $$Date: 92/08/07 18:27:00 $ |
8d063cd8 LW |
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 LW |
8 | $| = 1; |
9 | ||
8d063cd8 LW |
10 | if ($ARGV[0] eq '-v') { |
11 | $verbose = 1; | |
12 | shift; | |
13 | } | |
14 | ||
378cc40b LW |
15 | chdir 't' if -f 't/TEST'; |
16 | ||
8d063cd8 | 17 | if ($ARGV[0] eq '') { |
fe14fcc3 LW |
18 | @ARGV = split(/[ \n]/, |
19 | `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t lib/*.t`); | |
8d063cd8 LW |
20 | } |
21 | ||
5303340c LW |
22 | open(CONFIG,"../config.sh"); |
23 | while (<CONFIG>) { | |
135863df AB |
24 | if (/sharpbang='(.*)'/) { |
25 | $sharpbang = ($1 eq '#!'); | |
26 | last; | |
27 | } | |
28 | } | |
8d063cd8 | 29 | $bad = 0; |
79072805 LW |
30 | $good = 0; |
31 | $total = @ARGV; | |
8d063cd8 | 32 | while ($test = shift) { |
fe14fcc3 | 33 | if ($test =~ /^$/) { |
378cc40b LW |
34 | next; |
35 | } | |
fe14fcc3 LW |
36 | $te = $test; |
37 | chop($te); | |
38 | print "$te" . '.' x (15 - length($te)); | |
135863df | 39 | if ($sharpbang) { |
378cc40b | 40 | open(results,"./$test|") || (print "can't run.\n"); |
135863df | 41 | } else { |
378cc40b | 42 | open(script,"$test") || die "Can't run $test.\n"; |
135863df AB |
43 | $_ = <script>; |
44 | close(script); | |
45 | if (/#!..perl(.*)/) { | |
46 | $switch = $1; | |
47 | } else { | |
48 | $switch = ''; | |
49 | } | |
50 | open(results,"./perl$switch $test|") || (print "can't run.\n"); | |
51 | } | |
8d063cd8 | 52 | $ok = 0; |
378cc40b | 53 | $next = 0; |
8d063cd8 LW |
54 | while (<results>) { |
55 | if ($verbose) { | |
56 | print $_; | |
57 | } | |
58 | unless (/^#/) { | |
59 | if (/^1\.\.([0-9]+)/) { | |
60 | $max = $1; | |
2b317908 LW |
61 | $totmax += $max; |
62 | $files += 1; | |
8d063cd8 LW |
63 | $next = 1; |
64 | $ok = 1; | |
65 | } else { | |
7e1cf235 | 66 | $next = $1, $ok = 0, last if /^not ok ([0-9]*)/; |
8d063cd8 LW |
67 | if (/^ok (.*)/ && $1 == $next) { |
68 | $next = $next + 1; | |
69 | } else { | |
70 | $ok = 0; | |
71 | } | |
72 | } | |
73 | } | |
74 | } | |
75 | $next = $next - 1; | |
76 | if ($ok && $next == $max) { | |
77 | print "ok\n"; | |
79072805 | 78 | $good = $good + 1; |
8d063cd8 LW |
79 | } else { |
80 | $next += 1; | |
81 | print "FAILED on test $next\n"; | |
82 | $bad = $bad + 1; | |
83 | $_ = $test; | |
84 | if (/^base/) { | |
378cc40b | 85 | die "Failed a basic test--cannot continue.\n"; |
8d063cd8 LW |
86 | } |
87 | } | |
88 | } | |
89 | ||
90 | if ($bad == 0) { | |
91 | if ($ok) { | |
92 | print "All tests successful.\n"; | |
93 | } else { | |
378cc40b | 94 | die "FAILED--no tests were run for some reason.\n"; |
8d063cd8 LW |
95 | } |
96 | } else { | |
79072805 | 97 | $pct = sprintf("%.2f", $good / $total * 100); |
8d063cd8 | 98 | if ($bad == 1) { |
79072805 | 99 | warn "Failed 1 test, $pct% okay.\n"; |
8d063cd8 | 100 | } else { |
79072805 | 101 | die "Failed $bad/$total tests, $pct% okay.\n"; |
8d063cd8 LW |
102 | } |
103 | } | |
104 | ($user,$sys,$cuser,$csys) = times; | |
2b317908 LW |
105 | print sprintf("u=%g s=%g cu=%g cs=%g files=%d tests=%d\n", |
106 | $user,$sys,$cuser,$csys,$files,$totmax); |