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; |
17 | |
cc6ae9e5 |
18 | # remove empty elements due to insertion of empty symbols via "''p1'" syntax |
19 | @ARGV = grep($_,@ARGV) if $^O eq 'VMS'; |
551405c4 |
20 | our $show_elapsed_time = $ENV{HARNESS_TIMER} || 0; |
cc6ae9e5 |
21 | |
5d9a6404 |
22 | # Cheesy version of Getopt::Std. Maybe we should replace it with that. |
80ed0dea |
23 | { |
24 | my @argv = (); |
5d9a6404 |
25 | foreach my $idx (0..$#ARGV) { |
b326da91 |
26 | push( @argv, $ARGV[$idx] ), next unless $ARGV[$idx] =~ /^-(\S+)$/; |
80ed0dea |
27 | $::core = 1 if $1 eq 'core'; |
28 | $::verbose = 1 if $1 eq 'v'; |
29 | $::torture = 1 if $1 eq 'torture'; |
30 | $::with_utf8 = 1 if $1 eq 'utf8'; |
31 | $::with_utf16 = 1 if $1 eq 'utf16'; |
32 | $::bytecompile = 1 if $1 eq 'bytecompile'; |
33 | $::compile = 1 if $1 eq 'compile'; |
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) { |
9f3d340b |
109 | foreach my $dir (qw(base comp cmd run io op uni)) { |
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)) { |
00701878 |
145 | my $ext_pat = $^O eq 'MSWin32' ? '(?:win32/)?ext' : 'ext'; |
f458b6e8 |
146 | while (<MANI>) { # similar code in t/harness |
00701878 |
147 | if (m!^($ext_pat/(\S+)/+(?:[^/\s]+\.t|test\.pl)|lib/\S+?(?:\.t|test\.pl))\s!) { |
80ed0dea |
148 | my $t = $1; |
149 | my $extension = $2; |
150 | if (!$::core || $t =~ m!^lib/[a-z]!) |
5a6e071d |
151 | { |
6234cb77 |
152 | if (defined $extension) { |
153 | $extension =~ s!/t$!!; |
154 | # XXX Do I want to warn that I'm skipping these? |
155 | next if $skip{$extension}; |
156 | } |
80ed0dea |
157 | my $path = File::Spec->catfile($updir, $t); |
73ddec28 |
158 | push @ARGV, $path; |
80ed0dea |
159 | $::path_to_name{$path} = $t; |
5a6e071d |
160 | } |
7a315204 |
161 | } |
162 | } |
35d88760 |
163 | close MANI; |
7a315204 |
164 | } else { |
f458b6e8 |
165 | warn "$0: cannot open $mani: $!\n"; |
7a315204 |
166 | } |
80ed0dea |
167 | unless ($::core) { |
d44161bf |
168 | _find_tests('pod'); |
e018f8be |
169 | _find_tests('x2p'); |
80ed0dea |
170 | _find_tests('japh') if $::torture; |
e018f8be |
171 | } |
8d063cd8 |
172 | } |
173 | |
7a315204 |
174 | # Tests known to cause infinite loops for the perlcc tests. |
80ed0dea |
175 | # %::infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 ); |
176 | %::infinite = (); |
6ee623d5 |
177 | |
80ed0dea |
178 | if ($::deparse) { |
f193aa2f |
179 | _testprogs('deparse', '', @ARGV); |
180 | } |
f458b6e8 |
181 | elsif( $::compile ) { |
1df34986 |
182 | _testprogs('compile', '', @ARGV); |
183 | } |
80ed0dea |
184 | elsif( $::bytecompile ) { |
1df34986 |
185 | _testprogs('bytecompile', '', @ARGV); |
f193aa2f |
186 | } |
80ed0dea |
187 | elsif ($::with_utf16) { |
1de9afcd |
188 | for my $e (0, 1) { |
189 | for my $b (0, 1) { |
190 | print STDERR "# ENDIAN $e BOM $b\n"; |
191 | my @UARGV; |
192 | for my $a (@ARGV) { |
193 | my $u = $a . "." . ($e ? "l" : "b") . "e" . ($b ? "b" : ""); |
194 | my $f = $e ? "v" : "n"; |
195 | push @UARGV, $u; |
196 | unlink($u); |
197 | if (open(A, $a)) { |
198 | if (open(U, ">$u")) { |
90f6ca78 |
199 | print U pack("$f", 0xFEFF) if $b; |
1de9afcd |
200 | while (<A>) { |
201 | print U pack("$f*", unpack("C*", $_)); |
202 | } |
80ed0dea |
203 | close(U); |
1de9afcd |
204 | } |
80ed0dea |
205 | close(A); |
1de9afcd |
206 | } |
207 | } |
208 | _testprogs('perl', '', @UARGV); |
209 | unlink(@UARGV); |
210 | } |
211 | } |
212 | } |
f193aa2f |
213 | else { |
214 | _testprogs('compile', '', @ARGV) if -e "../testcompile"; |
215 | _testprogs('perl', '', @ARGV); |
485988ae |
216 | } |
6ee623d5 |
217 | |
bb365837 |
218 | sub _testprogs { |
80ed0dea |
219 | my ($type, $args, @tests) = @_; |
6ee623d5 |
220 | |
bb365837 |
221 | print <<'EOT' if ($type eq 'compile'); |
7a315204 |
222 | ------------------------------------------------------------------------------ |
6ee623d5 |
223 | TESTING COMPILER |
7a315204 |
224 | ------------------------------------------------------------------------------ |
bb365837 |
225 | EOT |
226 | |
485988ae |
227 | print <<'EOT' if ($type eq 'deparse'); |
7a315204 |
228 | ------------------------------------------------------------------------------ |
485988ae |
229 | TESTING DEPARSER |
7a315204 |
230 | ------------------------------------------------------------------------------ |
485988ae |
231 | EOT |
232 | |
566ece03 |
233 | print <<EOT if ($type eq 'bytecompile'); |
1df34986 |
234 | ------------------------------------------------------------------------------ |
235 | TESTING BYTECODE COMPILER |
236 | ------------------------------------------------------------------------------ |
237 | EOT |
238 | |
595ae481 |
239 | $ENV{PERLCC_TIMEOUT} = 120 |
f458b6e8 |
240 | if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT}); |
ef712cf7 |
241 | |
80ed0dea |
242 | $::bad_files = 0; |
73ddec28 |
243 | |
cc6ae9e5 |
244 | foreach my $t (@tests) { |
80ed0dea |
245 | unless (exists $::path_to_name{$t}) { |
f458b6e8 |
246 | my $tname = File::Spec->catfile('t',$t); |
247 | $tname = VMS::Filespec::unixify($tname) if $^O eq 'VMS'; |
248 | $::path_to_name{$t} = $tname; |
cc6ae9e5 |
249 | } |
73ddec28 |
250 | } |
908801fe |
251 | my $maxlen = 0; |
80ed0dea |
252 | foreach (@::path_to_name{@tests}) { |
73ddec28 |
253 | s/\.\w+\z/./; |
254 | my $len = length ; |
255 | $maxlen = $len if $len > $maxlen; |
088b5126 |
256 | } |
908801fe |
257 | # + 3 : we want three dots between the test name and the "ok" |
80ed0dea |
258 | my $dotdotdot = $maxlen + 3 ; |
7a834142 |
259 | my $valgrind = 0; |
da51b73c |
260 | my $valgrind_log = 'current.valgrind'; |
80ed0dea |
261 | my $total_files = @tests; |
262 | my $good_files = 0; |
263 | my $tested_files = 0; |
264 | my $totmax = 0; |
ade55ef4 |
265 | my %failed_tests; |
80ed0dea |
266 | |
551405c4 |
267 | while (my $test = shift @tests) { |
28ffa55a |
268 | my $test_start_time = $show_elapsed_time ? Time::HiRes::time() : 0; |
bb365837 |
269 | |
80ed0dea |
270 | if ( $::infinite{$test} && $type eq 'compile' ) { |
595ae481 |
271 | print STDERR "$test creates infinite loop! Skipping.\n"; |
f458b6e8 |
272 | next; |
6ee623d5 |
273 | } |
bb365837 |
274 | if ($test =~ /^$/) { |
275 | next; |
6ee623d5 |
276 | } |
485988ae |
277 | if ($type eq 'deparse') { |
278 | if ($test eq "comp/redef.t") { |
279 | # Redefinition happens at compile time |
280 | next; |
281 | } |
7a834142 |
282 | elsif ($test =~ m{lib/Switch/t/}) { |
485988ae |
283 | # B::Deparse doesn't support source filtering |
284 | next; |
285 | } |
286 | } |
80ed0dea |
287 | my $te = $::path_to_name{$test} . '.' |
288 | x ($dotdotdot - length($::path_to_name{$test})); |
cc6ae9e5 |
289 | |
290 | if ($^O ne 'VMS') { # defer printing on VMS due to piping bug |
291 | print $te; |
292 | $te = ''; |
293 | } |
bb365837 |
294 | |
80ed0dea |
295 | # XXX DAPM %OVER not defined anywhere |
296 | # $test = $OVER{$test} if exists $OVER{$test}; |
7a315204 |
297 | |
551405c4 |
298 | open(SCRIPT,"<",$test) or die "Can't run $test.\n"; |
f458b6e8 |
299 | $_ = <SCRIPT>; |
300 | close(SCRIPT) unless ($type eq 'deparse'); |
80ed0dea |
301 | if ($::with_utf16) { |
90f6ca78 |
302 | $_ =~ tr/\0//d; |
303 | } |
80ed0dea |
304 | my $switch; |
f458b6e8 |
305 | if (/#!.*\bperl.*\s-\w*([tT])/) { |
306 | $switch = qq{"-$1"}; |
307 | } |
308 | else { |
80ed0dea |
309 | if ($::taintwarn) { |
b26492ee |
310 | # not all tests are expected to pass with this option |
311 | $switch = '"-t"'; |
312 | } |
313 | else { |
314 | $switch = ''; |
315 | } |
f458b6e8 |
316 | } |
6ee623d5 |
317 | |
f458b6e8 |
318 | my $test_executable; # for 'compile' tests |
485988ae |
319 | my $file_opts = ""; |
320 | if ($type eq 'deparse') { |
321 | # Look for #line directives which change the filename |
322 | while (<SCRIPT>) { |
323 | $file_opts .= ",-f$3$4" |
324 | if /^#\s*line\s+(\d+)\s+((\w+)|"([^"]+)")/; |
325 | } |
326 | close(SCRIPT); |
327 | } |
7a315204 |
328 | |
80ed0dea |
329 | my $utf8 = $::with_utf8 ? '-I../lib -Mutf8' : ''; |
4343e7c3 |
330 | my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC |
485988ae |
331 | if ($type eq 'deparse') { |
80ed0dea |
332 | my $deparse_cmd = |
127212b2 |
333 | "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,-sv1.,". |
80ed0dea |
334 | "-l$::deparse_opts$file_opts ". |
7a315204 |
335 | "$test > $test.dp ". |
336 | "&& ./perl $testswitch $switch -I../lib $test.dp |"; |
80ed0dea |
337 | open(RESULTS, $deparse_cmd) |
338 | or print "can't deparse '$deparse_cmd': $!.\n"; |
485988ae |
339 | } |
1df34986 |
340 | elsif ($type eq 'bytecompile') { |
c7e45529 |
341 | my ($pwd, $null); |
f458b6e8 |
342 | if( $^O eq 'MSWin32') { |
c7e45529 |
343 | $pwd = `cd`; |
344 | $null = 'nul'; |
345 | } else { |
346 | $pwd = `pwd`; |
347 | $null = '/dev/null'; |
348 | } |
349 | chomp $pwd; |
350 | my $perl = $ENV{PERL} || "$pwd/perl"; |
351 | my $bswitch = "-MO=Bytecode,-H,-TI,-s$pwd/$test,"; |
566ece03 |
352 | $bswitch .= "-TF$test.plc," |
1df34986 |
353 | if $test =~ m(chdir|pod/|CGI/t/carp|lib/DB); |
354 | $bswitch .= "-k," |
355 | if $test =~ m(deparse|terse|ext/Storable/t/code); |
1df34986 |
356 | $bswitch .= "-b," |
357 | if $test =~ m(op/getpid); |
80ed0dea |
358 | my $bytecompile_cmd = |
f458b6e8 |
359 | "$perl $testswitch $switch -I../lib $bswitch". |
c7e45529 |
360 | "-o$test.plc $test 2>$null &&". |
1de9afcd |
361 | "$perl $testswitch $switch -I../lib $utf8 $test.plc |"; |
80ed0dea |
362 | open(RESULTS,$bytecompile_cmd) |
363 | or print "can't byte-compile '$bytecompile_cmd': $!.\n"; |
1df34986 |
364 | } |
485988ae |
365 | elsif ($type eq 'perl') { |
a7da9a42 |
366 | my $perl = $ENV{PERL} || './perl'; |
da51b73c |
367 | my $redir = $^O eq 'VMS' ? '2>&1' : ''; |
7a834142 |
368 | if ($ENV{PERL_VALGRIND}) { |
4f9287d3 |
369 | my $valgrind = $ENV{VALGRIND} // 'valgrind'; |
370 | $perl = "$valgrind --suppressions=perl.supp --leak-check=yes " |
371 | . "--leak-resolution=high --show-reachable=yes " |
d76be4ee |
372 | . "--num-callers=50 --log-fd=3 $perl"; |
da51b73c |
373 | $redir = "3>$valgrind_log"; |
7a834142 |
374 | } |
80ed0dea |
375 | my $run = "$perl" . _quote_args("$testswitch $switch $utf8") |
376 | . " $test $redir|"; |
be24517c |
377 | open(RESULTS,$run) or print "can't run '$run': $!.\n"; |
d638aca2 |
378 | } |
379 | else { |
80ed0dea |
380 | my $compile_cmd; |
f458b6e8 |
381 | my $pl2c = "$testswitch -I../lib ../utils/perlcc --testsuite " . |
382 | # -O9 for good measure, -fcog is broken ATM |
383 | "$switch -Wb=-O9,-fno-cog -L .. " . |
384 | "-I \".. ../lib/CORE\" $args $utf8 $test -o "; |
385 | |
386 | if( $^O eq 'MSWin32' ) { |
387 | $test_executable = "$test.exe"; |
388 | # hopefully unused name... |
389 | open HACK, "> xweghyz.pl"; |
390 | print HACK <<EOT; |
b326da91 |
391 | #!./perl |
392 | |
393 | open HACK, '.\\perl $pl2c $test_executable |'; |
394 | # cl.exe prints the name of the .c file on stdout (\%^\$^#) |
6d73d07f |
395 | while(<HACK>) {m/^\\w+\\.[cC]\$/ && next;print} |
b326da91 |
396 | open HACK, '$test_executable |'; |
397 | while(<HACK>) {print} |
398 | EOT |
f458b6e8 |
399 | close HACK; |
400 | $compile_cmd = 'xweghyz.pl |'; |
401 | } |
402 | else { |
403 | $test_executable = "$test.plc"; |
404 | $compile_cmd |
80ed0dea |
405 | = "./perl $pl2c $test_executable && $test_executable |"; |
f458b6e8 |
406 | } |
407 | unlink $test_executable if -f $test_executable; |
80ed0dea |
408 | open(RESULTS, $compile_cmd) |
409 | or print "can't compile '$compile_cmd': $!.\n"; |
6ee623d5 |
410 | } |
9c8d215a |
411 | # Our environment may force us to use UTF-8, but we can't be sure that |
412 | # anything we're reading from will be generating (well formed) UTF-8 |
413 | # This may not be the best way - possibly we should unset ${^OPEN} up |
414 | # top? |
415 | binmode RESULTS; |
d638aca2 |
416 | |
f458b6e8 |
417 | my $failure; |
418 | my $next = 0; |
419 | my $seen_leader = 0; |
420 | my $seen_ok = 0; |
20f82676 |
421 | my $trailing_leader = 0; |
80ed0dea |
422 | my $max; |
43fe0836 |
423 | my %todo; |
bb365837 |
424 | while (<RESULTS>) { |
cc6ae9e5 |
425 | next if /^\s*$/; # skip blank lines |
80ed0dea |
426 | if ($::verbose) { |
bb365837 |
427 | print $_; |
428 | } |
21c74f43 |
429 | unless (/^\#/) { |
20f82676 |
430 | if ($trailing_leader) { |
431 | # shouldn't be anything following a postfix 1..n |
a5890677 |
432 | $failure = 'FAILED--extra output after trailing 1..n'; |
20f82676 |
433 | last; |
434 | } |
809908f7 |
435 | if (/^1\.\.([0-9]+)( todo ([\d ]+))?/) { |
20f82676 |
436 | if ($seen_leader) { |
a5890677 |
437 | $failure = 'FAILED--seen duplicate leader'; |
20f82676 |
438 | last; |
439 | } |
bb365837 |
440 | $max = $1; |
f458b6e8 |
441 | %todo = map { $_ => 1 } split / /, $3 if $3; |
bb365837 |
442 | $totmax += $max; |
80ed0dea |
443 | $tested_files++; |
f458b6e8 |
444 | if ($seen_ok) { |
20f82676 |
445 | # 1..n appears at end of file |
446 | $trailing_leader = 1; |
447 | if ($next != $max) { |
a5890677 |
448 | $failure = "FAILED--expected $max tests, saw $next"; |
20f82676 |
449 | last; |
450 | } |
451 | } |
452 | else { |
453 | $next = 0; |
454 | } |
f458b6e8 |
455 | $seen_leader = 1; |
bb365837 |
456 | } |
457 | else { |
f458b6e8 |
458 | if (/^(not )?ok(?: (\d+))?[^\#]*(\s*\#.*)?/) { |
21c74f43 |
459 | unless ($seen_leader) { |
460 | unless ($seen_ok) { |
20f82676 |
461 | $next = 0; |
21c74f43 |
462 | } |
37ce32a7 |
463 | } |
21c74f43 |
464 | $seen_ok = 1; |
20f82676 |
465 | $next++; |
f458b6e8 |
466 | my($not, $num, $extra, $istodo) = ($1, $2, $3, 0); |
467 | $num = $next unless $num; |
468 | |
469 | if ($num == $next) { |
470 | |
eac7c728 |
471 | # SKIP is essentially the same as TODO for t/TEST |
472 | # this still conforms to TAP: |
473 | # http://search.cpan.org/dist/Test-Harness/lib/Test/Harness/TAP.pod |
474 | $extra and $istodo = $extra =~ /#\s*(?:TODO|SKIP)\b/; |
21c74f43 |
475 | $istodo = 1 if $todo{$num}; |
476 | |
477 | if( $not && !$istodo ) { |
20f82676 |
478 | $failure = "FAILED at test $num"; |
21c74f43 |
479 | last; |
480 | } |
20f82676 |
481 | } |
482 | else { |
f458b6e8 |
483 | $failure ="FAILED--expected test $next, saw test $num"; |
20f82676 |
484 | last; |
37ce32a7 |
485 | } |
f458b6e8 |
486 | } |
487 | elsif (/^Bail out!\s*(.*)/i) { # magic words |
488 | die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n"); |
bb365837 |
489 | } |
490 | else { |
dbf51d07 |
491 | # module tests are allowed extra output, |
492 | # because Test::Harness allows it |
493 | next if $test =~ /^\W*(ext|lib)\b/; |
a5890677 |
494 | $failure = "FAILED--unexpected output at test $next"; |
20f82676 |
495 | last; |
bb365837 |
496 | } |
8d063cd8 |
497 | } |
498 | } |
499 | } |
bb365837 |
500 | close RESULTS; |
20f82676 |
501 | |
502 | if (not defined $failure) { |
a5890677 |
503 | $failure = 'FAILED--no leader found' unless $seen_leader; |
20f82676 |
504 | } |
505 | |
7a834142 |
506 | if ($ENV{PERL_VALGRIND}) { |
da51b73c |
507 | my @valgrind; |
508 | if (-e $valgrind_log) { |
509 | if (open(V, $valgrind_log)) { |
510 | @valgrind = <V>; |
511 | close V; |
512 | } else { |
513 | warn "$0: Failed to open '$valgrind_log': $!\n"; |
514 | } |
515 | } |
7a834142 |
516 | if (@valgrind) { |
d44161bf |
517 | my $leaks = 0; |
518 | my $errors = 0; |
7a834142 |
519 | for my $i (0..$#valgrind) { |
520 | local $_ = $valgrind[$i]; |
d44161bf |
521 | if (/^==\d+== ERROR SUMMARY: (\d+) errors? /) { |
522 | $errors += $1; # there may be multiple error summaries |
523 | } elsif (/^==\d+== LEAK SUMMARY:/) { |
524 | for my $off (1 .. 4) { |
525 | if ($valgrind[$i+$off] =~ |
526 | /(?:lost|reachable):\s+\d+ bytes in (\d+) blocks/) { |
527 | $leaks += $1; |
528 | } |
529 | } |
7a834142 |
530 | } |
531 | } |
d44161bf |
532 | if ($errors or $leaks) { |
da51b73c |
533 | if (rename $valgrind_log, "$test.valgrind") { |
d44161bf |
534 | $valgrind++; |
535 | } else { |
536 | warn "$0: Failed to create '$test.valgrind': $!\n"; |
7a834142 |
537 | } |
538 | } |
539 | } else { |
540 | warn "No valgrind output?\n"; |
541 | } |
da51b73c |
542 | if (-e $valgrind_log) { |
543 | unlink $valgrind_log |
544 | or warn "$0: Failed to unlink '$valgrind_log': $!\n"; |
545 | } |
7a834142 |
546 | } |
485988ae |
547 | if ($type eq 'deparse') { |
548 | unlink "./$test.dp"; |
549 | } |
211f317f |
550 | if ($ENV{PERL_3LOG}) { |
551 | my $tpp = $test; |
3716a21d |
552 | $tpp =~ s:^\.\./::; |
9c54ecba |
553 | $tpp =~ s:/:_:g; |
3716a21d |
554 | $tpp =~ s:\.t$:.3log:; |
555 | rename("perl.3log", $tpp) || |
556 | die "rename: perl3.log to $tpp: $!\n"; |
211f317f |
557 | } |
f458b6e8 |
558 | # test if the compiler compiled something |
559 | if( $type eq 'compile' && !-e "$test_executable" ) { |
560 | $failure = "Test did not compile"; |
561 | } |
20f82676 |
562 | if (not defined $failure and $next != $max) { |
a5890677 |
563 | $failure="FAILED--expected $max tests, saw $next"; |
20f82676 |
564 | } |
565 | |
566 | if (defined $failure) { |
567 | print "${te}$failure\n"; |
568 | $::bad_files++; |
ade55ef4 |
569 | if ($test =~ /^base/) { |
570 | die "Failed a basic test ($test) -- cannot continue.\n"; |
20f82676 |
571 | } |
ade55ef4 |
572 | ++$failed_tests{$test}; |
20f82676 |
573 | } |
574 | else { |
bb365837 |
575 | if ($max) { |
551405c4 |
576 | my $elapsed; |
577 | if ( $show_elapsed_time ) { |
578 | $elapsed = sprintf( " %8.0f ms", (Time::HiRes::time() - $test_start_time) * 1000 ); |
579 | } |
580 | else { |
581 | $elapsed = ""; |
582 | } |
583 | print "${te}ok$elapsed\n"; |
80ed0dea |
584 | $good_files++; |
bb365837 |
585 | } |
586 | else { |
cc6ae9e5 |
587 | print "${te}skipping test on this platform\n"; |
80ed0dea |
588 | $tested_files -= 1; |
bb365837 |
589 | } |
bcce72a7 |
590 | } |
551405c4 |
591 | } # while tests |
8d063cd8 |
592 | |
80ed0dea |
593 | if ($::bad_files == 0) { |
20f82676 |
594 | if ($good_files) { |
bb365837 |
595 | print "All tests successful.\n"; |
596 | # XXX add mention of 'perlbug -ok' ? |
597 | } |
598 | else { |
599 | die "FAILED--no tests were run for some reason.\n"; |
600 | } |
8d063cd8 |
601 | } |
bb365837 |
602 | else { |
80ed0dea |
603 | my $pct = $tested_files ? sprintf("%.2f", ($tested_files - $::bad_files) / $tested_files * 100) : "0.00"; |
ade55ef4 |
604 | my $s = $::bad_files == 1 ? "" : "s"; |
605 | warn "Failed $::bad_files test$s out of $tested_files, $pct% okay.\n"; |
606 | for my $test ( sort keys %failed_tests ) { |
607 | print "\t$test\n"; |
bb365837 |
608 | } |
4e4732c1 |
609 | warn <<'SHRDLU_1'; |
f7d228c6 |
610 | ### Since not all tests were successful, you may want to run some of |
611 | ### them individually and examine any diagnostic messages they produce. |
612 | ### See the INSTALL document's section on "make test". |
4e4732c1 |
613 | SHRDLU_1 |
80ed0dea |
614 | warn <<'SHRDLU_2' if $good_files / $total_files > 0.8; |
f7d228c6 |
615 | ### You have a good chance to get more information by running |
616 | ### ./perl harness |
617 | ### in the 't' directory since most (>=80%) of the tests succeeded. |
4e4732c1 |
618 | SHRDLU_2 |
f458b6e8 |
619 | if (eval {require Config; import Config; 1}) { |
80ed0dea |
620 | if ($::Config{usedl} && (my $p = $::Config{ldlibpthname})) { |
4e4732c1 |
621 | warn <<SHRDLU_3; |
f7d228c6 |
622 | ### You may have to set your dynamic library search path, |
623 | ### $p, to point to the build directory: |
4e4732c1 |
624 | SHRDLU_3 |
f458b6e8 |
625 | if (exists $ENV{$p} && $ENV{$p} ne '') { |
4e4732c1 |
626 | warn <<SHRDLU_4a; |
f7d228c6 |
627 | ### setenv $p `pwd`:\$$p; cd t; ./perl harness |
628 | ### $p=`pwd`:\$$p; export $p; cd t; ./perl harness |
629 | ### export $p=`pwd`:\$$p; cd t; ./perl harness |
4e4732c1 |
630 | SHRDLU_4a |
f458b6e8 |
631 | } else { |
4e4732c1 |
632 | warn <<SHRDLU_4b; |
f7d228c6 |
633 | ### setenv $p `pwd`; cd t; ./perl harness |
634 | ### $p=`pwd`; export $p; cd t; ./perl harness |
635 | ### export $p=`pwd`; cd t; ./perl harness |
4e4732c1 |
636 | SHRDLU_4b |
f458b6e8 |
637 | } |
4e4732c1 |
638 | warn <<SHRDLU_5; |
f7d228c6 |
639 | ### for csh-style shells, like tcsh; or for traditional/modern |
640 | ### Bourne-style shells, like bash, ksh, and zsh, respectively. |
4e4732c1 |
641 | SHRDLU_5 |
f458b6e8 |
642 | } |
afd33fa9 |
643 | } |
bb365837 |
644 | } |
80ed0dea |
645 | my ($user,$sys,$cuser,$csys) = times; |
f47304e9 |
646 | print sprintf("u=%.2f s=%.2f cu=%.2f cs=%.2f scripts=%d tests=%d\n", |
80ed0dea |
647 | $user,$sys,$cuser,$csys,$tested_files,$totmax); |
7a834142 |
648 | if ($ENV{PERL_VALGRIND}) { |
649 | my $s = $valgrind == 1 ? '' : 's'; |
650 | print "$valgrind valgrind report$s created.\n", ; |
651 | } |
6ee623d5 |
652 | } |
80ed0dea |
653 | exit ($::bad_files != 0); |
ade55ef4 |
654 | |
655 | # ex: set ts=8 sts=4 sw=4 noet: |