Commit | Line | Data |
bd4dea8e |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | $ENV{PERL5LIB} = '../lib'; |
7 | require Config; import Config; |
8 | } |
9 | |
10 | $| = 1; |
11 | |
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"; |
16 | my $i = 0 ; |
17 | 1 while -f ++$tmpfile; |
18 | END { if ($tmpfile) { 1 while unlink $tmpfile} } |
19 | |
20 | my @prgs = () ; |
21 | my @w_files = () ; |
22 | |
23 | if (@ARGV) |
601f2d16 |
24 | { print "ARGV = [@ARGV]\n" ; @w_files = map { s#^#./lib/warnings/#; $_ } @ARGV } |
bd4dea8e |
25 | else |
601f2d16 |
26 | { @w_files = sort glob("lib/warnings/*") } |
bd4dea8e |
27 | |
28 | my $files = 0; |
29 | foreach my $file (@w_files) { |
30 | |
31 | next if $file =~ /(~|\.orig|,v)$/; |
32 | |
33 | open F, "<$file" or die "Cannot open $file: $!\n" ; |
34 | my $line = 0; |
35 | while (<F>) { |
36 | $line++; |
37 | last if /^__END__/ ; |
38 | } |
39 | |
40 | { |
41 | local $/ = undef; |
42 | $files++; |
43 | @prgs = (@prgs, $file, split "\n########\n", <F>) ; |
44 | } |
45 | close F ; |
46 | } |
47 | |
48 | undef $/; |
49 | |
50 | print "1..", scalar(@prgs)-$files, "\n"; |
51 | |
52 | |
53 | for (@prgs){ |
54 | unless (/\n/) |
55 | { |
56 | print "# From $_\n"; |
57 | next; |
58 | } |
59 | my $switch = ""; |
60 | my @temps = () ; |
61 | if (s/^\s*-\w+//){ |
62 | $switch = $&; |
63 | $switch =~ s/(-\S*[A-Z]\S*)/"$1"/ if $Is_VMS; # protect uc switches |
64 | } |
65 | my($prog,$expected) = split(/\nEXPECT\n/, $_); |
66 | if ( $prog =~ /--FILE--/) { |
67 | my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ; |
68 | shift @files ; |
69 | die "Internal error test $i didn't split into pairs, got " . |
70 | scalar(@files) . "[" . join("%%%%", @files) ."]\n" |
71 | if @files % 2 ; |
72 | while (@files > 2) { |
73 | my $filename = shift @files ; |
74 | my $code = shift @files ; |
75 | push @temps, $filename ; |
76 | open F, ">$filename" or die "Cannot open $filename: $!\n" ; |
77 | print F $code ; |
78 | close F ; |
79 | } |
80 | shift @files ; |
81 | $prog = shift @files ; |
82 | } |
83 | open TEST, ">$tmpfile"; |
84 | print TEST $prog,"\n"; |
85 | close TEST; |
86 | my $results = $Is_VMS ? |
87 | `./perl "-I../lib" $switch $tmpfile 2>&1` : |
88 | $Is_MSWin32 ? |
89 | `.\\perl -I../lib $switch $tmpfile 2>&1` : |
90 | $Is_NetWare ? |
91 | `perl -I../lib $switch $tmpfile 2>&1` : |
92 | `./perl -I../lib $switch $tmpfile 2>&1`; |
93 | my $status = $?; |
94 | $results =~ s/\n+$//; |
95 | # allow expected output to be written as if $prog is on STDIN |
96 | $results =~ s/tmp\d+/-/g; |
97 | $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS; # clip off DCL status msg |
98 | # bison says 'parse error' instead of 'syntax error', |
99 | # various yaccs may or may not capitalize 'syntax'. |
100 | $results =~ s/^(syntax|parse) error/syntax error/mig; |
101 | # allow all tests to run when there are leaks |
102 | $results =~ s/Scalars leaked: \d+\n//g; |
103 | $expected =~ s/\n+$//; |
104 | my $prefix = ($results =~ s#^PREFIX(\n|$)##) ; |
105 | # any special options? (OPTIONS foo bar zap) |
106 | my $option_regex = 0; |
107 | if ($expected =~ s/^OPTIONS? (.+)\n//) { |
108 | foreach my $option (split(' ', $1)) { |
109 | if ($option eq 'regex') { # allow regular expressions |
110 | $option_regex = 1; |
111 | } else { |
112 | die "$0: Unknown OPTION '$option'\n"; |
113 | } |
114 | } |
115 | } |
116 | if ( $results =~ s/^SKIPPED\n//) { |
117 | print "$results\n" ; |
118 | } |
119 | elsif (($prefix && (( $option_regex && $results !~ /^$expected/) || |
120 | (!$option_regex && $results !~ /^\Q$expected/))) or |
121 | (!$prefix && (( $option_regex && $results !~ /^$expected/) || |
122 | (!$option_regex && $results ne $expected)))) { |
123 | print STDERR "PROG: $switch\n$prog\n"; |
124 | print STDERR "EXPECTED:\n$expected\n"; |
125 | print STDERR "GOT:\n$results\n"; |
126 | print "not "; |
127 | } |
128 | print "ok ", ++$i, "\n"; |
129 | foreach (@temps) |
130 | { unlink $_ if $_ } |
131 | } |