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