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