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 | |
3e6e8be7 |
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 | |
3e6e8be7 |
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 | |
3e6e8be7 |
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 |
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 | |
6ee623d5 |
41 | %infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 ); |
42 | |
43 | _testprogs('perl', @ARGV); |
44 | _testprogs('compile', @ARGV) if (-e "../testcompile"); |
45 | |
46 | sub _testprogs |
47 | { |
48 | $type = shift @_; |
49 | @tests = @_; |
50 | |
51 | |
52 | print " |
53 | -------------------------------------------------------------------------------- |
54 | TESTING COMPILER |
55 | -------------------------------------------------------------------------------- |
56 | " if ($type eq 'compile'); |
57 | |
58 | $bad = 0; |
59 | $good = 0; |
60 | $total = @tests; |
61 | $files = 0; |
62 | $totmax = 0; |
63 | while ($test = shift @tests) { |
64 | |
65 | if ( $infinite{$test} && $type eq 'compile' ) { |
66 | print STDERR "$test creates infinite loop! Skipping.\n"; |
67 | next; |
68 | } |
fe14fcc3 |
69 | if ($test =~ /^$/) { |
378cc40b |
70 | next; |
71 | } |
fe14fcc3 |
72 | $te = $test; |
73 | chop($te); |
55497cff |
74 | print "$te" . '.' x (18 - length($te)); |
135863df |
75 | if ($sharpbang) { |
3e6e8be7 |
76 | -x $test || (print "isn't executable.\n"); |
6ee623d5 |
77 | |
78 | if ($type eq 'perl') |
79 | { open(RESULTS, "./$test |") || (print "can't run.\n"); } |
80 | else |
81 | { |
82 | open(RESULTS, "./perl -I../lib ../utils/perlcc ./$test -run -verbose dcf -log ../compilelog |") |
83 | || (print "can't compile.\n"); |
84 | } |
135863df |
85 | } else { |
3e6e8be7 |
86 | open(SCRIPT,"$test") || die "Can't run $test.\n"; |
87 | $_ = <SCRIPT>; |
88 | close(SCRIPT); |
135863df |
89 | if (/#!..perl(.*)/) { |
90 | $switch = $1; |
55497cff |
91 | if ($^O eq 'VMS') { |
92 | # Must protect uppercase switches with "" on command line |
93 | $switch =~ s/-([A-Z]\S*)/"-$1"/g; |
94 | } |
135863df |
95 | } else { |
96 | $switch = ''; |
97 | } |
6ee623d5 |
98 | |
99 | if ($type eq 'perl') |
100 | { |
101 | open(RESULTS,"./perl$switch $test |") || (print "can't run.\n"); |
102 | } |
103 | else |
104 | { |
105 | open(RESULTS, "./perl -I../lib ../utils/perlcc ./$test -run -verbose dcf -log ../compilelog |") |
106 | || (print "can't compile.\n"); |
107 | } |
135863df |
108 | } |
8d063cd8 |
109 | $ok = 0; |
378cc40b |
110 | $next = 0; |
3e6e8be7 |
111 | while (<RESULTS>) { |
8d063cd8 |
112 | if ($verbose) { |
113 | print $_; |
114 | } |
115 | unless (/^#/) { |
116 | if (/^1\.\.([0-9]+)/) { |
117 | $max = $1; |
2b317908 |
118 | $totmax += $max; |
119 | $files += 1; |
8d063cd8 |
120 | $next = 1; |
121 | $ok = 1; |
122 | } else { |
7e1cf235 |
123 | $next = $1, $ok = 0, last if /^not ok ([0-9]*)/; |
fac76ed7 |
124 | if (/^ok (\d+)(\s*#.*)?$/ && $1 == $next) { |
8d063cd8 |
125 | $next = $next + 1; |
126 | } else { |
127 | $ok = 0; |
128 | } |
129 | } |
130 | } |
131 | } |
132 | $next = $next - 1; |
133 | if ($ok && $next == $max) { |
bcce72a7 |
134 | if ($max) { |
135 | print "ok\n"; |
136 | $good = $good + 1; |
137 | } else { |
138 | print "skipping test on this platform\n"; |
139 | $files -= 1; |
140 | } |
8d063cd8 |
141 | } else { |
142 | $next += 1; |
3e6e8be7 |
143 | print "FAILED at test $next\n"; |
8d063cd8 |
144 | $bad = $bad + 1; |
145 | $_ = $test; |
146 | if (/^base/) { |
378cc40b |
147 | die "Failed a basic test--cannot continue.\n"; |
8d063cd8 |
148 | } |
149 | } |
150 | } |
151 | |
152 | if ($bad == 0) { |
153 | if ($ok) { |
154 | print "All tests successful.\n"; |
3e6e8be7 |
155 | # XXX add mention of 'perlbug -ok' ? |
8d063cd8 |
156 | } else { |
378cc40b |
157 | die "FAILED--no tests were run for some reason.\n"; |
8d063cd8 |
158 | } |
159 | } else { |
79072805 |
160 | $pct = sprintf("%.2f", $good / $total * 100); |
8d063cd8 |
161 | if ($bad == 1) { |
f46c10df |
162 | warn "Failed 1 test script out of $total, $pct% okay.\n"; |
8d063cd8 |
163 | } else { |
f46c10df |
164 | warn "Failed $bad test scripts out of $total, $pct% okay.\n"; |
8d063cd8 |
165 | } |
f46c10df |
166 | warn <<'SHRDLU'; |
167 | ### Since not all tests were successful, you may want to run some |
168 | ### of them individually and examine any diagnostic messages they |
169 | ### produce. See the INSTALL document's section on "make test". |
6ee623d5 |
170 | ### If you are testing the compiler, then ignore this message |
171 | ### and run |
172 | ### ./perl harness |
173 | ### in the directory ./t. |
f46c10df |
174 | SHRDLU |
3e6e8be7 |
175 | warn <<'SHRDLU' if $good / $total > 0.8; |
176 | ### |
177 | ### Since most tests were successful, you have a good chance to |
178 | ### get information with better granularity by running |
6ee623d5 |
179 | ### ./perl harness |
3e6e8be7 |
180 | ### in directory ./t. |
181 | SHRDLU |
8d063cd8 |
182 | } |
183 | ($user,$sys,$cuser,$csys) = times; |
f46c10df |
184 | print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n", |
2b317908 |
185 | $user,$sys,$cuser,$csys,$files,$totmax); |
6ee623d5 |
186 | } |
3e6e8be7 |
187 | exit ($bad != 0); |