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