integrate cfgperl contents into mainline
[p5sagit/p5-mst-13.2.git] / lib / Test / Harness.pm
index 61a29db..9902741 100644 (file)
@@ -64,16 +64,27 @@ sub runtests {
 
     # pass -I flags to children
     my $old5lib = $ENV{PERL5LIB};
-    local($ENV{'PERL5LIB'}) = join($Config{path_sep}, @INC);
 
-    if ($^O eq 'VMS') { $switches =~ s/-(\S*[A-Z]\S*)/"-$1"/g }
+    # VMS has a 255-byte limit on the length of %ENV entries, so
+    # toss the ones that involve perl_root, the install location
+    # for VMS
+    my $new5lib;
+    if ($^O eq 'VMS') {
+       $new5lib = join($Config{path_sep}, grep {!/perl_root/i;} @INC);
+       $switches =~ s/-(\S*[A-Z]\S*)/"-$1"/g;
+    }
+    else {
+        $new5lib = join($Config{path_sep}, @INC);
+    }
+
+    local($ENV{'PERL5LIB'}) = $new5lib;
 
     my @dir_files = globdir $files_in_dir if defined $files_in_dir;
     my $t_start = new Benchmark;
     while ($test = shift(@tests)) {
        $te = $test;
        chop($te);
-       if ($^O eq 'VMS') { $te =~ s/^.*\.t\./[.t./; }
+       if ($^O eq 'VMS') { $te =~ s/^.*\.t\./[.t./s; }
        my $blank = (' ' x 77);
        my $leader = "$te" . '.' x (20 - length($te));
        my $ml = "";
@@ -84,6 +95,8 @@ sub runtests {
        $fh->open($test) or print "can't open $test. $!\n";
        my $first = <$fh>;
        my $s = $switches;
+       $s .= " $ENV{'HARNESS_PERL_SWITCHES'}"
+           if exists $ENV{'HARNESS_PERL_SWITCHES'};
        $s .= join " ", q[ "-T"], map {qq["-I$_"]} @INC
            if $first =~ /^#!.*\bperl.*-\w*T/;
        $fh->close or print "can't close $test. $!\n";
@@ -498,6 +511,11 @@ If relative, directory name is with respect to the current directory at
 the moment runtests() was called.  Putting absolute path into 
 C<HARNESS_FILELEAK_IN_DIR> may give more predicatable results.
 
+The value of C<HARNESS_PERL_SWITCHES> will be prepended to the
+switches used to invoke perl on each test.  For example, setting
+C<HARNESS_PERL_SWITCHES> to "-W" will run all tests with all
+warnings enabled.
+
 Harness sets C<HARNESS_ACTIVE> before executing the individual tests.
 This allows the tests to determine if they are being executed through the
 harness or by any other means.