6 $ENV{PERL5LIB} = '../lib';
7 require Config; import Config;
14 my $Is_VMS = $^O eq 'VMS';
15 my $Is_MSWin32 = $^O eq 'MSWin32';
16 my $Is_NetWare = $^O eq 'NetWare';
17 my $tmpfile = "tmp0000";
19 1 while -f ++$tmpfile;
20 END { if ($tmpfile) { 1 while unlink $tmpfile} }
26 { print "ARGV = [@ARGV]\n" ; @w_files = map { s#^#./lib/warnings/#; $_ } @ARGV }
28 { @w_files = sort glob("lib/warnings/*") }
31 foreach my $file (@w_files) {
33 next if $file =~ /(~|\.orig|,v)$/;
35 open F, "<$file" or die "Cannot open $file: $!\n" ;
45 @prgs = (@prgs, $file, split "\n########\n", <F>) ;
52 print "1..", scalar(@prgs)-$files, "\n";
66 $switch =~ s/(-\S*[A-Z]\S*)/"$1"/ if $Is_VMS; # protect uc switches
68 my($prog,$expected) = split(/\nEXPECT\n/, $_);
69 if ( $prog =~ /--FILE--/) {
70 my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
72 die "Internal error test $i didn't split into pairs, got " .
73 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
76 my $filename = shift @files ;
77 my $code = shift @files ;
78 push @temps, $filename ;
79 if ($filename =~ m#(.*)/#) {
83 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
85 close F or die "Cannot close $filename: $!\n";
88 $prog = shift @files ;
90 open TEST, ">$tmpfile" or die "Cannot open >$tmpfile: $!";
93 open(STDERR, ">&STDOUT")
94 or die "Can't dup STDOUT->STDERR: $!;";
97 print TEST "\n#line 1\n"; # So the line numbers don't get messed up.
98 print TEST $prog,"\n";
99 close TEST or die "Cannot close $tmpfile: $!";
100 my $results = $Is_VMS ?
101 `./perl "-I../lib" $switch $tmpfile` :
103 `.\\perl -I../lib $switch $tmpfile` :
105 `perl -I../lib $switch $tmpfile` :
107 `$^X -I::lib $switch -MMac::err=unix $tmpfile` :
108 `./perl -I../lib $switch $tmpfile`;
110 $results =~ s/\n+$//;
111 # allow expected output to be written as if $prog is on STDIN
112 $results =~ s/tmp\d+/-/g;
114 # some tests will trigger VMS messages that won't be expected
115 $results =~ s/\n?%[A-Z]+-[SIWEF]-[A-Z]+,.*//;
117 # pipes double these sometimes
118 $results =~ s/\n\n/\n/g;
120 # bison says 'parse error' instead of 'syntax error',
121 # various yaccs may or may not capitalize 'syntax'.
122 $results =~ s/^(syntax|parse) error/syntax error/mig;
123 # allow all tests to run when there are leaks
124 $results =~ s/Scalars leaked: \d+\n//g;
125 $expected =~ s/\n+$//;
126 my $prefix = ($results =~ s#^PREFIX(\n|$)##) ;
127 # any special options? (OPTIONS foo bar zap)
128 my $option_regex = 0;
129 my $option_random = 0;
130 if ($expected =~ s/^OPTIONS? (.+)\n//) {
131 foreach my $option (split(' ', $1)) {
132 if ($option eq 'regex') { # allow regular expressions
135 elsif ($option eq 'random') { # all lines match, but in any order
139 die "$0: Unknown OPTION '$option'\n";
143 die "$0: can't have OPTION regex and random\n"
144 if $option_regex + option_random > 1;
145 if ( $results =~ s/^SKIPPED\n//) {
148 elsif ($option_random)
150 print "not " if !randomMatch($results, $expected);
152 elsif (($prefix && (( $option_regex && $results !~ /^$expected/) ||
153 (!$option_regex && $results !~ /^\Q$expected/))) or
154 (!$prefix && (( $option_regex && $results !~ /^$expected/) ||
155 (!$option_regex && $results ne $expected)))) {
156 print STDERR "PROG: $switch\n$prog\n";
157 print STDERR "EXPECTED:\n$expected\n";
158 print STDERR "GOT:\n$results\n";
161 print "ok ", ++$i, "\n";
165 { rmtree $_ if -d $_ }
171 my $expected = shift;
173 my @got = sort split "\n", $got ;
174 my @expected = sort split "\n", $expected ;
176 return "@got" eq "@expected";