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#^#./lib/warnings/#; $_ } @ARGV }
26 { @w_files = sort glob("lib/warnings/*") }
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" ;
78 close F or die "Cannot close $filename: $!\n";
81 $prog = shift @files ;
83 open TEST, ">$tmpfile" or die "Cannot open >$tmpfile: $!";
86 open(STDERR, ">&STDOUT")
87 or die "Can't dup STDOUT->STDERR: $!;";
90 print TEST "\n#line 1\n"; # So the line numbers don't get messed up.
91 print TEST $prog,"\n";
92 close TEST or die "Cannot close $tmpfile: $!";
93 my $results = $Is_VMS ?
94 `./perl "-I../lib" $switch $tmpfile` :
96 `.\\perl -I../lib $switch $tmpfile` :
98 `perl -I../lib $switch $tmpfile` :
100 `$^X -I::lib $switch -MMac::err=unix $tmpfile` :
101 `./perl -I../lib $switch $tmpfile`;
103 $results =~ s/\n+$//;
104 # allow expected output to be written as if $prog is on STDIN
105 $results =~ s/tmp\d+/-/g;
107 # some tests will trigger VMS messages that won't be expected
108 $results =~ s/\n?%[A-Z]+-[SIWEF]-[A-Z]+,.*//;
110 # pipes double these sometimes
111 $results =~ s/\n\n/\n/g;
113 # bison says 'parse error' instead of 'syntax error',
114 # various yaccs may or may not capitalize 'syntax'.
115 $results =~ s/^(syntax|parse) error/syntax error/mig;
116 # allow all tests to run when there are leaks
117 $results =~ s/Scalars leaked: \d+\n//g;
118 $expected =~ s/\n+$//;
119 my $prefix = ($results =~ s#^PREFIX(\n|$)##) ;
120 # any special options? (OPTIONS foo bar zap)
121 my $option_regex = 0;
122 if ($expected =~ s/^OPTIONS? (.+)\n//) {
123 foreach my $option (split(' ', $1)) {
124 if ($option eq 'regex') { # allow regular expressions
127 die "$0: Unknown OPTION '$option'\n";
131 if ( $results =~ s/^SKIPPED\n//) {
134 elsif (($prefix && (( $option_regex && $results !~ /^$expected/) ||
135 (!$option_regex && $results !~ /^\Q$expected/))) or
136 (!$prefix && (( $option_regex && $results !~ /^$expected/) ||
137 (!$option_regex && $results ne $expected)))) {
138 print STDERR "PROG: $switch\n$prog\n";
139 print STDERR "EXPECTED:\n$expected\n";
140 print STDERR "GOT:\n$results\n";
143 print "ok ", ++$i, "\n";