This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Enable more warnings in smart match tests
[perl5.git] / t / harness
index 8a4e9b4..5e5ddf4 100644 (file)
--- a/t/harness
+++ b/t/harness
@@ -6,8 +6,8 @@
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';              # pick up only this build's lib
-    $ENV{PERL5LIB} = '../lib';    # so children will see it too
 }
+delete $ENV{PERL5LIB};
 
 my $torture; # torture testing?
 
@@ -101,7 +101,23 @@ if ($ARGV[0] && $ARGV[0]=~/^-re/) {
 }
 
 my $jobs = $ENV{TEST_JOBS};
-my ($rules, $state);
+my ($fork, $rules, $state);
+if ($ENV{HARNESS_OPTIONS}) {
+    for my $opt ( split /:/, $ENV{HARNESS_OPTIONS} ) {
+        if ( $opt =~ /^j(\d*)$/ ) {
+            $jobs ||= $1 || 9;
+        }
+        elsif ( $opt eq 'f' ) {
+            $fork = 1;
+        }
+        elsif ( $opt eq 'c' ) {
+#            $args->{color} = 1;
+        }
+        else {
+            die "Unknown HARNESS_OPTIONS item: $opt\n";
+        }
+    }
+}
 
 if (@ARGV) {
     # If you want these run in speed order, just use prove
@@ -172,14 +188,16 @@ if (@ARGV) {
        my $mani  = File::Spec->catfile(File::Spec->updir, "MANIFEST");
        if (open(MANI, $mani)) {
            my @manitests = ();
-           my $ext_pat = $^O eq 'MSWin32' ? '(?:win32/)?ext' : 'ext';
            while (<MANI>) { # similar code in t/TEST
-               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 ($test, $extension) = ($1, $2);
                    if (defined $extension) {
                        $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
                    }
                    push @manitests, File::Spec->catfile($updir, $test);
                }
@@ -191,7 +209,6 @@ if (@ARGV) {
        } else {
            warn "$0: cannot open $mani: $!\n";
        }
-       push @last, <Module_Pluggable/*.t>;
        push @last, <pod/*.t>;
        push @last, <x2p/*.t>;
 
@@ -210,14 +227,28 @@ if ($^O eq 'MSWin32') {
 
 if ($jobs) {
     eval 'use TAP::Harness 3.13; 1' or die $@;
-    my $h = TAP::Harness->new({ jobs => $jobs, rules => $rules});
+
+    # Test::Harness parses $ENV{HARNESS_OPTIONS}, TAP::Harness does not
+    local $ENV{HARNESS_OPTIONS};
+    my $h = TAP::Harness->new({ jobs => $jobs, rules => $rules, ($fork ? (fork => $fork) : ())});
     if ($state) {
        $h->callback(
                     after_test => sub {
                         $state->observe_test(@_);
                     }
                    );
+       $h->callback(
+                    after_runtests => sub {
+                        $state->commit(@_);
+                    }
+                   );
     }
+    $h->callback(
+                parser_args => sub {
+                    my ( $args, $test ) = @_;
+                    push @{ $args->{switches} }, '-I../lib';
+                }
+               );
     $h->runtests(@tests);
 } else {
     Test::Harness::runtests @tests;