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)$/;
34 next if $file =~ /perlio$/ && !(find PerlIO::Layer 'perlio');
36 open F, "<$file" or die "Cannot open $file: $!\n" ;
46 @prgs = (@prgs, $file, split "\n########\n", <F>) ;
53 print "1..", scalar(@prgs)-$files, "\n";
67 $switch =~ s/(-\S*[A-Z]\S*)/"$1"/ if $Is_VMS; # protect uc switches
69 my($prog,$expected) = split(/\nEXPECT\n/, $_);
70 if ( $prog =~ /--FILE--/) {
71 my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
73 die "Internal error test $i didn't split into pairs, got " .
74 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
77 my $filename = shift @files ;
78 my $code = shift @files ;
79 push @temps, $filename ;
80 if ($filename =~ m#(.*)/#) {
84 open F, ">$filename" or die "Cannot open $filename: $!\n" ;
86 close F or die "Cannot close $filename: $!\n";
89 $prog = shift @files ;
91 open TEST, ">$tmpfile" or die "Cannot open >$tmpfile: $!";
94 open(STDERR, ">&STDOUT")
95 or die "Can't dup STDOUT->STDERR: $!;";
98 print TEST "\n#line 1\n"; # So the line numbers don't get messed up.
99 print TEST $prog,"\n";
100 close TEST or die "Cannot close $tmpfile: $!";
101 my $results = $Is_VMS ?
102 `./perl "-I../lib" $switch $tmpfile` :
104 `.\\perl -I../lib $switch $tmpfile` :
106 `perl -I../lib $switch $tmpfile` :
108 `$^X -I::lib $switch -MMac::err=unix $tmpfile` :
109 `./perl -I../lib $switch $tmpfile`;
111 $results =~ s/\n+$//;
112 # allow expected output to be written as if $prog is on STDIN
113 $results =~ s/tmp\d+/-/g;
115 # some tests will trigger VMS messages that won't be expected
116 $results =~ s/\n?%[A-Z]+-[SIWEF]-[A-Z]+,.*//;
118 # pipes double these sometimes
119 $results =~ s/\n\n/\n/g;
121 # bison says 'parse error' instead of 'syntax error',
122 # various yaccs may or may not capitalize 'syntax'.
123 $results =~ s/^(syntax|parse) error/syntax error/mig;
124 # allow all tests to run when there are leaks
125 $results =~ s/Scalars leaked: \d+\n//g;
126 $expected =~ s/\n+$//;
127 my $prefix = ($results =~ s#^PREFIX(\n|$)##) ;
128 # any special options? (OPTIONS foo bar zap)
129 my $option_regex = 0;
130 my $option_random = 0;
131 if ($expected =~ s/^OPTIONS? (.+)\n//) {
132 foreach my $option (split(' ', $1)) {
133 if ($option eq 'regex') { # allow regular expressions
136 elsif ($option eq 'random') { # all lines match, but in any order
140 die "$0: Unknown OPTION '$option'\n";
144 die "$0: can't have OPTION regex and random\n"
145 if $option_regex + option_random > 1;
146 if ( $results =~ s/^SKIPPED\n//) {
149 elsif ($option_random)
151 print "not " if !randomMatch($results, $expected);
153 elsif (($prefix && (( $option_regex && $results !~ /^$expected/) ||
154 (!$option_regex && $results !~ /^\Q$expected/))) or
155 (!$prefix && (( $option_regex && $results !~ /^$expected/) ||
156 (!$option_regex && $results ne $expected)))) {
157 print STDERR "PROG: $switch\n$prog\n";
158 print STDERR "EXPECTED:\n$expected\n";
159 print STDERR "GOT:\n$results\n";
162 print "ok ", ++$i, "\n";
166 { rmtree $_ if -d $_ }
172 my $expected = shift;
174 my @got = sort split "\n", $got ;
175 my @expected = sort split "\n", $expected ;
177 return "@got" eq "@expected";