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] =~ /^-(\w+)$/;
12 $verbose = 1 if $1 eq 'v';
13 $with_utf= 1 if $1 eq 'utf8';
14 splice(@ARGV, $idx, 1);
18 chdir 't' if -f 't/TEST';
20 die "You need to run \"make test\" first to set things up.\n"
21 unless -e 'perl' or -e 'perl.exe';
23 # check leakage for embedders
24 $ENV{PERL_DESTRUCT_LEVEL} = 2 unless exists $ENV{PERL_DESTRUCT_LEVEL};
26 $ENV{EMXSHELL} = 'sh'; # For OS/2
29 @ARGV = split(/[ \n]/,
30 `echo base/*.t comp/*.t cmd/*.t run/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t`);
33 %infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 );
35 _testprogs('perl', @ARGV);
36 _testprogs('compile', @ARGV) if (-e "../testcompile");
43 print <<'EOT' if ($type eq 'compile');
44 --------------------------------------------------------------------------------
46 --------------------------------------------------------------------------------
49 $ENV{PERLCC_TIMEOUT} = 120
50 if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT});
60 $maxlen = $len if $len > $maxlen;
62 # +3 : we want three dots between the test name and the "ok"
64 $dotdotdot = $maxlen + 3 - 2;
65 while ($test = shift @tests) {
67 if ( $infinite{$test} && $type eq 'compile' ) {
68 print STDERR "$test creates infinite loop! Skipping.\n";
76 print "$te" . '.' x ($dotdotdot - length($te));
78 open(SCRIPT,"<$test") or die "Can't run $test.\n";
81 if (/#!.*perl(.*)$/) {
84 # Must protect uppercase switches with "" on command line
85 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
92 my $utf = $with_utf ? '-I../lib -Mutf8'
94 if ($type eq 'perl') {
95 my $run = "./perl$switch $utf $test |";
96 open(RESULTS,$run) or print "can't run '$run': $!.\n";
100 "./perl -I../lib ../utils/perlcc -o ./$test.plc $utf ./$test "
101 ." && ./$test.plc |";
102 open(RESULTS, $compile)
103 or print "can't compile '$compile': $!.\n";
104 unlink "./$test.plc";
114 if (/^1\.\.([0-9]+)/) {
122 if (/^(not )?ok (\d+)(\s*#.*)?/ &&
125 my($not, $num, $extra) = ($1, $2, $3);
126 my($istodo) = $extra =~ /^\s*#\s*TODO/ if $extra;
128 if( $not && !$istodo ) {
137 elsif (/^Bail out!\s*(.*)/i) { # magic words
138 die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
148 if ($ok && $next == $max) {
154 print "skipping test on this platform\n";
160 print "FAILED at test $next\n";
164 die "Failed a basic test--cannot continue.\n";
171 print "All tests successful.\n";
172 # XXX add mention of 'perlbug -ok' ?
175 die "FAILED--no tests were run for some reason.\n";
179 $pct = $files ? sprintf("%.2f", ($files - $bad) / $files * 100) : "0.00";
181 warn "Failed 1 test script out of $files, $pct% okay.\n";
184 warn "Failed $bad test scripts out of $files, $pct% okay.\n";
187 ### Since not all tests were successful, you may want to run some
188 ### of them individually and examine any diagnostic messages they
189 ### produce. See the INSTALL document's section on "make test".
190 ### If you are testing the compiler, then ignore this message
193 ### in the directory ./t.
195 warn <<'SHRDLU' if $good / $total > 0.8;
197 ### Since most tests were successful, you have a good chance to
198 ### get information with better granularity by running
200 ### in directory ./t.
203 ($user,$sys,$cuser,$csys) = times;
204 print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
205 $user,$sys,$cuser,$csys,$files,$totmax);