3 # This is written in a peculiar style, since we're trying to avoid
4 # most of the constructs we'll be testing for.
8 # Cheesy version of Getopt::Std. Maybe we should replace it with that.
10 foreach my $idx (0..$#ARGV) {
11 next unless $ARGV[$idx] =~ /^-(\S+)$/;
12 $verbose = 1 if $1 eq 'v';
13 $with_utf= 1 if $1 eq 'utf8';
14 if ($1 =~ /^deparse(,.+)?$/) {
18 splice(@ARGV, $idx, 1);
22 chdir 't' if -f 't/TEST';
24 die "You need to run \"make test\" first to set things up.\n"
25 unless -e 'perl' or -e 'perl.exe';
27 if ($ENV{PERL_3LOG}) { # Tru64 third(1) tool, see perlhack
28 unless (-x 'perl.third') {
29 unless (-x '../perl.third') {
30 die "You need to run \"make perl.third first.\n";
33 print "Symlinking ../perl.third as perl.third...\n";
34 die "Failed to symlink: $!\n"
35 unless symlink("../perl.third", "perl.third");
36 die "Symlinked but no executable perl.third: $!\n"
37 unless -x 'perl.third';
42 # check leakage for embedders
43 $ENV{PERL_DESTRUCT_LEVEL} = 2 unless exists $ENV{PERL_DESTRUCT_LEVEL};
45 $ENV{EMXSHELL} = 'sh'; # For OS/2
47 # Roll your own File::Find!
50 my $curdir = File::Spec->curdir;
51 my $updir = File::Spec->updir;
55 opendir DIR, $dir || die "Trouble opening $dir: $!";
56 foreach my $f (sort { $a cmp $b } readdir DIR) {
57 next if $f eq $curdir or $f eq $updir;
59 my $fullpath = File::Spec->catdir($dir, $f);
61 _find_tests($fullpath) if -d $fullpath;
62 push @ARGV, $fullpath if $f =~ /\.t$/;
67 foreach my $dir (qw(base comp cmd run io op pragma lib pod)) {
70 my $mani = File::Spec->catdir($updir, "MANIFEST");
71 if (open(MANI, $mani)) {
72 while (<MANI>) { # similar code in t/harness
73 if (m!^(ext/.+/([^/]+\.t|test\.pl)|lib/.+(\.t|test\.pl))\s!) {
75 $OVER{$1} = File::Spec->catdir($updir, $1);
79 warn "$0: cannot open $mani: $!\n";
83 # Tests known to cause infinite loops for the perlcc tests.
84 # %infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 );
88 _testprogs('deparse', @ARGV);
90 _testprogs('perl', @ARGV);
91 _testprogs('compile', @ARGV) if (-e "../testcompile");
98 print <<'EOT' if ($type eq 'compile');
99 ------------------------------------------------------------------------------
101 ------------------------------------------------------------------------------
104 print <<'EOT' if ($type eq 'deparse');
105 ------------------------------------------------------------------------------
107 ------------------------------------------------------------------------------
110 $ENV{PERLCC_TIMEOUT} = 120
111 if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT});
120 foreach (@tests) { # The same code in lib/Test/Harness.pm:_run_all_tests
121 my $suf = /\.(\w+)$/ ? $1 : '';
123 my $suflen = length $suf;
124 $maxlen = $len if $len > $maxlen;
125 $maxsuflen = $suflen if $suflen > $maxsuflen;
127 # + 3 : we want three dots between the test name and the "ok"
128 $dotdotdot = $maxlen + 3 - $maxsuflen;
129 while ($test = shift @tests) {
131 if ( $infinite{$test} && $type eq 'compile' ) {
132 print STDERR "$test creates infinite loop! Skipping.\n";
138 if ($type eq 'deparse') {
139 if ($test eq "comp/redef.t") {
140 # Redefinition happens at compile time
143 elsif ($test eq "lib/switch.t") {
144 # B::Deparse doesn't support source filtering
150 print "$te" . '.' x ($dotdotdot - length($te));
152 $test = $OVER{$test} if exists $OVER{$test};
154 open(SCRIPT,"<$test") or die "Can't run $test.\n";
156 close(SCRIPT) unless ($type eq 'deparse');
157 if (/#!.*perl(.*)$/) {
160 # Must protect uppercase switches with "" on command line
161 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
169 if ($type eq 'deparse') {
170 # Look for #line directives which change the filename
172 $file_opts .= ",-f$3$4"
173 if /^#\s*line\s+(\d+)\s+((\w+)|"([^"]+)")/;
178 $test = $OVER{$test} if exists $OVER{$test};
180 my $utf = $with_utf ? '-I../lib -Mutf8' : '';
181 my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC
182 if ($type eq 'deparse') {
184 "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,".
185 "-l$deparse_opts$file_opts ".
187 "&& ./perl $testswitch $switch -I../lib $test.dp |";
188 open(RESULTS, $deparse)
189 or print "can't deparse '$deparse': $!.\n";
191 elsif ($type eq 'perl') {
192 my $run = "./perl $testswitch $switch $utf $test |";
193 open(RESULTS,$run) or print "can't run '$run': $!.\n";
197 "./perl $testswitch -I../lib ../utils/perlcc -o ".
198 "$test.plc $utf $test ".
200 open(RESULTS, $compile)
201 or print "can't compile '$compile': $!.\n";
212 if (/^1\.\.([0-9]+)( todo ([\d ]+))?/) {
214 %todo = map { $_ => 1 } split / /, $3 if $3;
221 if (/^(not )?ok (\d+)(\s*#.*)?/ &&
224 my($not, $num, $extra) = ($1, $2, $3);
225 my($istodo) = $extra =~ /^\s*#\s*TODO/ if $extra;
226 $istodo = 1 if $todo{$num};
228 if( $not && !$istodo ) {
237 elsif (/^Bail out!\s*(.*)/i) { # magic words
238 die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
247 if ($type eq 'deparse') {
250 if ($ENV{PERL_3LOG}) {
254 rename("perl.3log", "perl.3log.$tpp");
257 if ($ok && $next == $max) {
263 print "skipping test on this platform\n";
269 print "FAILED at test $next\n";
273 die "Failed a basic test--cannot continue.\n";
280 print "All tests successful.\n";
281 # XXX add mention of 'perlbug -ok' ?
284 die "FAILED--no tests were run for some reason.\n";
288 $pct = $files ? sprintf("%.2f", ($files - $bad) / $files * 100) : "0.00";
290 warn "Failed 1 test script out of $files, $pct% okay.\n";
293 warn "Failed $bad test scripts out of $files, $pct% okay.\n";
296 ### Since not all tests were successful, you may want to run some
297 ### of them individually and examine any diagnostic messages they
298 ### produce. See the INSTALL document's section on "make test".
299 ### If you are testing the compiler, then ignore this message
302 ### in the directory ./t.
304 warn <<'SHRDLU' if $good / $total > 0.8;
306 ### Since most tests were successful, you have a good chance to
307 ### get information with better granularity by running
309 ### in directory ./t.
312 ($user,$sys,$cuser,$csys) = times;
313 print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
314 $user,$sys,$cuser,$csys,$files,$totmax);