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