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 # 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 (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 pragma lib pod)) {
73 # %infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 );
77 _testprogs('deparse', @ARGV);
79 _testprogs('perl', @ARGV);
80 _testprogs('compile', @ARGV) if (-e "../testcompile");
88 print <<'EOT' if ($type eq 'compile');
89 --------------------------------------------------------------------------------
91 --------------------------------------------------------------------------------
94 print <<'EOT' if ($type eq 'deparse');
95 --------------------------------------------------------------------------------
97 --------------------------------------------------------------------------------
100 $ENV{PERLCC_TIMEOUT} = 120
101 if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT});
111 $maxlen = $len if $len > $maxlen;
113 # +3 : we want three dots between the test name and the "ok"
115 $dotdotdot = $maxlen + 3 - 2;
116 while ($test = shift @tests) {
118 if ( $infinite{$test} && $type eq 'compile' ) {
119 print STDERR "$test creates infinite loop! Skipping.\n";
125 if ($type eq 'deparse') {
126 if ($test eq "comp/redef.t") {
127 # Redefinition happens at compile time
130 elsif ($test eq "lib/switch.t") {
131 # B::Deparse doesn't support source filtering
137 print "$te" . '.' x ($dotdotdot - length($te));
139 open(SCRIPT,"<$test") or die "Can't run $test.\n";
141 close(SCRIPT) unless ($type eq 'deparse');
142 if (/#!.*perl(.*)$/) {
145 # Must protect uppercase switches with "" on command line
146 $switch =~ s/-([A-Z]\S*)/"-$1"/g;
154 if ($type eq 'deparse') {
155 # Look for #line directives which change the filename
157 $file_opts .= ",-f$3$4"
158 if /^#\s*line\s+(\d+)\s+((\w+)|"([^"]+)")/;
162 my $utf = $with_utf ? '-I../lib -Mutf8'
164 my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC
165 if ($type eq 'deparse') {
167 "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,".
168 "-l$deparse_opts$file_opts ".
169 "./$test > ./$test.dp ".
170 "&& ./perl $testswitch $switch -I../lib ./$test.dp |";
171 open(RESULTS, $deparse)
172 or print "can't deparse '$deparse': $!.\n";
174 elsif ($type eq 'perl') {
175 my $run = "./perl $testswitch $switch $utf $test |";
176 open(RESULTS,$run) or print "can't run '$run': $!.\n";
180 "./perl $testswitch -I../lib ../utils/perlcc -o ".
181 "./$test.plc $utf ./$test ".
183 open(RESULTS, $compile)
184 or print "can't compile '$compile': $!.\n";
185 unlink "./$test.plc";
195 if (/^1\.\.([0-9]+)/) {
203 if (/^(not )?ok (\d+)(\s*#.*)?/ &&
206 my($not, $num, $extra) = ($1, $2, $3);
207 my($istodo) = $extra =~ /^\s*#\s*TODO/ if $extra;
209 if( $not && !$istodo ) {
218 elsif (/^Bail out!\s*(.*)/i) { # magic words
219 die "FAILED--Further testing stopped" . ($1 ? ": $1\n" : ".\n");
228 if ($type eq 'deparse') {
231 if ($ENV{PERL_3LOG}) {
235 rename("perl.3log", "perl.3log.$tpp");
238 if ($ok && $next == $max) {
244 print "skipping test on this platform\n";
250 print "FAILED at test $next\n";
254 die "Failed a basic test--cannot continue.\n";
261 print "All tests successful.\n";
262 # XXX add mention of 'perlbug -ok' ?
265 die "FAILED--no tests were run for some reason.\n";
269 $pct = $files ? sprintf("%.2f", ($files - $bad) / $files * 100) : "0.00";
271 warn "Failed 1 test script out of $files, $pct% okay.\n";
274 warn "Failed $bad test scripts out of $files, $pct% okay.\n";
277 ### Since not all tests were successful, you may want to run some
278 ### of them individually and examine any diagnostic messages they
279 ### produce. See the INSTALL document's section on "make test".
280 ### If you are testing the compiler, then ignore this message
283 ### in the directory ./t.
285 warn <<'SHRDLU' if $good / $total > 0.8;
287 ### Since most tests were successful, you have a good chance to
288 ### get information with better granularity by running
290 ### in directory ./t.
293 ($user,$sys,$cuser,$csys) = times;
294 print sprintf("u=%g s=%g cu=%g cs=%g scripts=%d tests=%d\n",
295 $user,$sys,$cuser,$csys,$files,$totmax);