6 $ENV{PERL5LIB} = '../lib';
7 require Config; import Config;
8 $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
13 my $Is_VMS = $^O eq 'VMS';
14 my $Is_MSWin32 = $^O eq 'MSWin32';
15 my $tmpfile = "tmp0000";
17 1 while -f ++$tmpfile;
18 END { if ($tmpfile) { 1 while unlink $tmpfile} }
24 { print "ARGV = [@ARGV]\n" ; @w_files = map { s#^#./pragma/warn/#; $_ } @ARGV }
26 { @w_files = sort glob("pragma/warn/*") }
30 next if /(~|\.orig|,v)$/;
32 open F, "<$_" or die "Cannot open $_: $!\n" ;
39 @prgs = (@prgs, split "\n########\n", <F>) ;
46 print "1..", scalar @prgs, "\n";
54 $switch =~ s/(-\S*[A-Z]\S*)/"$1"/ if $Is_VMS; # protect uc switches
56 my($prog,$expected) = split(/\nEXPECT\n/, $_);
57 if ( $prog =~ /--FILE--/) {
58 my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
60 die "Internal error test $i didn't split into pairs, got " .
61 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
64 my $filename = shift @files ;
65 my $code = shift @files ;
66 push @temps, $filename ;
67 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
72 $prog = shift @files ;
74 open TEST, ">$tmpfile";
75 print TEST $prog,"\n";
77 my $results = $Is_VMS ?
78 `./perl "-I../lib" $switch $tmpfile 2>&1` :
80 `.\\perl -I../lib $switch $tmpfile 2>&1` :
81 `./perl -I../lib $switch $tmpfile 2>&1`;
84 # allow expected output to be written as if $prog is on STDIN
85 $results =~ s/tmp\d+/-/g;
86 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
87 # bison says 'parse error' instead of 'syntax error',
88 # various yaccs may or may not capitalize 'syntax'.
89 $results =~ s/^(syntax|parse) error/syntax error/mig;
90 # allow all tests to run when there are leaks
91 $results =~ s/Scalars leaked: \d+\n//g;
92 $expected =~ s/\n+$//;
93 my $prefix = ($results =~ s#^PREFIX(\n|$)##) ;
94 # any special options? (OPTIONS foo bar zap)
96 if ($expected =~ s/^OPTIONS? (.+)\n//) {
97 foreach my $option (split(' ', $1)) {
98 if ($option eq 'regex') { # allow regular expressions
101 die "$0: Unknown OPTION '$option'\n";
105 if ( $results =~ s/^SKIPPED\n//) {
108 elsif (($prefix && (( $option_regex && $results !~ /^$expected/) ||
109 (!$option_regex && $results !~ /^\Q$expected/))) or
110 (!$prefix && (( $option_regex && $results !~ /^$expected/) ||
111 (!$option_regex && $results ne $expected)))) {
112 print STDERR "PROG: $switch\n$prog\n";
113 print STDERR "EXPECTED:\n$expected\n";
114 print STDERR "GOT:\n$results\n";
117 print "ok ", ++$i, "\n";