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