This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
The test.third results were funnily named because of the
[perl5.git] / t / harness
1 #!./perl
2
3 # We suppose that perl _mostly_ works at this moment, so may use
4 # sophisticated testing.
5
6 BEGIN {
7     chdir 't' if -d 't';
8     unshift @INC, '../lib';
9     $ENV{PERL5LIB} = '../lib';    # so children will see it too
10 }
11 use lib '../lib';
12
13 use Test::Harness;
14
15 $Test::Harness::switches = "";    # Too much noise otherwise
16 $Test::Harness::verbose = shift if @ARGV && $ARGV[0] eq '-v';
17
18 #fudge DATA for now.
19 %datahandle = qw(
20                 lib/bigint.t            1
21                 lib/bigintpm.t          1
22                 lib/bigfloat.t          1
23                 lib/bigfloatpm.t        1
24                 op/gv.t                 1
25                 lib/complex.t           1
26                 lib/ph.t                1
27                 lib/soundex.t           1
28                 op/misc.t               1
29                 op/runlevel.t           1
30                 op/tie.t                1
31                 op/lex_assign.t         1
32                 );
33
34 foreach (keys %datahandle) {
35      unlink "$_.t";
36 }
37
38 if (@ARGV) {
39     @tests = @ARGV;
40 } else {
41     unless (@tests) {
42         @tests = <base/*.t comp/*.t cmd/*.t io/*.t op/*.t lib/*.t>;
43         use File::Spec;
44         my $updir = File::Spec->updir;
45         my $mani  = File::Spec->catdir(File::Spec->updir, "MANIFEST");
46         if (open(MANI, $mani)) {
47             while (<MANI>) { # similar code in t/TEST
48             if (m!^(ext/\S+/([^/]+\.t|test\.pl)|lib/\S+?(\.t|test\.pl))\s!) {
49                     push @tests, File::Spec->catdir($updir, $1);
50                 }
51             }
52         } else {
53             warn "$0: cannot open $mani: $!\n";
54         }
55         push @tests, <pod/*.t>;
56     }
57 }
58
59 Test::Harness::runtests @tests;
60 exit(0) unless -e "../testcompile";
61
62 # %infinite =  qw (
63 #        op/bop.t       1
64 #        lib/hostname.t 1
65 #        op/lex_assign.t        1
66 #        lib/ph.t       1
67 #        );
68
69 my $dhwrapper = <<'EOT';
70 open DATA,"<".__FILE__;
71 until (($_=<DATA>) =~ /^__END__/) {};
72 EOT
73
74 @tests = grep (!$infinite{$_}, @tests);
75 @tests = map {
76          my $new = $_;
77          if ($datahandle{$_} && !( -f "$new.t") ) {
78              $new .= '.t';
79              local(*F, *T);
80              open(F,"<$_") or die "Can't open $_: $!";
81              open(T,">$new") or die "Can't open $new: $!";
82              print T $dhwrapper, <F>;
83              close F;
84              close T;
85          }
86          $new;
87          } @tests;
88
89 print "The tests ", join(' ', keys(%infinite)),
90     " generate infinite loops! Skipping!\n";
91
92 $ENV{'HARNESS_COMPILE_TEST'} = 1;
93 $ENV{'PERLCC_TIMEOUT'} = 120 unless $ENV{'PERLCC_TIMEOUT'};
94
95 Test::Harness::runtests @tests;
96 foreach (keys %datahandle) {
97      unlink "$_.t";
98 }