add missing dTHR; notes for test failures due to small stacksize
[p5sagit/p5-mst-13.2.git] / t / pragma / warning.t
CommitLineData
8ebc5c01 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 $ENV{PERL5LIB} = '../lib';
7}
8
9$| = 1;
10
44a8e56a 11my $Is_VMS = $^O eq 'VMS';
68dc0745 12my $Is_MSWin32 = $^O eq 'MSWin32';
8ebc5c01 13my $tmpfile = "tmp0000";
14my $i = 0 ;
151 while -f ++$tmpfile;
44a8e56a 16END { if ($tmpfile) { 1 while unlink $tmpfile} }
8ebc5c01 17
18my @prgs = () ;
599cee73 19my @w_files = () ;
8ebc5c01 20
599cee73 21if (@ARGV)
22 { print "ARGV = [@ARGV]\n" ; @w_files = map { s#^#./pragma/warn-#; $_ } @ARGV }
23else
24 { @w_files = sort glob("pragma/warn-*") }
25
26foreach (@w_files) {
27
28 next if /\.orig$/ ;
8ebc5c01 29
d8b8f155 30 next if /(~|\.orig)$/;
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
44undef $/;
45
46print "1..", scalar @prgs, "\n";
47
48
49for (@prgs){
50 my $switch = "";
51 my @temps = () ;
52 if (s/^\s*-\w+//){
53 $switch = $&;
44a8e56a 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 ?
78 `MCR $^X $switch $tmpfile` :
68dc0745 79 $Is_MSWin32 ?
80 `.\\perl -I../lib $switch $tmpfile 2>&1` :
44a8e56a 81 `sh -c './perl $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
8ebc5c01 87 $expected =~ s/\n+$//;
88 my $prefix = ($results =~ s/^PREFIX\n//) ;
89 if ( $results =~ s/^SKIPPED\n//) {
90 print "$results\n" ;
91 }
92 elsif (($prefix and $results !~ /^\Q$expected/) or
93 (!$prefix and $results ne $expected)){
94 print STDERR "PROG: $switch\n$prog\n";
95 print STDERR "EXPECTED:\n$expected\n";
96 print STDERR "GOT:\n$results\n";
97 print "not ";
98 }
99 print "ok ", ++$i, "\n";
100 foreach (@temps)
101 { unlink $_ if $_ }
102}