Change the scan policy of the *.t and test.pl files,
[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';
93430cb4 8 unshift @INC, '../lib';
ef712cf7 9 $ENV{PERL5LIB} = '../lib'; # so children will see it too
aa689395 10}
a5f75d66 11use lib '../lib';
aa689395 12
a5f75d66 13use Test::Harness;
14
ef712cf7 15$Test::Harness::switches = ""; # Too much noise otherwise
90ce63d5 16$Test::Harness::verbose = shift if @ARGV && $ARGV[0] eq '-v';
a5f75d66 17
0ca04487 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 pragma/subs.t 1
33 );
34
35foreach (keys %datahandle) {
36 unlink "$_.t";
37}
38
7a315204 39if (@ARGV) {
40 @tests = @ARGV;
41} else {
42 @tests = <base/*.t comp/*.t cmd/*.t io/*.t op/*.t pragma/*.t lib/*.t pod/*.t> unless @tests;
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)) {
80ffb5f9 47 while (<MANI>) { # similar code in t/TEST
48 if (m!^(ext/.+/([^/]+\.t|test\.pl)|lib/.+(\.t|test\.pl))\s!) {
7a315204 49 push @tests, File::Spec->catdir($updir, $1);
50 }
51 }
52 } else {
53 warn "$0: cannot open $mani: $!\n";
54 }
55}
52cebf5e 56
a5f75d66 57Test::Harness::runtests @tests;
56eca212 58exit(0) unless -e "../testcompile";
59
e4f0d88d 60# %infinite = qw (
61# op/bop.t 1
62# lib/hostname.t 1
63# op/lex_assign.t 1
595ae481 64# lib/ph.t 1
e4f0d88d 65# );
56eca212 66
67my $dhwrapper = <<'EOT';
68open DATA,"<".__FILE__;
69until (($_=<DATA>) =~ /^__END__/) {};
70EOT
52cebf5e 71
72@tests = grep (!$infinite{$_}, @tests);
56eca212 73@tests = map {
ef712cf7 74 my $new = $_;
adac82c7 75 if ($datahandle{$_} && !( -f "$new.t") ) {
ef712cf7 76 $new .= '.t';
77 local(*F, *T);
78 open(F,"<$_") or die "Can't open $_: $!";
79 open(T,">$new") or die "Can't open $new: $!";
80 print T $dhwrapper, <F>;
81 close F;
82 close T;
83 }
84 $new;
85 } @tests;
86
87print "The tests ", join(' ', keys(%infinite)),
88 " generate infinite loops! Skipping!\n";
89
595ae481 90$ENV{'HARNESS_COMPILE_TEST'} = 1;
9636a016 91$ENV{'PERLCC_TIMEOUT'} = 120 unless $ENV{'PERLCC_TIMEOUT'};
ef712cf7 92
595ae481 93Test::Harness::runtests @tests;
56eca212 94foreach (keys %datahandle) {
95 unlink "$_.t";
52cebf5e 96}