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 | ||
4633a7c4 LW |
17 | die "You need to run \"make test\" first to set things up.\n" |
18 | unless -e 'perl' or -e 'perl.exe'; | |
19 | ||
20 | $ENV{EMXSHELL} = 'sh'; # For OS/2 | |
748a9306 | 21 | |
8d063cd8 | 22 | if ($ARGV[0] eq '') { |
fe14fcc3 | 23 | @ARGV = split(/[ \n]/, |
8ebc5c01 | 24 | `echo base/*.t comp/*.t cmd/*.t pragma/*.t io/*.t; echo op/*.t lib/*.t`); |
8d063cd8 LW |
25 | } |
26 | ||
ff68c719 | 27 | if ($^O eq 'os2' || $^O eq 'qnx') { |
28 | $sharpbang = 0; | |
29 | } | |
30 | else { | |
31 | open(CONFIG, "../config.sh"); | |
32 | while (<CONFIG>) { | |
33 | if (/sharpbang='(.*)'/) { | |
34 | $sharpbang = ($1 eq '#!'); | |
35 | last; | |
36 | } | |
135863df | 37 | } |
ff68c719 | 38 | close(CONFIG); |
135863df | 39 | } |
ff68c719 | 40 | |
8d063cd8 | 41 | $bad = 0; |
79072805 LW |
42 | $good = 0; |
43 | $total = @ARGV; | |
8d063cd8 | 44 | while ($test = shift) { |
fe14fcc3 | 45 | if ($test =~ /^$/) { |
378cc40b LW |
46 | next; |
47 | } | |
fe14fcc3 LW |
48 | $te = $test; |
49 | chop($te); | |
55497cff | 50 | print "$te" . '.' x (18 - length($te)); |
135863df | 51 | if ($sharpbang) { |
a0d0e21e | 52 | open(results,"./$test |") || (print "can't run.\n"); |
135863df | 53 | } else { |
378cc40b | 54 | open(script,"$test") || die "Can't run $test.\n"; |
135863df AB |
55 | $_ = <script>; |
56 | close(script); | |
57 | if (/#!..perl(.*)/) { | |
58 | $switch = $1; | |
55497cff | 59 | if ($^O eq 'VMS') { |
60 | # Must protect uppercase switches with "" on command line | |
61 | $switch =~ s/-([A-Z]\S*)/"-$1"/g; | |
62 | } | |
135863df AB |
63 | } else { |
64 | $switch = ''; | |
65 | } | |
a0d0e21e | 66 | open(results,"./perl$switch $test |") || (print "can't run.\n"); |
135863df | 67 | } |
8d063cd8 | 68 | $ok = 0; |
378cc40b | 69 | $next = 0; |
8d063cd8 LW |
70 | while (<results>) { |
71 | if ($verbose) { | |
72 | print $_; | |
73 | } | |
74 | unless (/^#/) { | |
75 | if (/^1\.\.([0-9]+)/) { | |
76 | $max = $1; | |
2b317908 LW |
77 | $totmax += $max; |
78 | $files += 1; | |
8d063cd8 LW |
79 | $next = 1; |
80 | $ok = 1; | |
81 | } else { | |
7e1cf235 | 82 | $next = $1, $ok = 0, last if /^not ok ([0-9]*)/; |
8d063cd8 LW |
83 | if (/^ok (.*)/ && $1 == $next) { |
84 | $next = $next + 1; | |
85 | } else { | |
86 | $ok = 0; | |
87 | } | |
88 | } | |
89 | } | |
90 | } | |
91 | $next = $next - 1; | |
92 | if ($ok && $next == $max) { | |
bcce72a7 | 93 | if ($max) { |
94 | print "ok\n"; | |
95 | $good = $good + 1; | |
96 | } else { | |
97 | print "skipping test on this platform\n"; | |
98 | $files -= 1; | |
99 | } | |
8d063cd8 LW |
100 | } else { |
101 | $next += 1; | |
102 | print "FAILED on test $next\n"; | |
103 | $bad = $bad + 1; | |
104 | $_ = $test; | |
105 | if (/^base/) { | |
378cc40b | 106 | die "Failed a basic test--cannot continue.\n"; |
8d063cd8 LW |
107 | } |
108 | } | |
109 | } | |
110 | ||
111 | if ($bad == 0) { | |
112 | if ($ok) { | |
113 | print "All tests successful.\n"; | |
114 | } else { | |
378cc40b | 115 | die "FAILED--no tests were run for some reason.\n"; |
8d063cd8 LW |
116 | } |
117 | } else { | |
79072805 | 118 | $pct = sprintf("%.2f", $good / $total * 100); |
8d063cd8 | 119 | if ($bad == 1) { |
79072805 | 120 | warn "Failed 1 test, $pct% okay.\n"; |
8d063cd8 | 121 | } else { |
79072805 | 122 | die "Failed $bad/$total tests, $pct% okay.\n"; |
8d063cd8 LW |
123 | } |
124 | } | |
125 | ($user,$sys,$cuser,$csys) = times; | |
2b317908 LW |
126 | print sprintf("u=%g s=%g cu=%g cs=%g files=%d tests=%d\n", |
127 | $user,$sys,$cuser,$csys,$files,$totmax); |