This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
strictify t/TEST
[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;
262 my $ok;
263
264 my $test;
bb365837
GS
265 while ($test = shift @tests) {
266
80ed0dea 267 if ( $::infinite{$test} && $type eq 'compile' ) {
595ae481 268 print STDERR "$test creates infinite loop! Skipping.\n";
bb365837 269 next;
6ee623d5 270 }
bb365837
GS
271 if ($test =~ /^$/) {
272 next;
6ee623d5 273 }
485988ae
RH
274 if ($type eq 'deparse') {
275 if ($test eq "comp/redef.t") {
276 # Redefinition happens at compile time
277 next;
278 }
7a834142 279 elsif ($test =~ m{lib/Switch/t/}) {
485988ae
RH
280 # B::Deparse doesn't support source filtering
281 next;
282 }
283 }
80ed0dea
DM
284 my $te = $::path_to_name{$test} . '.'
285 x ($dotdotdot - length($::path_to_name{$test}));
cc6ae9e5
CB
286
287 if ($^O ne 'VMS') { # defer printing on VMS due to piping bug
288 print $te;
289 $te = '';
290 }
bb365837 291
80ed0dea
DM
292 # XXX DAPM %OVER not defined anywhere
293 # $test = $OVER{$test} if exists $OVER{$test};
7a315204 294
2f6bec1d
MS
295 open(SCRIPT,"<$test") or die "Can't run $test.\n";
296 $_ = <SCRIPT>;
297 close(SCRIPT) unless ($type eq 'deparse');
80ed0dea 298 if ($::with_utf16) {
90f6ca78
RGS
299 $_ =~ tr/\0//d;
300 }
80ed0dea 301 my $switch;
5dc83c40 302 if (/#!.*\bperl.*\s-\w*([tT])/) {
6537fe72 303 $switch = qq{"-$1"};
2f6bec1d
MS
304 }
305 else {
80ed0dea 306 if ($::taintwarn) {
b26492ee
RGS
307 # not all tests are expected to pass with this option
308 $switch = '"-t"';
309 }
310 else {
311 $switch = '';
312 }
2f6bec1d 313 }
6ee623d5 314
b326da91 315 my $test_executable; # for 'compile' tests
485988ae
RH
316 my $file_opts = "";
317 if ($type eq 'deparse') {
318 # Look for #line directives which change the filename
319 while (<SCRIPT>) {
320 $file_opts .= ",-f$3$4"
321 if /^#\s*line\s+(\d+)\s+((\w+)|"([^"]+)")/;
322 }
323 close(SCRIPT);
324 }
7a315204 325
80ed0dea 326 my $utf8 = $::with_utf8 ? '-I../lib -Mutf8' : '';
4343e7c3 327 my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC
485988ae 328 if ($type eq 'deparse') {
80ed0dea 329 my $deparse_cmd =
127212b2 330 "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,-sv1.,".
80ed0dea 331 "-l$::deparse_opts$file_opts ".
7a315204
JH
332 "$test > $test.dp ".
333 "&& ./perl $testswitch $switch -I../lib $test.dp |";
80ed0dea
DM
334 open(RESULTS, $deparse_cmd)
335 or print "can't deparse '$deparse_cmd': $!.\n";
485988ae 336 }
1df34986 337 elsif ($type eq 'bytecompile') {
c7e45529
AE
338 my ($pwd, $null);
339 if( $^O eq 'MSWin32') {
340 $pwd = `cd`;
341 $null = 'nul';
342 } else {
343 $pwd = `pwd`;
344 $null = '/dev/null';
345 }
346 chomp $pwd;
347 my $perl = $ENV{PERL} || "$pwd/perl";
348 my $bswitch = "-MO=Bytecode,-H,-TI,-s$pwd/$test,";
566ece03 349 $bswitch .= "-TF$test.plc,"
1df34986
AE
350 if $test =~ m(chdir|pod/|CGI/t/carp|lib/DB);
351 $bswitch .= "-k,"
352 if $test =~ m(deparse|terse|ext/Storable/t/code);
1df34986
AE
353 $bswitch .= "-b,"
354 if $test =~ m(op/getpid);
80ed0dea 355 my $bytecompile_cmd =
1df34986 356 "$perl $testswitch $switch -I../lib $bswitch".
c7e45529 357 "-o$test.plc $test 2>$null &&".
1de9afcd 358 "$perl $testswitch $switch -I../lib $utf8 $test.plc |";
80ed0dea
DM
359 open(RESULTS,$bytecompile_cmd)
360 or print "can't byte-compile '$bytecompile_cmd': $!.\n";
1df34986 361 }
485988ae 362 elsif ($type eq 'perl') {
a7da9a42 363 my $perl = $ENV{PERL} || './perl';
da51b73c 364 my $redir = $^O eq 'VMS' ? '2>&1' : '';
7a834142 365 if ($ENV{PERL_VALGRIND}) {
d44161bf
MHM
366 $perl = "valgrind --suppressions=perl.supp --leak-check=yes "
367 . "--leak-resolution=high --show-reachable=yes "
da51b73c
MHM
368 . "--num-callers=50 --logfile-fd=3 $perl";
369 $redir = "3>$valgrind_log";
7a834142 370 }
80ed0dea
DM
371 my $run = "$perl" . _quote_args("$testswitch $switch $utf8")
372 . " $test $redir|";
be24517c 373 open(RESULTS,$run) or print "can't run '$run': $!.\n";
d638aca2
GS
374 }
375 else {
80ed0dea 376 my $compile_cmd;
b326da91 377 my $pl2c = "$testswitch -I../lib ../utils/perlcc --testsuite " .
9d2bbe64
MB
378 # -O9 for good measure, -fcog is broken ATM
379 "$switch -Wb=-O9,-fno-cog -L .. " .
1de9afcd 380 "-I \".. ../lib/CORE\" $args $utf8 $test -o ";
b326da91
MB
381
382 if( $^O eq 'MSWin32' ) {
383 $test_executable = "$test.exe";
384 # hopefully unused name...
385 open HACK, "> xweghyz.pl";
386 print HACK <<EOT;
387#!./perl
388
389open HACK, '.\\perl $pl2c $test_executable |';
390# cl.exe prints the name of the .c file on stdout (\%^\$^#)
6d73d07f 391while(<HACK>) {m/^\\w+\\.[cC]\$/ && next;print}
b326da91
MB
392open HACK, '$test_executable |';
393while(<HACK>) {print}
394EOT
395 close HACK;
80ed0dea 396 $compile_cmd = 'xweghyz.pl |';
b326da91
MB
397 }
398 else {
399 $test_executable = "$test.plc";
80ed0dea
DM
400 $compile_cmd
401 = "./perl $pl2c $test_executable && $test_executable |";
b326da91
MB
402 }
403 unlink $test_executable if -f $test_executable;
80ed0dea
DM
404 open(RESULTS, $compile_cmd)
405 or print "can't compile '$compile_cmd': $!.\n";
6ee623d5 406 }
d638aca2 407
b326da91 408 $ok = 0;
80ed0dea 409 my $next = 0;
21c74f43
A
410 my $seen_leader = 0;
411 my $seen_ok = 0;
80ed0dea 412 my $max;
bb365837 413 while (<RESULTS>) {
cc6ae9e5 414 next if /^\s*$/; # skip blank lines
80ed0dea 415 if ($::verbose) {
bb365837
GS
416 print $_;
417 }
21c74f43 418 unless (/^\#/) {
80ed0dea 419 my %todo;
809908f7 420 if (/^1\.\.([0-9]+)( todo ([\d ]+))?/) {
bb365837 421 $max = $1;
809908f7 422 %todo = map { $_ => 1 } split / /, $3 if $3;
bb365837 423 $totmax += $max;
80ed0dea 424 $tested_files++;
21c74f43
A
425 unless ($seen_ok) {
426 $next = 1;
427 $ok = 1;
428 }
429 $seen_leader = 1;
bb365837
GS
430 }
431 else {
21c74f43
A
432 if (/^(not )?ok (\d+)[^\#]*(\s*\#.*)?/) {
433 unless ($seen_leader) {
434 unless ($seen_ok) {
435 $next = 1;
436 $ok = 1;
437 }
37ce32a7 438 }
21c74f43
A
439 $seen_ok = 1;
440 if ($2 == $next) {
eac7c728
MB
441 my($not, $num, $extra, $istodo) = ($1, $2, $3, 0);
442 # SKIP is essentially the same as TODO for t/TEST
443 # this still conforms to TAP:
444 # http://search.cpan.org/dist/Test-Harness/lib/Test/Harness/TAP.pod
445 $extra and $istodo = $extra =~ /#\s*(?:TODO|SKIP)\b/;
21c74f43
A
446 $istodo = 1 if $todo{$num};
447
448 if( $not && !$istodo ) {
449 $ok = 0;
450 $next = $num;
451 last;
452 }
453 else {
454 $next = $next + 1;
455 }
37ce32a7 456 }
d667a7e6
A
457 }
458 elsif (/^Bail out!\s*(.*)/i) { # magic words
459 die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
bb365837
GS
460 }
461 else {
462 $ok = 0;
463 }
8d063cd8
LW
464 }
465 }
466 }
bb365837 467 close RESULTS;
7a834142 468 if ($ENV{PERL_VALGRIND}) {
da51b73c
MHM
469 my @valgrind;
470 if (-e $valgrind_log) {
471 if (open(V, $valgrind_log)) {
472 @valgrind = <V>;
473 close V;
474 } else {
475 warn "$0: Failed to open '$valgrind_log': $!\n";
476 }
477 }
7a834142 478 if (@valgrind) {
d44161bf
MHM
479 my $leaks = 0;
480 my $errors = 0;
7a834142
JH
481 for my $i (0..$#valgrind) {
482 local $_ = $valgrind[$i];
d44161bf
MHM
483 if (/^==\d+== ERROR SUMMARY: (\d+) errors? /) {
484 $errors += $1; # there may be multiple error summaries
485 } elsif (/^==\d+== LEAK SUMMARY:/) {
486 for my $off (1 .. 4) {
487 if ($valgrind[$i+$off] =~
488 /(?:lost|reachable):\s+\d+ bytes in (\d+) blocks/) {
489 $leaks += $1;
490 }
491 }
7a834142
JH
492 }
493 }
d44161bf 494 if ($errors or $leaks) {
da51b73c 495 if (rename $valgrind_log, "$test.valgrind") {
d44161bf
MHM
496 $valgrind++;
497 } else {
498 warn "$0: Failed to create '$test.valgrind': $!\n";
7a834142
JH
499 }
500 }
501 } else {
502 warn "No valgrind output?\n";
503 }
da51b73c
MHM
504 if (-e $valgrind_log) {
505 unlink $valgrind_log
506 or warn "$0: Failed to unlink '$valgrind_log': $!\n";
507 }
7a834142 508 }
485988ae
RH
509 if ($type eq 'deparse') {
510 unlink "./$test.dp";
511 }
211f317f
JH
512 if ($ENV{PERL_3LOG}) {
513 my $tpp = $test;
3716a21d 514 $tpp =~ s:^\.\./::;
9c54ecba 515 $tpp =~ s:/:_:g;
3716a21d
JH
516 $tpp =~ s:\.t$:.3log:;
517 rename("perl.3log", $tpp) ||
518 die "rename: perl3.log to $tpp: $!\n";
211f317f 519 }
bb365837 520 $next = $next - 1;
b326da91
MB
521 # test if the compiler compiled something
522 if( $type eq 'compile' && !-e "$test_executable" ) {
523 $ok = 0;
524 print "Test did not compile\n";
525 }
526 if ($ok && $next == $max ) {
bb365837 527 if ($max) {
cc6ae9e5 528 print "${te}ok\n";
80ed0dea 529 $good_files++;
bb365837
GS
530 }
531 else {
cc6ae9e5 532 print "${te}skipping test on this platform\n";
80ed0dea 533 $tested_files -= 1;
bb365837 534 }
bcce72a7 535 }
bb365837
GS
536 else {
537 $next += 1;
26affc6c
AT
538 if ($next > $max) {
539 print "${te}FAILED at test $next\tpossibly due to extra output\n";
540 }
541 else {
542 print "${te}FAILED at test $next\n";
543 }
80ed0dea 544 $::bad_files++;
bb365837
GS
545 $_ = $test;
546 if (/^base/) {
547 die "Failed a basic test--cannot continue.\n";
548 }
8d063cd8
LW
549 }
550 }
8d063cd8 551
80ed0dea 552 if ($::bad_files == 0) {
bb365837
GS
553 if ($ok) {
554 print "All tests successful.\n";
555 # XXX add mention of 'perlbug -ok' ?
556 }
557 else {
558 die "FAILED--no tests were run for some reason.\n";
559 }
8d063cd8 560 }
bb365837 561 else {
80ed0dea
DM
562 my $pct = $tested_files ? sprintf("%.2f", ($tested_files - $::bad_files) / $tested_files * 100) : "0.00";
563 if ($::bad_files == 1) {
564 warn "Failed 1 test script out of $tested_files, $pct% okay.\n";
bb365837
GS
565 }
566 else {
80ed0dea 567 warn "Failed $::bad_files test scripts out of $tested_files, $pct% okay.\n";
bb365837 568 }
4e4732c1 569 warn <<'SHRDLU_1';
f7d228c6
JH
570### Since not all tests were successful, you may want to run some of
571### them individually and examine any diagnostic messages they produce.
572### See the INSTALL document's section on "make test".
4e4732c1 573SHRDLU_1
80ed0dea 574 warn <<'SHRDLU_2' if $good_files / $total_files > 0.8;
f7d228c6
JH
575### You have a good chance to get more information by running
576### ./perl harness
577### in the 't' directory since most (>=80%) of the tests succeeded.
4e4732c1
NC
578SHRDLU_2
579 if (eval {require Config; import Config; 1}) {
80ed0dea 580 if ($::Config{usedl} && (my $p = $::Config{ldlibpthname})) {
4e4732c1 581 warn <<SHRDLU_3;
f7d228c6
JH
582### You may have to set your dynamic library search path,
583### $p, to point to the build directory:
4e4732c1
NC
584SHRDLU_3
585 if (exists $ENV{$p} && $ENV{$p} ne '') {
586 warn <<SHRDLU_4a;
f7d228c6
JH
587### setenv $p `pwd`:\$$p; cd t; ./perl harness
588### $p=`pwd`:\$$p; export $p; cd t; ./perl harness
589### export $p=`pwd`:\$$p; cd t; ./perl harness
4e4732c1
NC
590SHRDLU_4a
591 } else {
592 warn <<SHRDLU_4b;
f7d228c6
JH
593### setenv $p `pwd`; cd t; ./perl harness
594### $p=`pwd`; export $p; cd t; ./perl harness
595### export $p=`pwd`; cd t; ./perl harness
4e4732c1
NC
596SHRDLU_4b
597 }
598 warn <<SHRDLU_5;
f7d228c6
JH
599### for csh-style shells, like tcsh; or for traditional/modern
600### Bourne-style shells, like bash, ksh, and zsh, respectively.
4e4732c1
NC
601SHRDLU_5
602 }
afd33fa9 603 }
bb365837 604 }
80ed0dea 605 my ($user,$sys,$cuser,$csys) = times;
bb365837 606 print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
80ed0dea 607 $user,$sys,$cuser,$csys,$tested_files,$totmax);
7a834142
JH
608 if ($ENV{PERL_VALGRIND}) {
609 my $s = $valgrind == 1 ? '' : 's';
610 print "$valgrind valgrind report$s created.\n", ;
611 }
6ee623d5 612}
80ed0dea 613exit ($::bad_files != 0);