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