bump patchlevel to 5.005_51
[p5sagit/p5-mst-13.2.git] / t / pragma / warning.t
1 #!./perl 
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     $ENV{PERL5LIB} = '../lib';
7 }
8
9 $| = 1;
10
11 my $Is_VMS = $^O eq 'VMS';
12 my $Is_MSWin32 = $^O eq 'MSWin32';
13 my $tmpfile = "tmp0000";
14 my $i = 0 ;
15 1 while -f ++$tmpfile;
16 END {  if ($tmpfile) { 1 while unlink $tmpfile} }
17
18 my @prgs = () ;
19
20 foreach (sort glob("pragma/warn-*")) {
21
22     next if /(~|\.orig)$/;
23
24     open F, "<$_" or die "Cannot open $_: $!\n" ;
25     while (<F>) {
26         last if /^__END__/ ;
27     }
28
29     {
30         local $/ = undef;
31         @prgs = (@prgs, split "\n########\n", <F>) ;
32     }
33     close F ;
34 }
35
36 undef $/;
37
38 print "1..", scalar @prgs, "\n";
39  
40  
41 for (@prgs){
42     my $switch = "";
43     my @temps = () ;
44     if (s/^\s*-\w+//){
45         $switch = $&;
46         $switch =~ s/(-\S*[A-Z]\S*)/"-$1"/ if $Is_VMS; # protect uc switches
47     }
48     my($prog,$expected) = split(/\nEXPECT\n/, $_);
49     if ( $prog =~ /--FILE--/) {
50         my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ;
51         shift @files ;
52         die "Internal error test $i didn't split into pairs, got " . 
53                 scalar(@files) . "[" . join("%%%%", @files) ."]\n"
54             if @files % 2 ;
55         while (@files > 2) {
56             my $filename = shift @files ;
57             my $code = shift @files ;
58             push @temps, $filename ;
59             open F, ">$filename" or die "Cannot open $filename: $!\n" ;
60             print F $code ;
61             close F ;
62         }
63         shift @files ;
64         $prog = shift @files ;
65     }
66     open TEST, ">$tmpfile";
67     print TEST $prog,"\n";
68     close TEST;
69     my $results = $Is_VMS ?
70                   `MCR $^X $switch $tmpfile` :
71                   $Is_MSWin32 ?
72                   `.\\perl -I../lib $switch $tmpfile 2>&1` :
73                   `sh -c './perl $switch $tmpfile' 2>&1`;
74     my $status = $?;
75     $results =~ s/\n+$//;
76     # allow expected output to be written as if $prog is on STDIN
77     $results =~ s/tmp\d+/-/g;
78     $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS;  # clip off DCL status msg
79     $expected =~ s/\n+$//;
80     my $prefix = ($results =~ s/^PREFIX\n//) ;
81     if ( $results =~ s/^SKIPPED\n//) {
82         print "$results\n" ;
83     }
84     elsif (($prefix and $results !~ /^\Q$expected/) or
85            (!$prefix and $results ne $expected)){
86         print STDERR "PROG: $switch\n$prog\n";
87         print STDERR "EXPECTED:\n$expected\n";
88         print STDERR "GOT:\n$results\n";
89         print "not ";
90     }
91     print "ok ", ++$i, "\n";
92     foreach (@temps) 
93         { unlink $_ if $_ } 
94 }