line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Pod::Coverage::TrustMe; |
2
|
1
|
|
|
1
|
|
472
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
31
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.002000'; |
6
|
|
|
|
|
|
|
$VERSION =~ tr/_//d; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use File::Spec (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
9
|
1
|
|
|
1
|
|
4
|
use Cwd (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
10
|
1
|
|
|
1
|
|
677
|
use Test::Builder (); |
|
1
|
|
|
|
|
61645
|
|
|
1
|
|
|
|
|
29
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
9
|
use Exporter (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1274
|
|
13
|
|
|
|
|
|
|
*import = \&Exporter::import; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw( |
16
|
|
|
|
|
|
|
all_modules |
17
|
|
|
|
|
|
|
pod_coverage_ok |
18
|
|
|
|
|
|
|
all_pod_coverage_ok |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _blib { |
22
|
1
|
|
|
1
|
|
5
|
my $dir = File::Spec->curdir; |
23
|
1
|
|
|
|
|
3
|
my $try = 5; |
24
|
1
|
|
|
|
|
3
|
while ($try--) { |
25
|
1
|
|
|
|
|
19
|
my $blib = File::Spec->catdir($dir, 'blib'); |
26
|
1
|
50
|
33
|
|
|
51
|
if ( |
|
|
|
33
|
|
|
|
|
27
|
|
|
|
|
|
|
-d $blib |
28
|
|
|
|
|
|
|
&& -d File::Spec->catdir($blib, 'arch') |
29
|
|
|
|
|
|
|
&& -d File::Spec->catdir($blib, 'lib') |
30
|
|
|
|
|
|
|
) { |
31
|
1
|
|
|
|
|
7
|
return $blib; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
$dir = File::Spec->catdir($dir, File::Spec->updir); |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
0
|
return undef; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _lib { |
40
|
1
|
|
|
1
|
|
10
|
my $dir = File::Spec->curdir; |
41
|
1
|
|
|
|
|
2
|
my $try = 5; |
42
|
1
|
|
|
|
|
5
|
while ($try--) { |
43
|
1
|
|
|
|
|
10
|
my $lib = File::Spec->catdir($dir, 'lib'); |
44
|
1
|
50
|
|
|
|
22
|
if (-d $lib) { |
45
|
1
|
|
|
|
|
35
|
my @parts = File::Spec->splitdir(Cwd::realpath($lib)); |
46
|
1
|
50
|
33
|
|
|
27
|
if ( |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
47
|
|
|
|
|
|
|
@parts >= 2 |
48
|
|
|
|
|
|
|
&& $parts[-1] eq 'lib' |
49
|
|
|
|
|
|
|
&& ($parts[-2] eq 't' || $parts[-2] eq 'xt') |
50
|
|
|
|
|
|
|
) { |
51
|
0
|
|
|
|
|
0
|
next; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
7
|
return $lib; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
$dir = File::Spec->catdir($dir, File::Spec->updir); |
58
|
|
|
|
|
|
|
} |
59
|
0
|
|
|
|
|
0
|
return undef; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _base_dirs { |
63
|
1
|
|
|
1
|
|
2
|
my %find; |
64
|
1
|
50
|
|
|
|
3
|
if (my $lib = _lib()) { |
65
|
1
|
|
|
|
|
21
|
$find{Cwd::realpath($lib)}++; |
66
|
|
|
|
|
|
|
} |
67
|
1
|
50
|
|
|
|
5
|
if (my $blib = _blib()) { |
68
|
1
|
|
|
|
|
31
|
$find{Cwd::realpath(File::Spec->catdir($blib, 'arch'))}++; |
69
|
1
|
|
|
|
|
31
|
$find{Cwd::realpath(File::Spec->catdir($blib, 'lib'))}++; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
432
|
my @dirs = grep $find{Cwd::realpath($_)}, @INC; |
73
|
1
|
|
|
|
|
6
|
return @dirs; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub all_modules { |
77
|
1
|
|
|
1
|
1
|
3
|
my @dirs = @_; |
78
|
1
|
50
|
|
|
|
4
|
@dirs = _base_dirs |
79
|
|
|
|
|
|
|
if !@dirs; |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
4
|
my %searched; |
82
|
|
|
|
|
|
|
my @modules; |
83
|
1
|
|
|
|
|
0
|
my %modules; |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
5
|
my @search = map [$_], @dirs; |
86
|
1
|
|
|
|
|
5
|
while (my $search = shift @search) { |
87
|
18
|
|
|
|
|
64
|
my ($dir, @pre) = @$search; |
88
|
|
|
|
|
|
|
next |
89
|
18
|
100
|
|
|
|
1194
|
if $searched{Cwd::realpath($dir)}++; |
90
|
16
|
50
|
|
|
|
458
|
opendir my $dh, $dir or die; |
91
|
16
|
|
|
|
|
485
|
my @found = File::Spec->no_upwards(readdir $dh); |
92
|
16
|
|
|
|
|
189
|
closedir $dh; |
93
|
|
|
|
|
|
|
|
94
|
16
|
|
66
|
|
|
179
|
my @mods = grep /\.pm\z/ && -f File::Spec->catfile($dir, $_), @found; |
95
|
16
|
|
|
|
|
48
|
s/\.pm\z// for @mods; |
96
|
|
|
|
|
|
|
push @modules, |
97
|
16
|
|
|
|
|
58
|
grep !$modules{$_}++, |
98
|
|
|
|
|
|
|
map join('::', @pre, $_), |
99
|
|
|
|
|
|
|
grep !/\W/, |
100
|
|
|
|
|
|
|
@mods; |
101
|
|
|
|
|
|
|
|
102
|
16
|
|
|
|
|
463
|
unshift @search, |
103
|
|
|
|
|
|
|
map [ $_->[0], @pre, $_->[1] ], |
104
|
|
|
|
|
|
|
grep -d $_->[0], |
105
|
|
|
|
|
|
|
map [ File::Spec->catdir($dir, $_) => $_ ], |
106
|
|
|
|
|
|
|
grep !/\W/, |
107
|
|
|
|
|
|
|
@found; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
8
|
return @modules; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub pod_coverage_ok { |
114
|
3
|
|
|
3
|
1
|
8
|
my $module = shift; |
115
|
3
|
50
|
|
|
|
15
|
my %opts = ref $_[0] eq 'HASH' ? %{ +shift } : (); |
|
0
|
|
|
|
|
0
|
|
116
|
3
|
|
33
|
|
|
17
|
my $msg = shift || "Pod coverage on $module"; |
117
|
|
|
|
|
|
|
|
118
|
3
|
|
|
|
|
11
|
$opts{package} = $module; |
119
|
|
|
|
|
|
|
|
120
|
3
|
|
50
|
|
|
16
|
my $class = delete $opts{coverage_class} || 'Pod::Coverage::TrustMe'; |
121
|
3
|
|
|
|
|
22
|
(my $mod = "$class.pm") =~ s{::}{/}g; |
122
|
3
|
|
|
|
|
536
|
require $mod; |
123
|
|
|
|
|
|
|
|
124
|
3
|
|
|
|
|
25
|
my $cover = $class->new(%opts); |
125
|
|
|
|
|
|
|
|
126
|
3
|
|
33
|
|
|
11
|
our $Test ||= Test::Builder->new; |
127
|
3
|
|
|
|
|
8
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
128
|
|
|
|
|
|
|
|
129
|
3
|
|
|
|
|
5
|
my $ok; |
130
|
3
|
|
|
|
|
10
|
my $rating = $cover->coverage; |
131
|
3
|
50
|
|
|
|
11
|
if (!defined $rating) { |
132
|
0
|
|
|
|
|
0
|
my $why = $cover->why_unrated; |
133
|
0
|
|
|
|
|
0
|
$ok = $Test->ok( defined $cover->symbols, $msg ); |
134
|
0
|
|
|
|
|
0
|
$Test->diag( "$module: ". $cover->why_unrated ); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
else { |
137
|
3
|
|
|
|
|
83
|
$ok = $Test->is_eq((map sprintf('%3.0f%%', $_ * 100), $rating, 1), $msg); |
138
|
3
|
50
|
|
|
|
2375
|
if (!$ok) { |
139
|
0
|
|
|
|
|
0
|
$Test->diag(join('', |
140
|
|
|
|
|
|
|
"Naked subroutines:\n", |
141
|
|
|
|
|
|
|
map " $_\n", $cover->uncovered, |
142
|
|
|
|
|
|
|
)); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
} |
145
|
3
|
|
|
|
|
85
|
return $ok; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub all_pod_coverage_ok { |
149
|
1
|
50
|
|
1
|
1
|
85
|
my %opts = ref $_[0] eq 'HASH' ? %{ +shift } : (); |
|
0
|
|
|
|
|
0
|
|
150
|
1
|
|
|
|
|
3
|
my $dirs = delete $opts{dirs}; |
151
|
1
|
50
|
|
|
|
2
|
my @modules = all_modules(@{ $dirs || [] }); |
|
1
|
|
|
|
|
9
|
|
152
|
|
|
|
|
|
|
|
153
|
1
|
|
33
|
|
|
23
|
our $Test ||= Test::Builder->new; |
154
|
1
|
|
|
|
|
19
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
155
|
1
|
|
|
|
|
2
|
my $ok = 1; |
156
|
|
|
|
|
|
|
|
157
|
1
|
50
|
|
|
|
4
|
if ( @modules ) { |
158
|
1
|
|
|
|
|
5
|
$Test->plan( tests => scalar @modules ); |
159
|
|
|
|
|
|
|
|
160
|
1
|
|
|
|
|
841
|
for my $module ( @modules ) { |
161
|
3
|
50
|
|
|
|
11
|
pod_coverage_ok( $module, @_ ) or $ok = 0; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
else { |
165
|
0
|
|
|
|
|
0
|
$Test->plan( tests => 1 ); |
166
|
0
|
|
|
|
|
0
|
$Test->ok( 1, "No modules found." ); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
1
|
|
|
|
|
153
|
return $ok; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |
173
|
|
|
|
|
|
|
__END__ |