This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
chr(42) ne '*' if one is in EBCDIC.
[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 # Let tests know they're running in the perl core.  Useful for modules
18 # which live dual lives on CPAN.
19 $ENV{PERL_CORE} = 1;
20
21 #fudge DATA for now.
22 %datahandle = qw(
23                 lib/bigint.t            1
24                 lib/bigintpm.t          1
25                 lib/bigfloat.t          1
26                 lib/bigfloatpm.t        1
27                 op/gv.t                 1
28                 lib/complex.t           1
29                 lib/ph.t                1
30                 lib/soundex.t           1
31                 op/misc.t               1
32                 op/runlevel.t           1
33                 op/tie.t                1
34                 op/lex_assign.t         1
35                 );
36
37 foreach (keys %datahandle) {
38      unlink "$_.t";
39 }
40
41 my @tests = ();
42
43 if (@ARGV) {
44     if ($^O eq 'MSWin32') {
45         @tests = map(glob($_),@ARGV);
46     }
47     else {
48         @tests = @ARGV;
49     }
50 } else {
51     unless (@tests) {
52         push @tests, <base/*.t>;
53         push @tests, <comp/*.t>;
54         push @tests, <cmd/*.t>;
55         push @tests, <run/*.t>;
56         push @tests, <io/*.t>;
57         push @tests, <op/*.t>;
58         push @tests, <uni/*.t>;
59         push @tests, <lib/*.t>;
60         use File::Spec;
61         my $updir = File::Spec->updir;
62         my $mani  = File::Spec->catfile(File::Spec->updir, "MANIFEST");
63         if (open(MANI, $mani)) {
64             while (<MANI>) { # similar code in t/TEST
65             if (m!^(ext/\S+/([^/]+\.t|test\.pl)|lib/\S+?(\.t|test\.pl))\s!) {
66                     push @tests, File::Spec->catfile($updir, $1);
67                 }
68             }
69         } else {
70             warn "$0: cannot open $mani: $!\n";
71         }
72         push @tests, <pod/*.t>;
73     }
74 }
75
76 Test::Harness::runtests @tests;
77 exit(0) unless -e "../testcompile";
78
79 # %infinite =  qw (
80 #        op/bop.t       1
81 #        lib/hostname.t 1
82 #        op/lex_assign.t        1
83 #        lib/ph.t       1
84 #        );
85
86 my $dhwrapper = <<'EOT';
87 open DATA,"<".__FILE__;
88 until (($_=<DATA>) =~ /^__END__/) {};
89 EOT
90
91 @tests = grep (!$infinite{$_}, @tests);
92 @tests = map {
93          my $new = $_;
94          if ($datahandle{$_} && !( -f "$new.t") ) {
95              $new .= '.t';
96              local(*F, *T);
97              open(F,"<$_") or die "Can't open $_: $!";
98              open(T,">$new") or die "Can't open $new: $!";
99              print T $dhwrapper, <F>;
100              close F;
101              close T;
102          }
103          $new;
104          } @tests;
105
106 print "The tests ", join(' ', keys(%infinite)),
107     " generate infinite loops! Skipping!\n";
108
109 $ENV{'HARNESS_COMPILE_TEST'} = 1;
110 $ENV{'PERLCC_TIMEOUT'} = 120 unless $ENV{'PERLCC_TIMEOUT'};
111
112 Test::Harness::runtests @tests;
113 foreach (keys %datahandle) {
114      unlink "$_.t";
115 }