Commit | Line | Data |
8d063cd8 |
1 | #!./perl |
2 | |
8d063cd8 |
3 | # This is written in a peculiar style, since we're trying to avoid |
1de9afcd |
4 | # most of the constructs we'll be testing for. (This comment is |
5 | # probably obsolete on the avoidance side, though still currrent |
6 | # on the peculiarity side.) |
8d063cd8 |
7 | |
a687059c |
8 | $| = 1; |
9 | |
80ed0dea |
10 | # for testing TEST only |
11 | #BEGIN { require '../lib/strict.pm'; strict->import() }; |
12 | #BEGIN { require '../lib/warnings.pm'; warnings->import() }; |
13 | |
60e23f2f |
14 | # Let tests know they're running in the perl core. Useful for modules |
15 | # which live dual lives on CPAN. |
16 | $ENV{PERL_CORE} = 1; |
104393a7 |
17 | delete $ENV{PERL5LIB}; |
60e23f2f |
18 | |
cc6ae9e5 |
19 | # remove empty elements due to insertion of empty symbols via "''p1'" syntax |
20 | @ARGV = grep($_,@ARGV) if $^O eq 'VMS'; |
551405c4 |
21 | our $show_elapsed_time = $ENV{HARNESS_TIMER} || 0; |
cc6ae9e5 |
22 | |
5d9a6404 |
23 | # Cheesy version of Getopt::Std. Maybe we should replace it with that. |
80ed0dea |
24 | { |
25 | my @argv = (); |
5d9a6404 |
26 | foreach my $idx (0..$#ARGV) { |
b326da91 |
27 | push( @argv, $ARGV[$idx] ), next unless $ARGV[$idx] =~ /^-(\S+)$/; |
7019aa11 |
28 | $::benchmark = 1 if $1 eq 'benchmark'; |
80ed0dea |
29 | $::core = 1 if $1 eq 'core'; |
30 | $::verbose = 1 if $1 eq 'v'; |
31 | $::torture = 1 if $1 eq 'torture'; |
32 | $::with_utf8 = 1 if $1 eq 'utf8'; |
33 | $::with_utf16 = 1 if $1 eq 'utf16'; |
80ed0dea |
34 | $::taintwarn = 1 if $1 eq 'taintwarn'; |
43651d81 |
35 | $ENV{PERL_CORE_MINITEST} = 1 if $1 eq 'minitest'; |
485988ae |
36 | if ($1 =~ /^deparse(,.+)?$/) { |
80ed0dea |
37 | $::deparse = 1; |
38 | $::deparse_opts = $1; |
485988ae |
39 | } |
5d9a6404 |
40 | } |
80ed0dea |
41 | @ARGV = @argv; |
8d063cd8 |
42 | } |
43 | |
378cc40b |
44 | chdir 't' if -f 't/TEST'; |
45 | |
3e6e8be7 |
46 | die "You need to run \"make test\" first to set things up.\n" |
196918b0 |
47 | unless -e 'perl' or -e 'perl.exe' or -e 'perl.pm'; |
4633a7c4 |
48 | |
7a315204 |
49 | if ($ENV{PERL_3LOG}) { # Tru64 third(1) tool, see perlhack |
09187cb1 |
50 | unless (-x 'perl.third') { |
51 | unless (-x '../perl.third') { |
52 | die "You need to run \"make perl.third first.\n"; |
53 | } |
54 | else { |
55 | print "Symlinking ../perl.third as perl.third...\n"; |
56 | die "Failed to symlink: $!\n" |
57 | unless symlink("../perl.third", "perl.third"); |
58 | die "Symlinked but no executable perl.third: $!\n" |
59 | unless -x 'perl.third'; |
60 | } |
61 | } |
62 | } |
63 | |
3fb91a5e |
64 | # check leakage for embedders |
65 | $ENV{PERL_DESTRUCT_LEVEL} = 2 unless exists $ENV{PERL_DESTRUCT_LEVEL}; |
66 | |
4633a7c4 |
67 | $ENV{EMXSHELL} = 'sh'; # For OS/2 |
748a9306 |
68 | |
24c841ba |
69 | # Roll your own File::Find! |
70 | use TestInit; |
71 | use File::Spec; |
28ffa55a |
72 | if ($show_elapsed_time) { require Time::HiRes } |
24c841ba |
73 | my $curdir = File::Spec->curdir; |
74 | my $updir = File::Spec->updir; |
75 | |
76 | sub _find_tests { |
77 | my($dir) = @_; |
93e325a7 |
78 | opendir DIR, $dir or die "Trouble opening $dir: $!"; |
a1886d87 |
79 | foreach my $f (sort { $a cmp $b } readdir DIR) { |
f458b6e8 |
80 | next if $f eq $curdir or $f eq $updir or |
0b834283 |
81 | $f =~ /^(?:CVS|RCS|SCCS|\.svn)$/; |
24c841ba |
82 | |
f458b6e8 |
83 | my $fullpath = File::Spec->catfile($dir, $f); |
24c841ba |
84 | |
f458b6e8 |
85 | _find_tests($fullpath) if -d $fullpath; |
86 | $fullpath = VMS::Filespec::unixify($fullpath) if $^O eq 'VMS'; |
87 | push @ARGV, $fullpath if $f =~ /\.t$/; |
24c841ba |
88 | } |
89 | } |
90 | |
cc6ae9e5 |
91 | sub _quote_args { |
92 | my ($args) = @_; |
93 | my $argstring = ''; |
94 | |
95 | foreach (split(/\s+/,$args)) { |
96 | # In VMS protect with doublequotes because otherwise |
97 | # DCL will lowercase -- unless already doublequoted. |
98 | $_ = q(").$_.q(") if ($^O eq 'VMS') && !/^\"/ && length($_) > 0; |
99 | $argstring .= ' ' . $_; |
100 | } |
101 | return $argstring; |
102 | } |
103 | |
6234cb77 |
104 | sub _populate_hash { |
105 | return map {$_, 1} split /\s+/, $_[0]; |
106 | } |
107 | |
24c841ba |
108 | unless (@ARGV) { |
e1a479c5 |
109 | foreach my $dir (qw(base comp cmd run io op uni mro)) { |
f458b6e8 |
110 | _find_tests($dir); |
24c841ba |
111 | } |
80ed0dea |
112 | _find_tests("lib") unless $::core; |
6234cb77 |
113 | # Config.pm may be broken for make minitest. And this is only a refinement |
114 | # for skipping tests on non-default builds, so it is allowed to fail. |
115 | # What we want to to is make a list of extensions which we did not build. |
116 | my $configsh = File::Spec->catfile($updir, "config.sh"); |
117 | my %skip; |
118 | if (-f $configsh) { |
119 | my (%extensions, %known_extensions); |
120 | open FH, $configsh or die "Can't open $configsh: $!"; |
121 | while (<FH>) { |
122 | if (/^extensions=['"](.*)['"]$/) { |
123 | # Deliberate string interpolation to avoid triggering possible |
124 | # $1 resetting bugs. |
125 | %extensions = _populate_hash ("$1"); |
126 | } |
127 | elsif (/^known_extensions=['"](.*)['"]$/) { |
128 | %known_extensions = _populate_hash ($1); |
129 | } |
130 | } |
131 | if (%extensions) { |
132 | if (%known_extensions) { |
133 | foreach (keys %known_extensions) { |
134 | $skip{$_}++ unless $extensions{$_}; |
135 | } |
136 | } else { |
137 | warn "No known_extensions line found in $configsh"; |
138 | } |
139 | } else { |
140 | warn "No extensions line found in $configsh"; |
141 | } |
142 | } |
cc6ae9e5 |
143 | my $mani = File::Spec->catfile($updir, "MANIFEST"); |
7a315204 |
144 | if (open(MANI, $mani)) { |
f458b6e8 |
145 | while (<MANI>) { # similar code in t/harness |
e469beda |
146 | if (m!^(ext/(\S+)/+(?:[^/\s]+\.t|test\.pl)|lib/\S+?(?:\.t|test\.pl))\s!) { |
80ed0dea |
147 | my $t = $1; |
148 | my $extension = $2; |
149 | if (!$::core || $t =~ m!^lib/[a-z]!) |
5a6e071d |
150 | { |
6234cb77 |
151 | if (defined $extension) { |
152 | $extension =~ s!/t$!!; |
153 | # XXX Do I want to warn that I'm skipping these? |
154 | next if $skip{$extension}; |
142f6a0d |
155 | my $flat_extension = $extension; |
6ebb0601 |
156 | $flat_extension =~ s!-!/!g; |
157 | next if $skip{$flat_extension}; # Foo/Bar may live in Foo-Bar |
6234cb77 |
158 | } |
80ed0dea |
159 | my $path = File::Spec->catfile($updir, $t); |
73ddec28 |
160 | push @ARGV, $path; |
80ed0dea |
161 | $::path_to_name{$path} = $t; |
5a6e071d |
162 | } |
7a315204 |
163 | } |
164 | } |
35d88760 |
165 | close MANI; |
7a315204 |
166 | } else { |
f458b6e8 |
167 | warn "$0: cannot open $mani: $!\n"; |
7a315204 |
168 | } |
80ed0dea |
169 | unless ($::core) { |
d44161bf |
170 | _find_tests('pod'); |
e018f8be |
171 | _find_tests('x2p'); |
6b77813c |
172 | _find_tests('porting'); |
80ed0dea |
173 | _find_tests('japh') if $::torture; |
7019aa11 |
174 | _find_tests('t/benchmark') if $::benchmark or $ENV{PERL_BENCHMARK}; |
e018f8be |
175 | } |
8d063cd8 |
176 | } |
177 | |
80ed0dea |
178 | if ($::deparse) { |
f193aa2f |
179 | _testprogs('deparse', '', @ARGV); |
180 | } |
80ed0dea |
181 | elsif ($::with_utf16) { |
1de9afcd |
182 | for my $e (0, 1) { |
183 | for my $b (0, 1) { |
184 | print STDERR "# ENDIAN $e BOM $b\n"; |
185 | my @UARGV; |
186 | for my $a (@ARGV) { |
187 | my $u = $a . "." . ($e ? "l" : "b") . "e" . ($b ? "b" : ""); |
188 | my $f = $e ? "v" : "n"; |
189 | push @UARGV, $u; |
190 | unlink($u); |
191 | if (open(A, $a)) { |
192 | if (open(U, ">$u")) { |
90f6ca78 |
193 | print U pack("$f", 0xFEFF) if $b; |
1de9afcd |
194 | while (<A>) { |
195 | print U pack("$f*", unpack("C*", $_)); |
196 | } |
80ed0dea |
197 | close(U); |
1de9afcd |
198 | } |
80ed0dea |
199 | close(A); |
1de9afcd |
200 | } |
201 | } |
202 | _testprogs('perl', '', @UARGV); |
203 | unlink(@UARGV); |
204 | } |
205 | } |
206 | } |
f193aa2f |
207 | else { |
f193aa2f |
208 | _testprogs('perl', '', @ARGV); |
485988ae |
209 | } |
6ee623d5 |
210 | |
bb365837 |
211 | sub _testprogs { |
80ed0dea |
212 | my ($type, $args, @tests) = @_; |
6ee623d5 |
213 | |
485988ae |
214 | print <<'EOT' if ($type eq 'deparse'); |
7a315204 |
215 | ------------------------------------------------------------------------------ |
485988ae |
216 | TESTING DEPARSER |
7a315204 |
217 | ------------------------------------------------------------------------------ |
485988ae |
218 | EOT |
219 | |
80ed0dea |
220 | $::bad_files = 0; |
73ddec28 |
221 | |
cc6ae9e5 |
222 | foreach my $t (@tests) { |
80ed0dea |
223 | unless (exists $::path_to_name{$t}) { |
f458b6e8 |
224 | my $tname = File::Spec->catfile('t',$t); |
225 | $tname = VMS::Filespec::unixify($tname) if $^O eq 'VMS'; |
226 | $::path_to_name{$t} = $tname; |
cc6ae9e5 |
227 | } |
73ddec28 |
228 | } |
908801fe |
229 | my $maxlen = 0; |
80ed0dea |
230 | foreach (@::path_to_name{@tests}) { |
73ddec28 |
231 | s/\.\w+\z/./; |
232 | my $len = length ; |
233 | $maxlen = $len if $len > $maxlen; |
088b5126 |
234 | } |
908801fe |
235 | # + 3 : we want three dots between the test name and the "ok" |
80ed0dea |
236 | my $dotdotdot = $maxlen + 3 ; |
7a834142 |
237 | my $valgrind = 0; |
da51b73c |
238 | my $valgrind_log = 'current.valgrind'; |
80ed0dea |
239 | my $total_files = @tests; |
240 | my $good_files = 0; |
241 | my $tested_files = 0; |
242 | my $totmax = 0; |
ade55ef4 |
243 | my %failed_tests; |
80ed0dea |
244 | |
551405c4 |
245 | while (my $test = shift @tests) { |
28ffa55a |
246 | my $test_start_time = $show_elapsed_time ? Time::HiRes::time() : 0; |
bb365837 |
247 | |
bb365837 |
248 | if ($test =~ /^$/) { |
249 | next; |
6ee623d5 |
250 | } |
485988ae |
251 | if ($type eq 'deparse') { |
252 | if ($test eq "comp/redef.t") { |
253 | # Redefinition happens at compile time |
254 | next; |
255 | } |
7a834142 |
256 | elsif ($test =~ m{lib/Switch/t/}) { |
485988ae |
257 | # B::Deparse doesn't support source filtering |
258 | next; |
259 | } |
260 | } |
80ed0dea |
261 | my $te = $::path_to_name{$test} . '.' |
262 | x ($dotdotdot - length($::path_to_name{$test})); |
cc6ae9e5 |
263 | |
264 | if ($^O ne 'VMS') { # defer printing on VMS due to piping bug |
265 | print $te; |
266 | $te = ''; |
267 | } |
bb365837 |
268 | |
80ed0dea |
269 | # XXX DAPM %OVER not defined anywhere |
270 | # $test = $OVER{$test} if exists $OVER{$test}; |
7a315204 |
271 | |
551405c4 |
272 | open(SCRIPT,"<",$test) or die "Can't run $test.\n"; |
f458b6e8 |
273 | $_ = <SCRIPT>; |
274 | close(SCRIPT) unless ($type eq 'deparse'); |
80ed0dea |
275 | if ($::with_utf16) { |
90f6ca78 |
276 | $_ =~ tr/\0//d; |
277 | } |
80ed0dea |
278 | my $switch; |
f458b6e8 |
279 | if (/#!.*\bperl.*\s-\w*([tT])/) { |
280 | $switch = qq{"-$1"}; |
281 | } |
282 | else { |
80ed0dea |
283 | if ($::taintwarn) { |
b26492ee |
284 | # not all tests are expected to pass with this option |
285 | $switch = '"-t"'; |
286 | } |
287 | else { |
288 | $switch = ''; |
289 | } |
f458b6e8 |
290 | } |
6ee623d5 |
291 | |
485988ae |
292 | my $file_opts = ""; |
293 | if ($type eq 'deparse') { |
294 | # Look for #line directives which change the filename |
295 | while (<SCRIPT>) { |
296 | $file_opts .= ",-f$3$4" |
297 | if /^#\s*line\s+(\d+)\s+((\w+)|"([^"]+)")/; |
298 | } |
299 | close(SCRIPT); |
300 | } |
7a315204 |
301 | |
80ed0dea |
302 | my $utf8 = $::with_utf8 ? '-I../lib -Mutf8' : ''; |
4343e7c3 |
303 | my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC |
485988ae |
304 | if ($type eq 'deparse') { |
80ed0dea |
305 | my $deparse_cmd = |
127212b2 |
306 | "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,-sv1.,". |
80ed0dea |
307 | "-l$::deparse_opts$file_opts ". |
7a315204 |
308 | "$test > $test.dp ". |
309 | "&& ./perl $testswitch $switch -I../lib $test.dp |"; |
80ed0dea |
310 | open(RESULTS, $deparse_cmd) |
311 | or print "can't deparse '$deparse_cmd': $!.\n"; |
485988ae |
312 | } |
313 | elsif ($type eq 'perl') { |
a7da9a42 |
314 | my $perl = $ENV{PERL} || './perl'; |
da51b73c |
315 | my $redir = $^O eq 'VMS' ? '2>&1' : ''; |
7a834142 |
316 | if ($ENV{PERL_VALGRIND}) { |
4f9287d3 |
317 | my $valgrind = $ENV{VALGRIND} // 'valgrind'; |
3068023c |
318 | my $vg_opts = $ENV{VG_OPTS} |
319 | // "--suppressions=perl.supp --leak-check=yes " |
320 | . "--leak-resolution=high --show-reachable=yes " |
321 | . "--num-callers=50"; |
322 | $perl = "$valgrind --log-fd=3 $vg_opts $perl"; |
da51b73c |
323 | $redir = "3>$valgrind_log"; |
7a834142 |
324 | } |
80ed0dea |
325 | my $run = "$perl" . _quote_args("$testswitch $switch $utf8") |
326 | . " $test $redir|"; |
be24517c |
327 | open(RESULTS,$run) or print "can't run '$run': $!.\n"; |
d638aca2 |
328 | } |
9c8d215a |
329 | # Our environment may force us to use UTF-8, but we can't be sure that |
330 | # anything we're reading from will be generating (well formed) UTF-8 |
331 | # This may not be the best way - possibly we should unset ${^OPEN} up |
332 | # top? |
333 | binmode RESULTS; |
d638aca2 |
334 | |
f458b6e8 |
335 | my $failure; |
336 | my $next = 0; |
337 | my $seen_leader = 0; |
338 | my $seen_ok = 0; |
20f82676 |
339 | my $trailing_leader = 0; |
80ed0dea |
340 | my $max; |
43fe0836 |
341 | my %todo; |
bb365837 |
342 | while (<RESULTS>) { |
cc6ae9e5 |
343 | next if /^\s*$/; # skip blank lines |
615b7a35 |
344 | if (/^1..$/ && ($^O eq 'VMS')) { |
345 | # VMS pipe bug inserts blank lines. |
346 | my $l2 = <RESULTS>; |
347 | if ($l2 =~ /^\s*$/) { |
348 | $l2 = <RESULTS>; |
349 | } |
350 | $_ = '1..' . $l2; |
351 | } |
80ed0dea |
352 | if ($::verbose) { |
bb365837 |
353 | print $_; |
354 | } |
21c74f43 |
355 | unless (/^\#/) { |
20f82676 |
356 | if ($trailing_leader) { |
357 | # shouldn't be anything following a postfix 1..n |
a5890677 |
358 | $failure = 'FAILED--extra output after trailing 1..n'; |
20f82676 |
359 | last; |
360 | } |
809908f7 |
361 | if (/^1\.\.([0-9]+)( todo ([\d ]+))?/) { |
20f82676 |
362 | if ($seen_leader) { |
a5890677 |
363 | $failure = 'FAILED--seen duplicate leader'; |
20f82676 |
364 | last; |
365 | } |
bb365837 |
366 | $max = $1; |
f458b6e8 |
367 | %todo = map { $_ => 1 } split / /, $3 if $3; |
bb365837 |
368 | $totmax += $max; |
80ed0dea |
369 | $tested_files++; |
f458b6e8 |
370 | if ($seen_ok) { |
20f82676 |
371 | # 1..n appears at end of file |
372 | $trailing_leader = 1; |
373 | if ($next != $max) { |
a5890677 |
374 | $failure = "FAILED--expected $max tests, saw $next"; |
20f82676 |
375 | last; |
376 | } |
377 | } |
378 | else { |
379 | $next = 0; |
380 | } |
f458b6e8 |
381 | $seen_leader = 1; |
bb365837 |
382 | } |
383 | else { |
f458b6e8 |
384 | if (/^(not )?ok(?: (\d+))?[^\#]*(\s*\#.*)?/) { |
21c74f43 |
385 | unless ($seen_leader) { |
386 | unless ($seen_ok) { |
20f82676 |
387 | $next = 0; |
21c74f43 |
388 | } |
37ce32a7 |
389 | } |
21c74f43 |
390 | $seen_ok = 1; |
20f82676 |
391 | $next++; |
f458b6e8 |
392 | my($not, $num, $extra, $istodo) = ($1, $2, $3, 0); |
393 | $num = $next unless $num; |
394 | |
395 | if ($num == $next) { |
396 | |
eac7c728 |
397 | # SKIP is essentially the same as TODO for t/TEST |
398 | # this still conforms to TAP: |
3722f0dc |
399 | # http://search.cpan.org/dist/TAP/TAP.pod |
eac7c728 |
400 | $extra and $istodo = $extra =~ /#\s*(?:TODO|SKIP)\b/; |
21c74f43 |
401 | $istodo = 1 if $todo{$num}; |
402 | |
403 | if( $not && !$istodo ) { |
20f82676 |
404 | $failure = "FAILED at test $num"; |
21c74f43 |
405 | last; |
406 | } |
20f82676 |
407 | } |
408 | else { |
f458b6e8 |
409 | $failure ="FAILED--expected test $next, saw test $num"; |
20f82676 |
410 | last; |
37ce32a7 |
411 | } |
f458b6e8 |
412 | } |
413 | elsif (/^Bail out!\s*(.*)/i) { # magic words |
414 | die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n"); |
bb365837 |
415 | } |
416 | else { |
dbf51d07 |
417 | # module tests are allowed extra output, |
418 | # because Test::Harness allows it |
419 | next if $test =~ /^\W*(ext|lib)\b/; |
a5890677 |
420 | $failure = "FAILED--unexpected output at test $next"; |
20f82676 |
421 | last; |
bb365837 |
422 | } |
8d063cd8 |
423 | } |
424 | } |
425 | } |
bb365837 |
426 | close RESULTS; |
20f82676 |
427 | |
428 | if (not defined $failure) { |
a5890677 |
429 | $failure = 'FAILED--no leader found' unless $seen_leader; |
20f82676 |
430 | } |
431 | |
7a834142 |
432 | if ($ENV{PERL_VALGRIND}) { |
da51b73c |
433 | my @valgrind; |
434 | if (-e $valgrind_log) { |
435 | if (open(V, $valgrind_log)) { |
436 | @valgrind = <V>; |
437 | close V; |
438 | } else { |
439 | warn "$0: Failed to open '$valgrind_log': $!\n"; |
440 | } |
441 | } |
3068023c |
442 | if ($ENV{VG_OPTS} =~ /cachegrind/) { |
443 | if (rename $valgrind_log, "$test.valgrind") { |
444 | $valgrind++; |
445 | } else { |
446 | warn "$0: Failed to create '$test.valgrind': $!\n"; |
447 | } |
448 | } |
449 | elsif (@valgrind) { |
d44161bf |
450 | my $leaks = 0; |
451 | my $errors = 0; |
7a834142 |
452 | for my $i (0..$#valgrind) { |
453 | local $_ = $valgrind[$i]; |
d44161bf |
454 | if (/^==\d+== ERROR SUMMARY: (\d+) errors? /) { |
455 | $errors += $1; # there may be multiple error summaries |
456 | } elsif (/^==\d+== LEAK SUMMARY:/) { |
457 | for my $off (1 .. 4) { |
458 | if ($valgrind[$i+$off] =~ |
459 | /(?:lost|reachable):\s+\d+ bytes in (\d+) blocks/) { |
460 | $leaks += $1; |
461 | } |
462 | } |
7a834142 |
463 | } |
464 | } |
d44161bf |
465 | if ($errors or $leaks) { |
da51b73c |
466 | if (rename $valgrind_log, "$test.valgrind") { |
d44161bf |
467 | $valgrind++; |
468 | } else { |
469 | warn "$0: Failed to create '$test.valgrind': $!\n"; |
7a834142 |
470 | } |
471 | } |
472 | } else { |
473 | warn "No valgrind output?\n"; |
474 | } |
da51b73c |
475 | if (-e $valgrind_log) { |
476 | unlink $valgrind_log |
477 | or warn "$0: Failed to unlink '$valgrind_log': $!\n"; |
478 | } |
7a834142 |
479 | } |
485988ae |
480 | if ($type eq 'deparse') { |
481 | unlink "./$test.dp"; |
482 | } |
211f317f |
483 | if ($ENV{PERL_3LOG}) { |
484 | my $tpp = $test; |
3716a21d |
485 | $tpp =~ s:^\.\./::; |
9c54ecba |
486 | $tpp =~ s:/:_:g; |
3716a21d |
487 | $tpp =~ s:\.t$:.3log:; |
488 | rename("perl.3log", $tpp) || |
489 | die "rename: perl3.log to $tpp: $!\n"; |
211f317f |
490 | } |
20f82676 |
491 | if (not defined $failure and $next != $max) { |
a5890677 |
492 | $failure="FAILED--expected $max tests, saw $next"; |
20f82676 |
493 | } |
494 | |
343bc60d |
495 | if( !defined $failure # don't mask a test failure |
496 | and $? ) |
497 | { |
498 | $failure = "FAILED--non-zero wait status: $?"; |
499 | } |
500 | |
20f82676 |
501 | if (defined $failure) { |
502 | print "${te}$failure\n"; |
503 | $::bad_files++; |
ade55ef4 |
504 | if ($test =~ /^base/) { |
505 | die "Failed a basic test ($test) -- cannot continue.\n"; |
20f82676 |
506 | } |
ade55ef4 |
507 | ++$failed_tests{$test}; |
20f82676 |
508 | } |
509 | else { |
bb365837 |
510 | if ($max) { |
551405c4 |
511 | my $elapsed; |
512 | if ( $show_elapsed_time ) { |
513 | $elapsed = sprintf( " %8.0f ms", (Time::HiRes::time() - $test_start_time) * 1000 ); |
514 | } |
515 | else { |
516 | $elapsed = ""; |
517 | } |
518 | print "${te}ok$elapsed\n"; |
80ed0dea |
519 | $good_files++; |
bb365837 |
520 | } |
521 | else { |
6b202754 |
522 | print "${te}skipped\n"; |
80ed0dea |
523 | $tested_files -= 1; |
bb365837 |
524 | } |
bcce72a7 |
525 | } |
551405c4 |
526 | } # while tests |
8d063cd8 |
527 | |
80ed0dea |
528 | if ($::bad_files == 0) { |
20f82676 |
529 | if ($good_files) { |
bb365837 |
530 | print "All tests successful.\n"; |
531 | # XXX add mention of 'perlbug -ok' ? |
532 | } |
533 | else { |
534 | die "FAILED--no tests were run for some reason.\n"; |
535 | } |
8d063cd8 |
536 | } |
bb365837 |
537 | else { |
80ed0dea |
538 | my $pct = $tested_files ? sprintf("%.2f", ($tested_files - $::bad_files) / $tested_files * 100) : "0.00"; |
ade55ef4 |
539 | my $s = $::bad_files == 1 ? "" : "s"; |
540 | warn "Failed $::bad_files test$s out of $tested_files, $pct% okay.\n"; |
541 | for my $test ( sort keys %failed_tests ) { |
542 | print "\t$test\n"; |
bb365837 |
543 | } |
4e4732c1 |
544 | warn <<'SHRDLU_1'; |
f7d228c6 |
545 | ### Since not all tests were successful, you may want to run some of |
546 | ### them individually and examine any diagnostic messages they produce. |
547 | ### See the INSTALL document's section on "make test". |
4e4732c1 |
548 | SHRDLU_1 |
80ed0dea |
549 | warn <<'SHRDLU_2' if $good_files / $total_files > 0.8; |
f7d228c6 |
550 | ### You have a good chance to get more information by running |
551 | ### ./perl harness |
552 | ### in the 't' directory since most (>=80%) of the tests succeeded. |
4e4732c1 |
553 | SHRDLU_2 |
f458b6e8 |
554 | if (eval {require Config; import Config; 1}) { |
80ed0dea |
555 | if ($::Config{usedl} && (my $p = $::Config{ldlibpthname})) { |
4e4732c1 |
556 | warn <<SHRDLU_3; |
f7d228c6 |
557 | ### You may have to set your dynamic library search path, |
558 | ### $p, to point to the build directory: |
4e4732c1 |
559 | SHRDLU_3 |
f458b6e8 |
560 | if (exists $ENV{$p} && $ENV{$p} ne '') { |
4e4732c1 |
561 | warn <<SHRDLU_4a; |
f7d228c6 |
562 | ### setenv $p `pwd`:\$$p; cd t; ./perl harness |
563 | ### $p=`pwd`:\$$p; export $p; cd t; ./perl harness |
564 | ### export $p=`pwd`:\$$p; cd t; ./perl harness |
4e4732c1 |
565 | SHRDLU_4a |
f458b6e8 |
566 | } else { |
4e4732c1 |
567 | warn <<SHRDLU_4b; |
f7d228c6 |
568 | ### setenv $p `pwd`; cd t; ./perl harness |
569 | ### $p=`pwd`; export $p; cd t; ./perl harness |
570 | ### export $p=`pwd`; cd t; ./perl harness |
4e4732c1 |
571 | SHRDLU_4b |
f458b6e8 |
572 | } |
4e4732c1 |
573 | warn <<SHRDLU_5; |
f7d228c6 |
574 | ### for csh-style shells, like tcsh; or for traditional/modern |
575 | ### Bourne-style shells, like bash, ksh, and zsh, respectively. |
4e4732c1 |
576 | SHRDLU_5 |
f458b6e8 |
577 | } |
afd33fa9 |
578 | } |
bb365837 |
579 | } |
80ed0dea |
580 | my ($user,$sys,$cuser,$csys) = times; |
f47304e9 |
581 | print sprintf("u=%.2f s=%.2f cu=%.2f cs=%.2f scripts=%d tests=%d\n", |
80ed0dea |
582 | $user,$sys,$cuser,$csys,$tested_files,$totmax); |
7a834142 |
583 | if ($ENV{PERL_VALGRIND}) { |
584 | my $s = $valgrind == 1 ? '' : 's'; |
585 | print "$valgrind valgrind report$s created.\n", ; |
586 | } |
6ee623d5 |
587 | } |
80ed0dea |
588 | exit ($::bad_files != 0); |
ade55ef4 |
589 | |
590 | # ex: set ts=8 sts=4 sw=4 noet: |