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