| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Syntax::Aggregate::Checker; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3164
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
325
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Test::Syntax::Aggregate::Checker - runs syntax checks on specified files |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This module is used by L, you don't normally want use it directly |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 run |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Reads file names from the standart input. Tries to compile each file in a |
|
23
|
|
|
|
|
|
|
forked process. Prints "ok" if compilation succeed, or "not ok" otherwise. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub run { |
|
28
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
29
|
0
|
|
|
|
|
|
my %params = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
autoflush STDOUT, 1; |
|
32
|
0
|
|
|
|
|
|
while () { |
|
33
|
0
|
|
|
|
|
|
chomp; |
|
34
|
0
|
|
|
|
|
|
my $pid = fork; |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if ($pid) { |
|
37
|
0
|
|
|
|
|
|
waitpid $pid, 0; |
|
38
|
0
|
0
|
|
|
|
|
print $? ? "not ok\n" : "ok\n"; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
else { |
|
41
|
0
|
0
|
|
|
|
|
open my $scr, "<", $_ or die "Can't open $_: $!"; |
|
42
|
0
|
|
|
|
|
|
my $script = do { local $/; <$scr>; }; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
close $scr; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# shebang_to_perl |
|
46
|
0
|
|
|
|
|
|
my $shebang = ''; |
|
47
|
0
|
0
|
|
|
|
|
if ( $script =~ /^#!.* -[A-Za-vx-z]*w/ ) { |
|
48
|
0
|
|
|
|
|
|
$shebang = "use warnings;\n"; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# strip_end_data_segment |
|
52
|
0
|
|
|
|
|
|
$script =~ s/^__(END|DATA)__(.*)//ms; |
|
53
|
0
|
|
|
|
|
|
my $package = "$_"; |
|
54
|
0
|
|
|
|
|
|
$package =~ s{[^A-Za-z0-9]}{_}g; |
|
55
|
0
|
|
|
|
|
|
$package = __PACKAGE__ . "::$package"; |
|
56
|
0
|
|
|
|
|
|
my $eval = <
|
|
57
|
|
|
|
|
|
|
package $package; |
|
58
|
|
|
|
|
|
|
sub script { |
|
59
|
|
|
|
|
|
|
local \$0 = '$_'; |
|
60
|
|
|
|
|
|
|
$shebang; |
|
61
|
|
|
|
|
|
|
#line 1 $_ |
|
62
|
|
|
|
|
|
|
$script |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
EOS |
|
65
|
0
|
|
|
|
|
|
my $dir = $_; |
|
66
|
0
|
|
|
|
|
|
$dir =~ s/(?<=[\\\/])[^\\\/]+$//; |
|
67
|
0
|
0
|
|
|
|
|
chdir $dir if $dir; |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my @warnings; |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
1
|
|
|
1
|
|
5
|
no strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
23
|
|
|
|
0
|
|
|
|
|
|
|
|
72
|
1
|
|
|
1
|
|
4
|
no warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
202
|
|
|
73
|
0
|
|
|
0
|
|
|
local $SIG{__WARN__} = sub { push @warnings, shift }; |
|
|
0
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
local *STDIN; |
|
75
|
0
|
|
|
|
|
|
local *STDOUT; |
|
76
|
0
|
|
|
|
|
|
local *STDERR; |
|
77
|
0
|
|
|
|
|
|
eval $eval; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
0
|
|
|
|
|
|
my $err = $@; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Print warnings if there's an error or if hide_warnings is false |
|
82
|
0
|
0
|
0
|
|
|
|
if ($err or not $params{hide_warnings}) { |
|
83
|
0
|
|
|
|
|
|
print STDERR $_ for @warnings; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Don't want to run END blocks |
|
87
|
0
|
|
|
|
|
|
require POSIX; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
if ($err) { |
|
90
|
0
|
|
|
|
|
|
warn "Can't compile $_: $@\n"; |
|
91
|
0
|
|
|
|
|
|
close STDERR; |
|
92
|
0
|
|
|
|
|
|
close STDOUT; |
|
93
|
0
|
|
|
|
|
|
POSIX::_exit(1); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
else { |
|
96
|
0
|
|
|
|
|
|
POSIX::_exit(0); |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |