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