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}) {
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
48 @ARGV = split(/[ \n]/,
49 `echo base/*.t comp/*.t cmd/*.t run/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t pod/*.t camel-III/*.t`);
52 # %infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 );
55 _testprogs('deparse', @ARGV);
57 _testprogs('perl', @ARGV);
58 _testprogs('compile', @ARGV) if (-e "../testcompile");
66 print <<'EOT' if ($type eq 'compile');
67 --------------------------------------------------------------------------------
69 --------------------------------------------------------------------------------
72 print <<'EOT' if ($type eq 'deparse');
73 --------------------------------------------------------------------------------
75 --------------------------------------------------------------------------------
78 $ENV{PERLCC_TIMEOUT} = 120
79 if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT});
89 $maxlen = $len if $len > $maxlen;
91 # +3 : we want three dots between the test name and the "ok"
93 $dotdotdot = $maxlen + 3 - 2;
94 while ($test = shift @tests) {
96 if ( $infinite{$test} && $type eq 'compile' ) {
97 print STDERR "$test creates infinite loop! Skipping.\n";
103 if ($type eq 'deparse') {
104 if ($test eq "comp/redef.t") {
105 # Redefinition happens at compile time
108 elsif ($test eq "lib/switch.t") {
109 # B::Deparse doesn't support source filtering
115 print "$te" . '.' x ($dotdotdot - length($te));
117 open(SCRIPT,"<$test") or die "Can't run $test.\n";
119 close(SCRIPT) unless ($type eq 'deparse');
120 if (/#!.*perl(.*)$/) {
123 # Must protect uppercase switches with "" on command line
124 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
132 if ($type eq 'deparse') {
133 # Look for #line directives which change the filename
135 $file_opts .= ",-f$3$4"
136 if /^#\s*line\s+(\d+)\s+((\w+)|"([^"]+)")/;
140 my $utf = $with_utf ? '-I../lib -Mutf8'
142 my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC
143 if ($type eq 'deparse') {
145 "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,".
146 "-l$deparse_opts$file_opts ".
147 "./$test > ./$test.dp ".
148 "&& ./perl $testswitch $switch -I../lib ./$test.dp |";
149 open(RESULTS, $deparse)
150 or print "can't deparse '$deparse': $!.\n";
152 elsif ($type eq 'perl') {
153 my $run = "./perl $testswitch $switch $utf $test |";
154 open(RESULTS,$run) or print "can't run '$run': $!.\n";
158 "./perl $testswitch -I../lib ../utils/perlcc -o ".
159 "./$test.plc $utf ./$test ".
161 open(RESULTS, $compile)
162 or print "can't compile '$compile': $!.\n";
163 unlink "./$test.plc";
173 if (/^1\.\.([0-9]+)/) {
181 if (/^(not )?ok (\d+)(\s*#.*)?/ &&
184 my($not, $num, $extra) = ($1, $2, $3);
185 my($istodo) = $extra =~ /^\s*#\s*TODO/ if $extra;
187 if( $not && !$istodo ) {
196 elsif (/^Bail out!\s*(.*)/i) { # magic words
197 die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
206 if ($type eq 'deparse') {
209 if ($ENV{PERL_3LOG}) {
213 rename("perl.3log", "perl.3log.$tpp");
216 if ($ok && $next == $max) {
222 print "skipping test on this platform\n";
228 print "FAILED at test $next\n";
232 die "Failed a basic test--cannot continue.\n";
239 print "All tests successful.\n";
240 # XXX add mention of 'perlbug -ok' ?
243 die "FAILED--no tests were run for some reason.\n";
247 $pct = $files ? sprintf("%.2f", ($files - $bad) / $files * 100) : "0.00";
249 warn "Failed 1 test script out of $files, $pct% okay.\n";
252 warn "Failed $bad test scripts out of $files, $pct% okay.\n";
255 ### Since not all tests were successful, you may want to run some
256 ### of them individually and examine any diagnostic messages they
257 ### produce. See the INSTALL document's section on "make test".
258 ### If you are testing the compiler, then ignore this message
261 ### in the directory ./t.
263 warn <<'SHRDLU' if $good / $total > 0.8;
265 ### Since most tests were successful, you have a good chance to
266 ### get information with better granularity by running
268 ### in directory ./t.
271 ($user,$sys,$cuser,$csys) = times;
272 print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
273 $user,$sys,$cuser,$csys,$files,$totmax);