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