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