This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
TODO tests for reads from a scalar changed to upgraded after open
[perl5.git] / t / TEST
diff --git a/t/TEST b/t/TEST
index 0a354ba..00d8159 100755 (executable)
--- a/t/TEST
+++ b/t/TEST
@@ -2,7 +2,7 @@
 
 # This is written in a peculiar style, since we're trying to avoid
 # most of the constructs we'll be testing for.  (This comment is
-# probably obsolete on the avoidance side, though still currrent
+# probably obsolete on the avoidance side, though still current
 # on the peculiarity side.)
 
 # t/TEST and t/harness need to share code. The logical way to do this would be
@@ -23,8 +23,8 @@ my %dir_to_switch =
      '../ext/File-Glob/t' => '-I.. -MTestInit', # FIXME - tests assume t/
      );
 
-# "not absolute" is the the default, as it saves some fakery within TestInit
-# which can peturb tests, and takes CPU. Working with the upstream author of
+# "not absolute" is the default, as it saves some fakery within TestInit
+# which can perturb tests, and takes CPU. Working with the upstream author of
 # any of these, to figure out how to remove them from this list, considered
 # "a good thing".
 my %abs = (
@@ -51,13 +51,13 @@ my %abs = (
           '../cpan/Pod-Simple' => 1,
           '../cpan/Term-UI' => 1,
           '../cpan/Test-Simple' => 1,
-          '../cpan/Tie-File' => 1,
           '../cpan/podlators' => 1,
           '../dist/Cwd' => 1,
           '../dist/ExtUtils-Command' => 1,
           '../dist/ExtUtils-Install' => 1,
           '../dist/ExtUtils-Manifest' => 1,
           '../dist/ExtUtils-ParseXS' => 1,
+          '../dist/Tie-File' => 1,
          );
 
 my %temp_no_core =
@@ -81,7 +81,12 @@ my %temp_no_core =
 # delete env vars that may influence the results
 # but allow override via *_TEST env var if wanted
 # (e.g. PERL5OPT_TEST=-d:NYTProf)
-for my $envname (qw(PERL5LIB PERLLIB PERL5OPT)) {
+my @bad_env_vars = qw(
+    PERL5LIB PERLLIB PERL5OPT
+    PERL_YAML_BACKEND PERL_JSON_BACKEND
+);
+
+for my $envname (@bad_env_vars) {
     my $override = $ENV{"${envname}_TEST"};
     if (defined $override) {
        warn "$0: $envname=$override\n";
@@ -155,6 +160,8 @@ if ($ENV{PERL_3LOG}) { # Tru64 third(1) tool, see perlhack
 
 # check leakage for embedders
 $ENV{PERL_DESTRUCT_LEVEL} = 2 unless exists $ENV{PERL_DESTRUCT_LEVEL};
+# check existence of all symbols
+$ENV{PERL_DL_NONLAZY} = 1 unless exists $ENV{PERL_DL_NONLAZY};
 
 $ENV{EMXSHELL} = 'sh';        # For OS/2
 
@@ -171,20 +178,24 @@ my %skip = (
           );
 
 # Roll your own File::Find!
-sub _find_tests {
-    my($dir) = @_;
-    opendir DIR, $dir or die "Trouble opening $dir: $!";
-    foreach my $f (sort { $a cmp $b } readdir DIR) {
-       next if $skip{$f};
-
-       my $fullpath = "$dir/$f";
-
-       if (-d $fullpath) {
-           _find_tests($fullpath);
-       } elsif ($f =~ /\.t$/) {
-           push @ARGV, $fullpath;
+sub _find_tests { our @found=(); push @ARGV, _find_files('\.t$', $_[0]) }
+sub _find_files {
+    my($patt, @dirs) = @_;
+    for my $dir (@dirs) {
+       opendir DIR, $dir or die "Trouble opening $dir: $!";
+       foreach my $f (sort { $a cmp $b } readdir DIR) {
+           next if $skip{$f};
+
+           my $fullpath = "$dir/$f";
+           
+           if (-d $fullpath) {
+               _find_files($patt, $fullpath);
+           } elsif ($f =~ /$patt/) {
+               push @found, $fullpath;
+           }
        }
     }
+    @found;
 }
 
 
@@ -419,10 +430,13 @@ unless (@ARGV) {
     # then comp, to validate that require works
     # then run, to validate that -M works
     # then we know we can -MTestInit for everything else, making life simpler
-    foreach my $dir (qw(base comp run cmd io re op uni mro)) {
+    foreach my $dir (qw(base comp run cmd io re opbasic op uni mro)) {
        _find_tests($dir);
     }
-    _find_tests("lib") unless $::core;
+    unless ($::core) {
+       _find_tests('porting');
+       _find_tests("lib"); 
+    }
     # Config.pm may be broken for make minitest. And this is only a refinement
     # for skipping tests on non-default builds, so it is allowed to fail.
     # What we want to to is make a list of extensions which we did not build.
@@ -452,9 +466,9 @@ unless (@ARGV) {
     push @ARGV, _tests_from_manifest($extensions, $known_extensions);
     unless ($::core) {
        _find_tests('x2p');
-       _find_tests('porting');
        _find_tests('japh') if $::torture;
        _find_tests('t/benchmark') if $::benchmark or $ENV{PERL_BENCHMARK};
+       _find_tests('bigmem') if $ENV{PERL_TEST_MEMORY};
     }
 }
 
@@ -522,6 +536,7 @@ EOT
     my $tested_files  = 0;
     my $totmax = 0;
     my %failed_tests;
+    my $toolnm;                # valgrind, cachegrind, perf
 
     while (my $test = shift @tests) {
         my ($test_start_time, @starttimes) = 0;
@@ -533,7 +548,7 @@ EOT
            # in BEGIN/END blocks (giving better visibility of self vs
            # children of each testprog), but that would require some
            # IPC to send results back here, or a completely different
-           # collection scheme (Storable isnt tuned for incremental use)
+           # collection scheme (Storable isn't tuned for incremental use)
            @starttimes = times;
        }
        if ($test =~ /^$/) {
@@ -571,9 +586,9 @@ EOT
            next if /^\s*$/; # skip blank lines
            if (/^1..$/ && ($^O eq 'VMS')) {
                # VMS pipe bug inserts blank lines.
-               my $l2 = <RESULTS>;
+               my $l2 = <$results>;
                if ($l2 =~ /^\s*$/) {
-                   $l2 = <RESULTS>;
+                   $l2 = <$results>;
                }
                $_ = '1..' . $l2;
            }
@@ -658,7 +673,7 @@ EOT
        }
 
        if ($ENV{PERL_VALGRIND}) {
-           my $toolnm = $ENV{VALGRIND};
+           $toolnm = $ENV{VALGRIND};
            $toolnm =~ s|.*/||;  # keep basename
            my @valgrind;       # gets content of file
            if (-e $Valgrind_Log) {
@@ -842,6 +857,12 @@ SHRDLU_5
     if ($ENV{PERL_VALGRIND}) {
        my $s = $grind_ct == 1 ? '' : 's';
        print "$grind_ct valgrind report$s created.\n", ;
+       if ($toolnm eq 'cachegrind') {
+           # cachegrind leaves a lot of cachegrind.out.$pid litter
+           # around the tree, find and delete them
+           unlink _find_files('cachegrind.out.\d+$',
+                            qw ( ../t ../cpan ../ext ../dist/ ));
+       }
     }
 }
 exit ($::bad_files != 0);