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/*") }
31 next if /(~|\.orig)$/;
33 open F, "<$_" or die "Cannot open $_: $!\n" ;
40 @prgs = (@prgs, split "\n########\n", <F>) ;
47 print "1..", scalar @prgs, "\n";
55 $switch =~ s/(-\S*[A-Z]\S*)/"$1"/ if $Is_VMS; # protect uc switches
57 my($prog,$expected) = split(/\nEXPECT\n/, $_);
58 if ( $prog =~ /--FILE--/) {
59 my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
61 die "Internal error test $i didn't split into pairs, got " .
62 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
65 my $filename = shift @files ;
66 my $code = shift @files ;
67 push @temps, $filename ;
68 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
73 $prog = shift @files ;
75 open TEST, ">$tmpfile";
76 print TEST $prog,"\n";
78 my $results = $Is_VMS ?
79 `MCR $^X $switch $tmpfile` :
81 `.\\perl -I../lib $switch $tmpfile 2>&1` :
82 `./perl -I../lib $switch $tmpfile 2>&1`;
85 # allow expected output to be written as if $prog is on STDIN
86 $results =~ s/tmp\d+/-/g;
87 $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg
88 # bison says 'parse error' instead of 'syntax error',
89 # various yaccs may or may not capitalize 'syntax'.
90 $results =~ s/^(syntax|parse) error/syntax error/mig;
91 # allow all tests to run when there are leaks
92 $results =~ s/Scalars leaked: \d+\n//g;
93 $expected =~ s/\n+$//;
94 my $prefix = ($results =~ s/^PREFIX\n//) ;
95 # any special options? (OPTIONS foo bar zap)
97 if ($expected =~ s/^OPTIONS? (.+)\n//) {
98 foreach my $option (split(' ', $1)) {
99 if ($option eq 'regex') { # allow regular expressions
102 die "$0: Unknown OPTION '$option'\n";
106 if ( $results =~ s/^SKIPPED\n//) {
109 elsif (($prefix && (( $option_regex && $results !~ /^$expected/) ||
110 (!$option_regex && $results !~ /^\Q$expected/))) or
111 (!$prefix && (( $option_regex && $results !~ /^$expected/) ||
112 (!$option_regex && $results ne $expected)))) {
113 print STDERR "PROG: $switch\n$prog\n";
114 print STDERR "EXPECTED:\n$expected\n";
115 print STDERR "GOT:\n$results\n";
118 print "ok ", ++$i, "\n";