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