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 $test = $OVER{$test} if exists $OVER{$test};
187 my $utf = $with_utf ? '-I../lib -Mutf8' : '';
188 my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC
189 if ($type eq 'deparse') {
191 "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,".
192 "-l$deparse_opts$file_opts ".
194 "&& ./perl $testswitch $switch -I../lib $test.dp |";
195 open(RESULTS, $deparse)
196 or print "can't deparse '$deparse': $!.\n";
198 elsif ($type eq 'perl') {
199 my $perl = $ENV{PERL} || './perl';
200 my $run = "$perl $testswitch $switch $utf $test |";
201 open(RESULTS,$run) or print "can't run '$run': $!.\n";
205 "./perl $testswitch -I../lib ../utils/perlcc -o ".
206 "$test.plc $utf $test ".
208 open(RESULTS, $compile)
209 or print "can't compile '$compile': $!.\n";
220 if (/^1\.\.([0-9]+)( todo ([\d ]+))?/) {
222 %todo = map { $_ => 1 } split / /, $3 if $3;
229 if (/^(not )?ok (\d+)(\s*#.*)?/ &&
232 my($not, $num, $extra) = ($1, $2, $3);
233 my($istodo) = $extra =~ /^\s*#\s*TODO/ if $extra;
234 $istodo = 1 if $todo{$num};
236 if( $not && !$istodo ) {
245 elsif (/^Bail out!\s*(.*)/i) { # magic words
246 die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
255 if ($type eq 'deparse') {
258 if ($ENV{PERL_3LOG}) {
263 rename("perl.3log", "perl.3log.$tpp") ||
264 die "rename: perl3.log to perl.3log.$tpp: $!\n";
267 if ($ok && $next == $max) {
273 print "skipping test on this platform\n";
279 print "FAILED at test $next\n";
283 die "Failed a basic test--cannot continue.\n";
290 print "All tests successful.\n";
291 # XXX add mention of 'perlbug -ok' ?
294 die "FAILED--no tests were run for some reason.\n";
298 $pct = $files ? sprintf("%.2f", ($files - $bad) / $files * 100) : "0.00";
300 warn "Failed 1 test script out of $files, $pct% okay.\n";
303 warn "Failed $bad test scripts out of $files, $pct% okay.\n";
306 ### Since not all tests were successful, you may want to run some
307 ### of them individually and examine any diagnostic messages they
308 ### produce. See the INSTALL document's section on "make test".
309 ### If you are testing the compiler, then ignore this message
312 ### in the directory ./t.
314 warn <<'SHRDLU' if $good / $total > 0.8;
316 ### Since most tests were successful, you have a good chance to
317 ### get information with better granularity by running
319 ### in directory ./t.
322 ($user,$sys,$cuser,$csys) = times;
323 print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
324 $user,$sys,$cuser,$csys,$files,$totmax);