Commit | Line | Data |
8ebc5c01 |
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 $tmpfile = "tmp0000"; |
12 | my $i = 0 ; |
13 | 1 while -f ++$tmpfile; |
14 | END { unlink $tmpfile if $tmpfile; } |
15 | |
16 | my @prgs = () ; |
17 | |
18 | foreach (sort glob("pragma/strict-*")) { |
19 | |
20 | open F, "<$_" or die "Cannot open $_: $!\n" ; |
21 | while (<F>) { |
22 | last if /^__END__/ ; |
23 | } |
24 | |
25 | { |
26 | local $/ = undef; |
27 | @prgs = (@prgs, split "\n########\n", <F>) ; |
28 | } |
29 | close F ; |
30 | } |
31 | |
32 | undef $/; |
33 | |
34 | print "1..", scalar @prgs, "\n"; |
35 | |
36 | |
37 | for (@prgs){ |
38 | my $switch = ""; |
39 | my @temps = () ; |
40 | if (s/^\s*-\w+//){ |
41 | $switch = $&; |
42 | } |
43 | my($prog,$expected) = split(/\nEXPECT\n/, $_); |
44 | if ( $prog =~ /--FILE--/) { |
45 | my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ; |
46 | shift @files ; |
47 | die "Internal error test $i didn't split into pairs, got " . |
48 | scalar(@files) . "[" . join("%%%%", @files) ."]\n" |
49 | if @files % 2 ; |
50 | while (@files > 2) { |
51 | my $filename = shift @files ; |
52 | my $code = shift @files ; |
53 | push @temps, $filename ; |
54 | open F, ">$filename" or die "Cannot open $filename: $!\n" ; |
55 | print F $code ; |
56 | close F ; |
57 | } |
58 | shift @files ; |
59 | $prog = shift @files ; |
60 | } |
61 | open TEST, "| sh -c './perl $switch' >$tmpfile 2>&1"; |
62 | print TEST $prog, "\n"; |
63 | close TEST; |
64 | my $status = $?; |
65 | my $results = `cat $tmpfile`; |
66 | $results =~ s/\n+$//; |
67 | $expected =~ s/\n+$//; |
68 | my $prefix = ($results =~ s/^PREFIX\n//) ; |
69 | if ( $results =~ s/^SKIPPED\n//) { |
70 | print "$results\n" ; |
71 | } |
72 | elsif (($prefix and $results !~ /^\Q$expected/) or |
73 | (!$prefix and $results ne $expected)){ |
74 | print STDERR "PROG: $switch\n$prog\n"; |
75 | print STDERR "EXPECTED:\n$expected\n"; |
76 | print STDERR "GOT:\n$results\n"; |
77 | print "not "; |
78 | } |
79 | print "ok ", ++$i, "\n"; |
80 | foreach (@temps) |
81 | { unlink $_ if $_ } |
82 | } |