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