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