line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::ConsistentVersion; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
109162
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
98
|
|
4
|
3
|
|
|
3
|
|
5886
|
use autodie; |
|
3
|
|
|
|
|
79953
|
|
|
3
|
|
|
|
|
23
|
|
5
|
3
|
|
|
3
|
|
22034
|
use strict; |
|
3
|
|
|
|
|
19
|
|
|
3
|
|
|
|
|
119
|
|
6
|
3
|
|
|
3
|
|
18
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
254
|
|
7
|
3
|
|
|
3
|
|
17
|
use Test::Builder; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
74
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
2996
|
use version; our $VERSION = qv('0.2.3'); |
|
3
|
|
|
|
|
7891
|
|
|
3
|
|
|
|
|
22
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $TEST = Test::Builder->new; |
12
|
|
|
|
|
|
|
my %ARGS; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub check_consistent_versions { |
15
|
2
|
|
|
2
|
1
|
88015
|
%ARGS = @_; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
11
|
my @modules = _find_modules(); |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
7
|
my $file_count = @modules; |
20
|
2
|
50
|
|
|
|
17
|
unless(@modules) { |
21
|
0
|
|
|
|
|
0
|
$TEST->diag('No files to get version from.'); |
22
|
|
|
|
|
|
|
} |
23
|
2
|
|
|
|
|
6
|
my $test_count = $file_count; |
24
|
2
|
50
|
|
|
|
10
|
unless($ARGS{no_pod}) { |
25
|
2
|
|
|
|
|
4
|
eval { require Test::Pod::Content; }; |
|
2
|
|
|
|
|
19
|
|
26
|
|
|
|
|
|
|
|
27
|
2
|
50
|
|
|
|
10
|
if ($@) { |
28
|
0
|
|
|
|
|
0
|
$TEST->diag('Test::Pod::Content required to test POD version consistency'); |
29
|
0
|
|
|
|
|
0
|
$ARGS{no_pod} = 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
2
|
|
|
|
|
5
|
$test_count+=$file_count |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
2
|
50
|
|
|
|
9
|
$test_count++ unless $ARGS{no_changelog}; |
36
|
2
|
50
|
|
|
|
8
|
$test_count++ unless $ARGS{no_readme}; |
37
|
2
|
50
|
|
|
|
15
|
$TEST->plan(tests => $test_count) unless $TEST->has_plan; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
## no critic (eval) |
40
|
|
|
|
|
|
|
#Find the version number |
41
|
2
|
|
|
|
|
134
|
eval "require $modules[0]"; |
42
|
2
|
|
|
|
|
619
|
my $distro_version = $modules[0]->VERSION; |
43
|
2
|
|
|
|
|
18
|
$TEST->diag("Distribution version: $distro_version"); |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
245
|
_check_module_versions($distro_version, @modules); |
46
|
2
|
50
|
|
|
|
1194
|
_check_pod_versions(@modules) unless $ARGS{no_pod}; |
47
|
2
|
50
|
|
|
|
4037
|
_check_changelog($distro_version) unless $ARGS{no_changelog}; |
48
|
2
|
50
|
|
|
|
128
|
_check_readme($distro_version) unless $ARGS{no_readme}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _find_modules { |
52
|
2
|
|
|
2
|
|
7
|
my @modules; |
53
|
|
|
|
|
|
|
|
54
|
2
|
50
|
|
|
|
12
|
if($ARGS{files}) { |
55
|
0
|
|
|
|
|
0
|
@modules = @{$ARGS{modules}}; |
|
0
|
|
|
|
|
0
|
|
56
|
|
|
|
|
|
|
} |
57
|
2
|
50
|
|
|
|
71
|
if(-e 'MANIFEST') { |
58
|
2
|
|
|
|
|
15
|
open(my $fh, '<', 'MANIFEST'); |
59
|
4
|
|
|
|
|
9
|
@modules = map { |
60
|
8
|
|
|
|
|
32
|
my $str = $_; |
61
|
4
|
|
|
|
|
21
|
$str =~ s{^lib/(.*)\.pm}{$1}; |
62
|
4
|
|
|
|
|
14
|
$str =~ s(/)(::)g; |
63
|
4
|
|
|
|
|
9
|
chomp $str; |
64
|
4
|
|
|
|
|
13
|
$str; |
65
|
|
|
|
|
|
|
} grep { |
66
|
2
|
|
|
|
|
6884
|
/^lib.*\.pm$/ |
67
|
|
|
|
|
|
|
} <$fh>; |
68
|
2
|
|
|
|
|
14
|
close $fh; |
69
|
|
|
|
|
|
|
} |
70
|
2
|
|
|
|
|
1975
|
return @modules; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _check_pod_versions { |
74
|
2
|
|
|
2
|
|
8
|
my @modules = @_; |
75
|
2
|
50
|
|
|
|
8
|
unless(@modules) { |
76
|
0
|
|
|
|
|
0
|
$TEST->diag('No files to check POD of.'); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
## no critic (eval) |
80
|
2
|
|
|
|
|
6
|
foreach my $module (@modules) { |
81
|
4
|
50
|
|
|
|
5588
|
eval "require $module" or $TEST->diag($@); |
82
|
4
|
|
|
|
|
81
|
my $module_version = $module->VERSION; |
83
|
4
|
|
|
|
|
121
|
Test::Pod::Content::pod_section_like( $module, 'VERSION', qr{(^|\s)\Q$module_version\E(\s|$)}, "$module POD version is the same as module version") |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub _check_module_versions { |
88
|
2
|
|
|
2
|
|
7
|
my $version = shift; |
89
|
2
|
|
|
|
|
7
|
my @modules = @_; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
## no critic (eval) |
92
|
2
|
|
|
|
|
6
|
foreach my $module (@modules) { |
93
|
4
|
50
|
|
|
|
881
|
eval "require $module" or $TEST->diag($@); |
94
|
4
|
|
|
|
|
470
|
$TEST->is_eq($module->VERSION, $version, "$module is the same as the distribution version"); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _check_changelog { |
99
|
2
|
|
|
2
|
|
7
|
my $version = shift; |
100
|
2
|
50
|
|
|
|
40
|
if(-e 'Changes') { |
101
|
2
|
|
|
|
|
13
|
open(my $fh, '<', 'Changes'); |
102
|
2
|
|
|
|
|
212
|
my $version_check = quotemeta($version); |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
|
|
40
|
my $changelog = join "\n", <$fh>; |
105
|
2
|
|
|
|
|
38
|
$TEST->like($changelog, qr{\b$version_check\b}, 'Changelog includes reference to the distribution version: ' . $version); |
106
|
2
|
|
|
|
|
892
|
close $fh; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
else { |
109
|
0
|
|
|
|
|
0
|
$TEST->ok(0, 'Unable to find Changes file'); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub _check_readme { |
114
|
2
|
|
|
2
|
|
6
|
my $version = shift; |
115
|
2
|
100
|
|
|
|
30
|
if(-e 'README') { |
116
|
1
|
|
|
|
|
5
|
open(my $fh, '<', 'README'); |
117
|
1
|
|
|
|
|
92
|
my $version_check = quotemeta($version); |
118
|
|
|
|
|
|
|
|
119
|
1
|
|
|
|
|
21
|
my $readme = join "\n", <$fh>; |
120
|
1
|
|
|
|
|
20
|
$TEST->like($readme, qr{\b$version_check\b}, 'README file includes reference to the distribution version: ' . $version); |
121
|
1
|
|
|
|
|
346
|
close $fh; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
else { |
124
|
1
|
|
|
|
|
5
|
$TEST->ok(0, 'Unable to find README file'); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
__END__ |