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 $Is_NetWare = $^O eq 'NetWare';
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/*") }
29 foreach my $file (@w_files) {
31 next if $file =~ /(~|\.orig|,v)$/;
33 open F, "<$file" or die "Cannot open $file: $!\n" ;
43 @prgs = (@prgs, $file, split "\n########\n", <F>) ;
50 print "1..", scalar(@prgs)-$files, "\n";
63 $switch =~ s/(-\S*[A-Z]\S*)/"$1"/ if $Is_VMS; # protect uc switches
65 my($prog,$expected) = split(/\nEXPECT\n/, $_);
66 if ( $prog =~ /--FILE--/) {
67 my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
69 die "Internal error test $i didn't split into pairs, got " .
70 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
73 my $filename = shift @files ;
74 my $code = shift @files ;
75 push @temps, $filename ;
76 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
81 $prog = shift @files ;
83 open TEST, ">$tmpfile";
84 print TEST $prog,"\n";
86 my $results = $Is_VMS ?
87 `./perl "-I../lib" $switch $tmpfile 2>&1` :
89 `.\\perl -I../lib $switch $tmpfile 2>&1` :
91 `perl -I../lib $switch $tmpfile 2>&1` :
92 `./perl -I../lib $switch $tmpfile 2>&1`;
95 # allow expected output to be written as if $prog is on STDIN
96 $results =~ s/tmp\d+/-/g;
97 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
98 # bison says 'parse error' instead of 'syntax error',
99 # various yaccs may or may not capitalize 'syntax'.
100 $results =~ s/^(syntax|parse) error/syntax error/mig;
101 # allow all tests to run when there are leaks
102 $results =~ s/Scalars leaked: \d+\n//g;
103 $expected =~ s/\n+$//;
104 my $prefix = ($results =~ s#^PREFIX(\n|$)##) ;
105 # any special options? (OPTIONS foo bar zap)
106 my $option_regex = 0;
107 if ($expected =~ s/^OPTIONS? (.+)\n//) {
108 foreach my $option (split(' ', $1)) {
109 if ($option eq 'regex') { # allow regular expressions
112 die "$0: Unknown OPTION '$option'\n";
116 if ( $results =~ s/^SKIPPED\n//) {
119 elsif (($prefix && (( $option_regex && $results !~ /^$expected/) ||
120 (!$option_regex && $results !~ /^\Q$expected/))) or
121 (!$prefix && (( $option_regex && $results !~ /^$expected/) ||
122 (!$option_regex && $results ne $expected)))) {
123 print STDERR "PROG: $switch\n$prog\n";
124 print STDERR "EXPECTED:\n$expected\n";
125 print STDERR "GOT:\n$results\n";
128 print "ok ", ++$i, "\n";