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 $core = 1 if $1 eq 'core';
13 $verbose = 1 if $1 eq 'v';
14 $with_utf= 1 if $1 eq 'utf8';
15 if ($1 =~ /^deparse(,.+)?$/) {
19 splice(@ARGV, $idx, 1);
23 chdir 't' if -f 't/TEST';
25 die "You need to run \"make test\" first to set things up.\n"
26 unless -e 'perl' or -e 'perl.exe';
28 if ($ENV{PERL_3LOG}) { # Tru64 third(1) tool, see perlhack
29 unless (-x 'perl.third') {
30 unless (-x '../perl.third') {
31 die "You need to run \"make perl.third first.\n";
34 print "Symlinking ../perl.third as perl.third...\n";
35 die "Failed to symlink: $!\n"
36 unless symlink("../perl.third", "perl.third");
37 die "Symlinked but no executable perl.third: $!\n"
38 unless -x 'perl.third';
43 # check leakage for embedders
44 $ENV{PERL_DESTRUCT_LEVEL} = 2 unless exists $ENV{PERL_DESTRUCT_LEVEL};
46 $ENV{EMXSHELL} = 'sh'; # For OS/2
48 # Roll your own File::Find!
51 my $curdir = File::Spec->curdir;
52 my $updir = File::Spec->updir;
56 opendir DIR, $dir || die "Trouble opening $dir: $!";
57 foreach my $f (sort { $a cmp $b } readdir DIR) {
58 next if $f eq $curdir or $f eq $updir;
60 my $fullpath = File::Spec->catdir($dir, $f);
62 _find_tests($fullpath) if -d $fullpath;
63 push @ARGV, $fullpath if $f =~ /\.t$/;
68 foreach my $dir (qw(base comp cmd run io op)) {
71 _find_tests("lib") unless $core;
72 my $mani = File::Spec->catdir($updir, "MANIFEST");
73 if (open(MANI, $mani)) {
74 while (<MANI>) { # similar code in t/harness
75 if (m!^(ext/\S+/([^/]+\.t|test\.pl)|lib/\S+?(\.t|test\.pl))\s!) {
77 if (!$core || $t =~ m!^lib/[a-z]!)
79 $path = File::Spec->catdir($updir, $t);
86 warn "$0: cannot open $mani: $!\n";
91 # Tests known to cause infinite loops for the perlcc tests.
92 # %infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 );
96 _testprogs('deparse', @ARGV);
98 _testprogs('perl', @ARGV);
99 _testprogs('compile', @ARGV) if (-e "../testcompile");
106 print <<'EOT' if ($type eq 'compile');
107 ------------------------------------------------------------------------------
109 ------------------------------------------------------------------------------
112 print <<'EOT' if ($type eq 'deparse');
113 ------------------------------------------------------------------------------
115 ------------------------------------------------------------------------------
118 $ENV{PERLCC_TIMEOUT} = 120
119 if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT});
128 $name{$_} = File::Spec->catdir('t',$_) unless exists $name{$_};
131 foreach (@name{@tests}) {
134 $maxlen = $len if $len > $maxlen;
136 # + 3 : we want three dots between the test name and the "ok"
137 $dotdotdot = $maxlen + 3 ;
138 while ($test = shift @tests) {
140 if ( $infinite{$test} && $type eq 'compile' ) {
141 print STDERR "$test creates infinite loop! Skipping.\n";
147 if ($type eq 'deparse') {
148 if ($test eq "comp/redef.t") {
149 # Redefinition happens at compile time
152 elsif ($test eq "lib/switch.t") {
153 # B::Deparse doesn't support source filtering
158 print "$te" . '.' x ($dotdotdot - length($te));
160 $test = $OVER{$test} if exists $OVER{$test};
162 open(SCRIPT,"<$test") or die "Can't run $test.\n";
164 close(SCRIPT) unless ($type eq 'deparse');
165 if (/#!.*perl(.*)$/) {
168 # Must protect uppercase switches with "" on command line
169 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
177 if ($type eq 'deparse') {
178 # Look for #line directives which change the filename
180 $file_opts .= ",-f$3$4"
181 if /^#\s*line\s+(\d+)\s+((\w+)|"([^"]+)")/;
186 my $utf = $with_utf ? '-I../lib -Mutf8' : '';
187 my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC
188 if ($type eq 'deparse') {
190 "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,".
191 "-l$deparse_opts$file_opts ".
193 "&& ./perl $testswitch $switch -I../lib $test.dp |";
194 open(RESULTS, $deparse)
195 or print "can't deparse '$deparse': $!.\n";
197 elsif ($type eq 'perl') {
198 my $perl = $ENV{PERL} || './perl';
199 my $run = "$perl $testswitch $switch $utf $test |";
200 open(RESULTS,$run) or print "can't run '$run': $!.\n";
204 "./perl $testswitch -I../lib ../utils/perlcc -o ".
205 "$test.plc $utf $test ".
207 open(RESULTS, $compile)
208 or print "can't compile '$compile': $!.\n";
219 if (/^1\.\.([0-9]+)( todo ([\d ]+))?/) {
221 %todo = map { $_ => 1 } split / /, $3 if $3;
228 if (/^(not )?ok (\d+)[^#]*(\s*#.*)?/ &&
231 my($not, $num, $extra) = ($1, $2, $3);
232 my($istodo) = $extra =~ /^\s*#\s*TODO/ if $extra;
233 $istodo = 1 if $todo{$num};
235 if( $not && !$istodo ) {
244 elsif (/^Bail out!\s*(.*)/i) { # magic words
245 die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
254 if ($type eq 'deparse') {
257 if ($ENV{PERL_3LOG}) {
262 rename("perl.3log", "perl.3log.$tpp") ||
263 die "rename: perl3.log to perl.3log.$tpp: $!\n";
266 if ($ok && $next == $max) {
272 print "skipping test on this platform\n";
278 print "FAILED at test $next\n";
282 die "Failed a basic test--cannot continue.\n";
289 print "All tests successful.\n";
290 # XXX add mention of 'perlbug -ok' ?
293 die "FAILED--no tests were run for some reason.\n";
297 $pct = $files ? sprintf("%.2f", ($files - $bad) / $files * 100) : "0.00";
299 warn "Failed 1 test script out of $files, $pct% okay.\n";
302 warn "Failed $bad test scripts out of $files, $pct% okay.\n";
305 ### Since not all tests were successful, you may want to run some
306 ### of them individually and examine any diagnostic messages they
307 ### produce. See the INSTALL document's section on "make test".
308 ### If you are testing the compiler, then ignore this message
311 ### in the directory ./t.
313 warn <<'SHRDLU' if $good / $total > 0.8;
315 ### Since most tests were successful, you have a good chance to
316 ### get information with better granularity by running
318 ### in directory ./t.
321 ($user,$sys,$cuser,$csys) = times;
322 print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
323 $user,$sys,$cuser,$csys,$files,$totmax);