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]!)
80 $OVER{$t} = File::Spec->catdir($updir, $t);
85 warn "$0: cannot open $mani: $!\n";
90 # Tests known to cause infinite loops for the perlcc tests.
91 # %infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 );
95 _testprogs('deparse', @ARGV);
97 _testprogs('perl', @ARGV);
98 _testprogs('compile', @ARGV) if (-e "../testcompile");
105 print <<'EOT' if ($type eq 'compile');
106 ------------------------------------------------------------------------------
108 ------------------------------------------------------------------------------
111 print <<'EOT' if ($type eq 'deparse');
112 ------------------------------------------------------------------------------
114 ------------------------------------------------------------------------------
117 $ENV{PERLCC_TIMEOUT} = 120
118 if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT});
127 foreach (@tests) { # The same code in lib/Test/Harness.pm:_run_all_tests
128 my $suf = /\.(\w+)$/ ? $1 : '';
130 my $suflen = length $suf;
131 $maxlen = $len if $len > $maxlen;
132 $maxsuflen = $suflen if $suflen > $maxsuflen;
134 # + 3 : we want three dots between the test name and the "ok"
135 $dotdotdot = $maxlen + 3 - $maxsuflen;
136 while ($test = shift @tests) {
138 if ( $infinite{$test} && $type eq 'compile' ) {
139 print STDERR "$test creates infinite loop! Skipping.\n";
145 if ($type eq 'deparse') {
146 if ($test eq "comp/redef.t") {
147 # Redefinition happens at compile time
150 elsif ($test eq "lib/switch.t") {
151 # B::Deparse doesn't support source filtering
157 print "$te" . '.' x ($dotdotdot - length($te));
159 $test = $OVER{$test} if exists $OVER{$test};
161 open(SCRIPT,"<$test") or die "Can't run $test.\n";
163 close(SCRIPT) unless ($type eq 'deparse');
164 if (/#!.*perl(.*)$/) {
167 # Must protect uppercase switches with "" on command line
168 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
176 if ($type eq 'deparse') {
177 # Look for #line directives which change the filename
179 $file_opts .= ",-f$3$4"
180 if /^#\s*line\s+(\d+)\s+((\w+)|"([^"]+)")/;
185 my $utf = $with_utf ? '-I../lib -Mutf8' : '';
186 my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC
187 if ($type eq 'deparse') {
189 "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,".
190 "-l$deparse_opts$file_opts ".
192 "&& ./perl $testswitch $switch -I../lib $test.dp |";
193 open(RESULTS, $deparse)
194 or print "can't deparse '$deparse': $!.\n";
196 elsif ($type eq 'perl') {
197 my $perl = $ENV{PERL} || './perl';
198 my $run = "$perl $testswitch $switch $utf $test |";
199 open(RESULTS,$run) or print "can't run '$run': $!.\n";
203 "./perl $testswitch -I../lib ../utils/perlcc -o ".
204 "$test.plc $utf $test ".
206 open(RESULTS, $compile)
207 or print "can't compile '$compile': $!.\n";
218 if (/^1\.\.([0-9]+)( todo ([\d ]+))?/) {
220 %todo = map { $_ => 1 } split / /, $3 if $3;
227 if (/^(not )?ok (\d+)[^#]*(\s*#.*)?/ &&
230 my($not, $num, $extra) = ($1, $2, $3);
231 my($istodo) = $extra =~ /^\s*#\s*TODO/ if $extra;
232 $istodo = 1 if $todo{$num};
234 if( $not && !$istodo ) {
243 elsif (/^Bail out!\s*(.*)/i) { # magic words
244 die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
253 if ($type eq 'deparse') {
256 if ($ENV{PERL_3LOG}) {
261 rename("perl.3log", "perl.3log.$tpp") ||
262 die "rename: perl3.log to perl.3log.$tpp: $!\n";
265 if ($ok && $next == $max) {
271 print "skipping test on this platform\n";
277 print "FAILED at test $next\n";
281 die "Failed a basic test--cannot continue.\n";
288 print "All tests successful.\n";
289 # XXX add mention of 'perlbug -ok' ?
292 die "FAILED--no tests were run for some reason.\n";
296 $pct = $files ? sprintf("%.2f", ($files - $bad) / $files * 100) : "0.00";
298 warn "Failed 1 test script out of $files, $pct% okay.\n";
301 warn "Failed $bad test scripts out of $files, $pct% okay.\n";
304 ### Since not all tests were successful, you may want to run some
305 ### of them individually and examine any diagnostic messages they
306 ### produce. See the INSTALL document's section on "make test".
307 ### If you are testing the compiler, then ignore this message
310 ### in the directory ./t.
312 warn <<'SHRDLU' if $good / $total > 0.8;
314 ### Since most tests were successful, you have a good chance to
315 ### get information with better granularity by running
317 ### in directory ./t.
320 ($user,$sys,$cuser,$csys) = times;
321 print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
322 $user,$sys,$cuser,$csys,$files,$totmax);