Merge branch 'deletelocal' into blead
[p5sagit/p5-mst-13.2.git] / t / TEST
diff --git a/t/TEST b/t/TEST
index 22d814d..9af8baa 100755 (executable)
--- a/t/TEST
+++ b/t/TEST
@@ -14,6 +14,7 @@ $| = 1;
 # Let tests know they're running in the perl core.  Useful for modules
 # which live dual lives on CPAN.
 $ENV{PERL_CORE} = 1;
+delete $ENV{PERL5LIB};
 
 # remove empty elements due to insertion of empty symbols via "''p1'" syntax
 @ARGV = grep($_,@ARGV) if $^O eq 'VMS';
@@ -24,6 +25,7 @@ our $show_elapsed_time = $ENV{HARNESS_TIMER} || 0;
     my @argv = ();
     foreach my $idx (0..$#ARGV) {
        push( @argv, $ARGV[$idx] ), next unless $ARGV[$idx] =~ /^-(\S+)$/;
+       $::benchmark = 1 if $1 eq 'benchmark';
        $::core    = 1 if $1 eq 'core';
        $::verbose = 1 if $1 eq 'v';
        $::torture = 1 if $1 eq 'torture';
@@ -104,7 +106,7 @@ sub _populate_hash {
 }
 
 unless (@ARGV) {
-    foreach my $dir (qw(base comp cmd run io op uni)) {
+    foreach my $dir (qw(base comp cmd run io op uni mro)) {
        _find_tests($dir);
     }
     _find_tests("lib") unless $::core;
@@ -140,9 +142,8 @@ unless (@ARGV) {
     }
     my $mani = File::Spec->catfile($updir, "MANIFEST");
     if (open(MANI, $mani)) {
-       my $ext_pat = $^O eq 'MSWin32' ? '(?:win32/)?ext' : 'ext';
        while (<MANI>) { # similar code in t/harness
-           if (m!^($ext_pat/(\S+)/+(?:[^/\s]+\.t|test\.pl)|lib/\S+?(?:\.t|test\.pl))\s!) {
+           if (m!^(ext/(\S+)/+(?:[^/\s]+\.t|test\.pl)|lib/\S+?(?:\.t|test\.pl))\s!) {
                my $t = $1;
                my $extension = $2;
                if (!$::core || $t =~ m!^lib/[a-z]!)
@@ -151,6 +152,9 @@ unless (@ARGV) {
                        $extension =~ s!/t$!!;
                        # XXX Do I want to warn that I'm skipping these?
                        next if $skip{$extension};
+                       my $flat_extension = $extension;
+                       $flat_extension =~ s!-!/!g;
+                       next if $skip{$flat_extension}; # Foo/Bar may live in Foo-Bar
                    }
                    my $path = File::Spec->catfile($updir, $t);
                    push @ARGV, $path;
@@ -166,6 +170,7 @@ unless (@ARGV) {
        _find_tests('pod');
        _find_tests('x2p');
        _find_tests('japh') if $::torture;
+       _find_tests('t/benchmark') if $::benchmark or $ENV{PERL_BENCHMARK};
     }
 }
 
@@ -309,9 +314,11 @@ EOT
            my $redir = $^O eq 'VMS' ? '2>&1' : '';
            if ($ENV{PERL_VALGRIND}) {
                my $valgrind = $ENV{VALGRIND} // 'valgrind';
-               $perl = "$valgrind --suppressions=perl.supp --leak-check=yes "
-                               . "--leak-resolution=high --show-reachable=yes "
-                               . "--num-callers=50 --log-fd=3 $perl";
+               my $vg_opts = $ENV{VG_OPTS}
+                   //  "--suppressions=perl.supp --leak-check=yes "
+                       . "--leak-resolution=high --show-reachable=yes "
+                       . "--num-callers=50"; 
+               $perl = "$valgrind --log-fd=3 $vg_opts $perl";
                $redir = "3>$valgrind_log";
            }
            my $run = "$perl" . _quote_args("$testswitch $switch $utf8")
@@ -333,6 +340,14 @@ EOT
        my %todo;
        while (<RESULTS>) {
            next if /^\s*$/; # skip blank lines
+           if (/^1..$/ && ($^O eq 'VMS')) {
+               # VMS pipe bug inserts blank lines.
+               my $l2 = <RESULTS>;
+               if ($l2 =~ /^\s*$/) {
+                   $l2 = <RESULTS>;
+               }
+               $_ = '1..' . $l2;
+           }
            if ($::verbose) {
                print $_;
            }
@@ -380,7 +395,7 @@ EOT
 
                            # SKIP is essentially the same as TODO for t/TEST
                            # this still conforms to TAP:
-                           # http://search.cpan.org/dist/Test-Harness/lib/Test/Harness/TAP.pod
+                           # http://search.cpan.org/dist/TAP/TAP.pod
                            $extra and $istodo = $extra =~ /#\s*(?:TODO|SKIP)\b/;
                            $istodo = 1 if $todo{$num};
 
@@ -423,7 +438,14 @@ EOT
                    warn "$0: Failed to open '$valgrind_log': $!\n";
                }
            }
-           if (@valgrind) {
+           if ($ENV{VG_OPTS} =~ /cachegrind/) {
+               if (rename $valgrind_log, "$test.valgrind") {
+                   $valgrind++;
+               } else {
+                   warn "$0: Failed to create '$test.valgrind': $!\n";
+               }
+           }
+           elsif (@valgrind) {
                my $leaks = 0;
                my $errors = 0;
                for my $i (0..$#valgrind) {
@@ -469,6 +491,12 @@ EOT
            $failure="FAILED--expected $max tests, saw $next";
        }
 
+       if( !defined $failure  # don't mask a test failure
+           and $? )
+       {
+           $failure = "FAILED--non-zero wait status: $?";
+       }
+
        if (defined $failure) {
            print "${te}$failure\n";
            $::bad_files++;
@@ -490,7 +518,7 @@ EOT
                $good_files++;
            }
            else {
-               print "${te}skipping test on this platform\n";
+               print "${te}skipped\n";
                $tested_files -= 1;
            }
        }