Why quote some keys?
[p5sagit/p5-mst-13.2.git] / t / harness
CommitLineData
a5f75d66 1#!./perl
2
3# We suppose that perl _mostly_ works at this moment, so may use
4# sophisticated testing.
5
aa689395 6BEGIN {
7 chdir 't' if -d 't';
122a0375 8 @INC = '../lib'; # pick up only this build's lib
ef712cf7 9 $ENV{PERL5LIB} = '../lib'; # so children will see it too
aa689395 10}
aa689395 11
e018f8be 12my $torture; # torture testing?
13
a5f75d66 14use Test::Harness;
15
ef712cf7 16$Test::Harness::switches = ""; # Too much noise otherwise
90ce63d5 17$Test::Harness::verbose = shift if @ARGV && $ARGV[0] eq '-v';
a5f75d66 18
e018f8be 19if ($ARGV[0] eq '-torture') {
20 shift;
21 $torture = 1;
22}
23
60e23f2f 24# Let tests know they're running in the perl core. Useful for modules
25# which live dual lives on CPAN.
26$ENV{PERL_CORE} = 1;
27
0ca04487 28#fudge DATA for now.
29%datahandle = qw(
30 lib/bigint.t 1
31 lib/bigintpm.t 1
32 lib/bigfloat.t 1
33 lib/bigfloatpm.t 1
34 op/gv.t 1
35 lib/complex.t 1
36 lib/ph.t 1
37 lib/soundex.t 1
38 op/misc.t 1
39 op/runlevel.t 1
40 op/tie.t 1
41 op/lex_assign.t 1
0ca04487 42 );
43
44foreach (keys %datahandle) {
45 unlink "$_.t";
46}
47
122a0375 48my @tests = ();
49
7a315204 50if (@ARGV) {
4efb34a6 51 if ($^O eq 'MSWin32') {
52 @tests = map(glob($_),@ARGV);
53 }
54 else {
55 @tests = @ARGV;
56 }
7a315204 57} else {
b695f709 58 unless (@tests) {
122a0375 59 push @tests, <base/*.t>;
60 push @tests, <comp/*.t>;
61 push @tests, <cmd/*.t>;
62 push @tests, <run/*.t>;
63 push @tests, <io/*.t>;
64 push @tests, <op/*.t>;
37fca15e 65 push @tests, <uni/*.t>;
122a0375 66 push @tests, <lib/*.t>;
e018f8be 67 push @tests, <japh/*.t> if $torture;
bb27e7b6 68 push @tests, <win32/*.t> if $^O eq 'MSWin32';
b695f709 69 use File::Spec;
70 my $updir = File::Spec->updir;
122a0375 71 my $mani = File::Spec->catfile(File::Spec->updir, "MANIFEST");
b695f709 72 if (open(MANI, $mani)) {
73 while (<MANI>) { # similar code in t/TEST
f8166efe 74 if (m!^(ext/\S+/?([^/]+\.t|test\.pl)|lib/\S+?(\.t|test\.pl))\s!) {
122a0375 75 push @tests, File::Spec->catfile($updir, $1);
b695f709 76 }
7a315204 77 }
35d88760 78 close MANI;
b695f709 79 } else {
80 warn "$0: cannot open $mani: $!\n";
7a315204 81 }
b695f709 82 push @tests, <pod/*.t>;
7a315204 83 }
84}
22a65f1e 85if ($^O eq 'MSWin32') {
86 s,\\,/,g for @tests;
87}
a5f75d66 88Test::Harness::runtests @tests;
56eca212 89exit(0) unless -e "../testcompile";
90
e4f0d88d 91# %infinite = qw (
92# op/bop.t 1
93# lib/hostname.t 1
94# op/lex_assign.t 1
595ae481 95# lib/ph.t 1
e4f0d88d 96# );
56eca212 97
98my $dhwrapper = <<'EOT';
99open DATA,"<".__FILE__;
100until (($_=<DATA>) =~ /^__END__/) {};
101EOT
52cebf5e 102
103@tests = grep (!$infinite{$_}, @tests);
56eca212 104@tests = map {
ef712cf7 105 my $new = $_;
adac82c7 106 if ($datahandle{$_} && !( -f "$new.t") ) {
ef712cf7 107 $new .= '.t';
108 local(*F, *T);
109 open(F,"<$_") or die "Can't open $_: $!";
110 open(T,">$new") or die "Can't open $new: $!";
111 print T $dhwrapper, <F>;
112 close F;
113 close T;
114 }
115 $new;
116 } @tests;
117
118print "The tests ", join(' ', keys(%infinite)),
119 " generate infinite loops! Skipping!\n";
120
595ae481 121$ENV{'HARNESS_COMPILE_TEST'} = 1;
9636a016 122$ENV{'PERLCC_TIMEOUT'} = 120 unless $ENV{'PERLCC_TIMEOUT'};
ef712cf7 123
595ae481 124Test::Harness::runtests @tests;
56eca212 125foreach (keys %datahandle) {
126 unlink "$_.t";
52cebf5e 127}