Commit | Line | Data |
---|---|---|
8d063cd8 LW |
1 | #!./perl |
2 | ||
f46c10df | 3 | # Last change: Fri Jan 10 09:57:03 WET 1997 |
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 | ||
3e6e8be7 | 10 | if ($#ARGV >= 0 && $ARGV[0] eq '-v') { |
8d063cd8 LW |
11 | $verbose = 1; |
12 | shift; | |
13 | } | |
14 | ||
378cc40b LW |
15 | chdir 't' if -f 't/TEST'; |
16 | ||
3e6e8be7 | 17 | die "You need to run \"make test\" first to set things up.\n" |
4633a7c4 LW |
18 | unless -e 'perl' or -e 'perl.exe'; |
19 | ||
20 | $ENV{EMXSHELL} = 'sh'; # For OS/2 | |
748a9306 | 21 | |
3e6e8be7 MB |
22 | if ($#ARGV == -1) { |
23 | @ARGV = split(/[ \n]/, | |
24 | `echo base/*.t comp/*.t cmd/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t`); | |
8d063cd8 LW |
25 | } |
26 | ||
3e6e8be7 | 27 | if ($^O eq 'os2' || $^O eq 'qnx') { |
ff68c719 | 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; | |
3e6e8be7 MB |
44 | $files = 0; |
45 | $totmax = 0; | |
8d063cd8 | 46 | while ($test = shift) { |
fe14fcc3 | 47 | if ($test =~ /^$/) { |
378cc40b LW |
48 | next; |
49 | } | |
fe14fcc3 LW |
50 | $te = $test; |
51 | chop($te); | |
55497cff | 52 | print "$te" . '.' x (18 - length($te)); |
135863df | 53 | if ($sharpbang) { |
3e6e8be7 MB |
54 | -x $test || (print "isn't executable.\n"); |
55 | open(RESULTS,"./$test |") || (print "can't run.\n"); | |
135863df | 56 | } else { |
3e6e8be7 MB |
57 | open(SCRIPT,"$test") || die "Can't run $test.\n"; |
58 | $_ = <SCRIPT>; | |
59 | close(SCRIPT); | |
135863df AB |
60 | if (/#!..perl(.*)/) { |
61 | $switch = $1; | |
55497cff | 62 | if ($^O eq 'VMS') { |
63 | # Must protect uppercase switches with "" on command line | |
64 | $switch =~ s/-([A-Z]\S*)/"-$1"/g; | |
65 | } | |
135863df AB |
66 | } else { |
67 | $switch = ''; | |
68 | } | |
3e6e8be7 | 69 | open(RESULTS,"./perl$switch $test |") || (print "can't run.\n"); |
135863df | 70 | } |
8d063cd8 | 71 | $ok = 0; |
378cc40b | 72 | $next = 0; |
3e6e8be7 | 73 | while (<RESULTS>) { |
8d063cd8 LW |
74 | if ($verbose) { |
75 | print $_; | |
76 | } | |
77 | unless (/^#/) { | |
78 | if (/^1\.\.([0-9]+)/) { | |
79 | $max = $1; | |
2b317908 LW |
80 | $totmax += $max; |
81 | $files += 1; | |
8d063cd8 LW |
82 | $next = 1; |
83 | $ok = 1; | |
84 | } else { | |
7e1cf235 | 85 | $next = $1, $ok = 0, last if /^not ok ([0-9]*)/; |
fac76ed7 | 86 | if (/^ok (\d+)(\s*#.*)?$/ && $1 == $next) { |
8d063cd8 LW |
87 | $next = $next + 1; |
88 | } else { | |
89 | $ok = 0; | |
90 | } | |
91 | } | |
92 | } | |
93 | } | |
94 | $next = $next - 1; | |
95 | if ($ok && $next == $max) { | |
bcce72a7 | 96 | if ($max) { |
97 | print "ok\n"; | |
98 | $good = $good + 1; | |
99 | } else { | |
100 | print "skipping test on this platform\n"; | |
101 | $files -= 1; | |
102 | } | |
8d063cd8 LW |
103 | } else { |
104 | $next += 1; | |
3e6e8be7 | 105 | print "FAILED at test $next\n"; |
8d063cd8 LW |
106 | $bad = $bad + 1; |
107 | $_ = $test; | |
108 | if (/^base/) { | |
378cc40b | 109 | die "Failed a basic test--cannot continue.\n"; |
8d063cd8 LW |
110 | } |
111 | } | |
112 | } | |
113 | ||
114 | if ($bad == 0) { | |
115 | if ($ok) { | |
116 | print "All tests successful.\n"; | |
3e6e8be7 | 117 | # XXX add mention of 'perlbug -ok' ? |
8d063cd8 | 118 | } else { |
378cc40b | 119 | die "FAILED--no tests were run for some reason.\n"; |
8d063cd8 LW |
120 | } |
121 | } else { | |
79072805 | 122 | $pct = sprintf("%.2f", $good / $total * 100); |
8d063cd8 | 123 | if ($bad == 1) { |
f46c10df | 124 | warn "Failed 1 test script out of $total, $pct% okay.\n"; |
8d063cd8 | 125 | } else { |
f46c10df | 126 | warn "Failed $bad test scripts out of $total, $pct% okay.\n"; |
8d063cd8 | 127 | } |
f46c10df CS |
128 | warn <<'SHRDLU'; |
129 | ### Since not all tests were successful, you may want to run some | |
130 | ### of them individually and examine any diagnostic messages they | |
131 | ### produce. See the INSTALL document's section on "make test". | |
132 | SHRDLU | |
3e6e8be7 MB |
133 | warn <<'SHRDLU' if $good / $total > 0.8; |
134 | ### | |
135 | ### Since most tests were successful, you have a good chance to | |
136 | ### get information with better granularity by running | |
137 | ### ./perl harness | |
138 | ### in directory ./t. | |
139 | SHRDLU | |
8d063cd8 LW |
140 | } |
141 | ($user,$sys,$cuser,$csys) = times; | |
f46c10df | 142 | print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n", |
2b317908 | 143 | $user,$sys,$cuser,$csys,$files,$totmax); |
3e6e8be7 | 144 | exit ($bad != 0); |