This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Regen doc with perlmodstyle added.
[perl5.git] / t / harness
CommitLineData
a5f75d66
AD
1#!./perl
2
3# We suppose that perl _mostly_ works at this moment, so may use
4# sophisticated testing.
5
aa689395
PP
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
a5f75d66
AD
12use Test::Harness;
13
ef712cf7 14$Test::Harness::switches = ""; # Too much noise otherwise
90ce63d5 15$Test::Harness::verbose = shift if @ARGV && $ARGV[0] eq '-v';
a5f75d66 16
0ca04487
VB
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
0ca04487
VB
31 );
32
33foreach (keys %datahandle) {
34 unlink "$_.t";
35}
36
122a0375
PK
37my @tests = ();
38
7a315204
JH
39if (@ARGV) {
40 @tests = @ARGV;
41} else {
b695f709 42 unless (@tests) {
122a0375
PK
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>;
b695f709
JH
50 use File::Spec;
51 my $updir = File::Spec->updir;
122a0375 52 my $mani = File::Spec->catfile(File::Spec->updir, "MANIFEST");
b695f709
JH
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!) {
122a0375 56 push @tests, File::Spec->catfile($updir, $1);
b695f709 57 }
7a315204 58 }
b695f709
JH
59 } else {
60 warn "$0: cannot open $mani: $!\n";
7a315204 61 }
b695f709 62 push @tests, <pod/*.t>;
7a315204
JH
63 }
64}
52cebf5e 65
a5f75d66 66Test::Harness::runtests @tests;
56eca212
GS
67exit(0) unless -e "../testcompile";
68
e4f0d88d
EP
69# %infinite = qw (
70# op/bop.t 1
71# lib/hostname.t 1
72# op/lex_assign.t 1
595ae481 73# lib/ph.t 1
e4f0d88d 74# );
56eca212
GS
75
76my $dhwrapper = <<'EOT';
77open DATA,"<".__FILE__;
78until (($_=<DATA>) =~ /^__END__/) {};
79EOT
52cebf5e
EP
80
81@tests = grep (!$infinite{$_}, @tests);
56eca212 82@tests = map {
ef712cf7 83 my $new = $_;
adac82c7 84 if ($datahandle{$_} && !( -f "$new.t") ) {
ef712cf7
EP
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
96print "The tests ", join(' ', keys(%infinite)),
97 " generate infinite loops! Skipping!\n";
98
595ae481 99$ENV{'HARNESS_COMPILE_TEST'} = 1;
9636a016 100$ENV{'PERLCC_TIMEOUT'} = 120 unless $ENV{'PERLCC_TIMEOUT'};
ef712cf7 101
595ae481 102Test::Harness::runtests @tests;
56eca212
GS
103foreach (keys %datahandle) {
104 unlink "$_.t";
52cebf5e 105}