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/*") }
29 foreach my $file (@w_files) {
31 next if /(~|\.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` :
90 `./perl -I../lib $switch $tmpfile 2>&1`;
93 # allow expected output to be written as if $prog is on STDIN
94 $results =~ s/tmp\d+/-/g;
95 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
96 # bison says 'parse error' instead of 'syntax error',
97 # various yaccs may or may not capitalize 'syntax'.
98 $results =~ s/^(syntax|parse) error/syntax error/mig;
99 # allow all tests to run when there are leaks
100 $results =~ s/Scalars leaked: \d+\n//g;
101 $expected =~ s/\n+$//;
102 my $prefix = ($results =~ s#^PREFIX(\n|$)##) ;
103 # any special options? (OPTIONS foo bar zap)
104 my $option_regex = 0;
105 if ($expected =~ s/^OPTIONS? (.+)\n//) {
106 foreach my $option (split(' ', $1)) {
107 if ($option eq 'regex') { # allow regular expressions
110 die "$0: Unknown OPTION '$option'\n";
114 if ( $results =~ s/^SKIPPED\n//) {
117 elsif (($prefix && (( $option_regex && $results !~ /^$expected/) ||
118 (!$option_regex && $results !~ /^\Q$expected/))) or
119 (!$prefix && (( $option_regex && $results !~ /^$expected/) ||
120 (!$option_regex && $results ne $expected)))) {
121 print STDERR "PROG: $switch\n$prog\n";
122 print STDERR "EXPECTED:\n$expected\n";
123 print STDERR "GOT:\n$results\n";
126 print "ok ", ++$i, "\n";