line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Version; |
2
|
18
|
|
|
18
|
|
1307319
|
use 5.006; |
|
18
|
|
|
|
|
186
|
|
3
|
18
|
|
|
18
|
|
109
|
use strict; |
|
18
|
|
|
|
|
30
|
|
|
18
|
|
|
|
|
410
|
|
4
|
18
|
|
|
18
|
|
83
|
use warnings; |
|
18
|
|
|
|
|
29
|
|
|
18
|
|
|
|
|
417
|
|
5
|
18
|
|
|
18
|
|
88
|
use Carp; |
|
18
|
|
|
|
|
29
|
|
|
18
|
|
|
|
|
1820
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '2.08_01'; # TRIAL VERSION |
8
|
|
|
|
|
|
|
|
9
|
18
|
|
|
18
|
|
8567
|
use parent 'Exporter'; |
|
18
|
|
|
|
|
4961
|
|
|
18
|
|
|
|
|
92
|
|
10
|
18
|
|
|
18
|
|
985
|
use Test::Builder; |
|
18
|
|
|
|
|
33
|
|
|
18
|
|
|
|
|
471
|
|
11
|
18
|
|
|
18
|
|
8265
|
use version 0.86 qw( is_lax is_strict ); |
|
18
|
|
|
|
|
35802
|
|
|
18
|
|
|
|
|
125
|
|
12
|
18
|
|
|
18
|
|
10371
|
use File::Find::Rule::Perl; |
|
18
|
|
|
|
|
322876
|
|
|
18
|
|
|
|
|
161
|
|
13
|
18
|
|
|
18
|
|
2957
|
use Test::More; |
|
18
|
|
|
|
|
18184
|
|
|
18
|
|
|
|
|
100
|
|
14
|
18
|
|
|
18
|
|
17064
|
use Module::Metadata 1.000020; |
|
18
|
|
|
|
|
108605
|
|
|
18
|
|
|
|
|
23004
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw( version_all_ok ); ## no critic (Modules::ProhibitAutomaticExportation) |
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw( version_ok ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $cfg; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub import { ## no critic qw( Subroutines::RequireArgUnpacking Subroutines::RequireFinalReturn ) |
22
|
22
|
|
|
22
|
|
20668
|
my @exports; |
23
|
22
|
|
|
|
|
55
|
foreach my $param ( @_ ) { |
24
|
58
|
100
|
|
|
|
167
|
unless ( ref( $param ) eq 'HASH' ) { |
25
|
39
|
|
|
|
|
90
|
push @exports, $param; |
26
|
|
|
|
|
|
|
} else { |
27
|
19
|
|
|
|
|
59
|
$cfg = $param |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$cfg->{is_strict} |
32
|
|
|
|
|
|
|
= defined $cfg->{is_strict} ? $cfg->{is_strict} |
33
|
22
|
100
|
|
|
|
73
|
: 0 |
34
|
|
|
|
|
|
|
; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$cfg->{has_version} |
37
|
|
|
|
|
|
|
= defined $cfg->{has_version} ? $cfg->{has_version} |
38
|
22
|
100
|
|
|
|
112
|
: 1 |
39
|
|
|
|
|
|
|
; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$cfg->{consistent} |
42
|
|
|
|
|
|
|
= defined $cfg->{consistent} ? $cfg->{consistent} |
43
|
22
|
100
|
|
|
|
57
|
: 0 |
44
|
|
|
|
|
|
|
; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$cfg->{filename_match} |
47
|
|
|
|
|
|
|
= defined $cfg->{filename_match} ? $cfg->{filename_match} |
48
|
22
|
100
|
|
|
|
74
|
: [] |
49
|
|
|
|
|
|
|
; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$cfg->{multiple} |
52
|
|
|
|
|
|
|
= defined $cfg->{multiple} ? $cfg->{multiple} |
53
|
22
|
100
|
|
|
|
60
|
: 0 |
54
|
|
|
|
|
|
|
; |
55
|
|
|
|
|
|
|
|
56
|
22
|
100
|
|
|
|
96
|
unless(ref($cfg->{filename_match}) eq 'ARRAY') { |
57
|
3
|
|
|
|
|
8
|
$cfg->{filename_match} = [$cfg->{filename_match}]; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
22
|
|
|
|
|
217
|
my $mmv = version->parse( $Module::Metadata::VERSION ); |
61
|
22
|
|
|
|
|
101
|
my $rec = version->parse( '1.000020' ); |
62
|
22
|
100
|
66
|
|
|
839
|
if ( $mmv >= $rec && ! defined $cfg->{ignore_unindexable} ) { |
63
|
7
|
|
|
|
|
16
|
$cfg->{ignore_unindexable} = 1; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
22
|
|
|
|
|
19849
|
__PACKAGE__->export_to_level( 1, @exports ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $version_counter = 0; |
70
|
|
|
|
|
|
|
my $version_number; |
71
|
|
|
|
|
|
|
my $consistent = 1; |
72
|
|
|
|
|
|
|
my %versions; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $test = Test::Builder->new; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
our $_IN_VERSION_ALL_OK = 0; |
77
|
|
|
|
|
|
|
our %FILE_FIND_RULE_EXTRAS = ( |
78
|
|
|
|
|
|
|
untaint => 1, |
79
|
|
|
|
|
|
|
($^O eq 'MSWin32' ? (untaint_pattern => qr|^(([a-zA-Z]:)?[-+@\w./]+)$|x) : ()), |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub version_ok { |
84
|
73
|
|
|
73
|
1
|
28292
|
my ( $file, $name ) = @_; |
85
|
73
|
|
100
|
|
|
263
|
$file ||= ''; |
86
|
73
|
|
33
|
|
|
555
|
$name ||= "check version in '$file'"; |
87
|
|
|
|
|
|
|
|
88
|
73
|
100
|
|
|
|
213
|
croak 'No file passed to version_ok().' unless $file; |
89
|
|
|
|
|
|
|
|
90
|
72
|
100
|
|
|
|
1600
|
croak "'$file' doesn't exist." unless -e $file; |
91
|
|
|
|
|
|
|
|
92
|
71
|
|
|
|
|
494
|
my $info = Module::Metadata->new_from_file( $file ); |
93
|
71
|
50
|
66
|
|
|
51029
|
if ( $cfg->{ignore_unindexable} && ! $info->is_indexable) { |
94
|
0
|
|
|
|
|
0
|
$test->skip( "$file not indexable" ); |
95
|
0
|
|
|
|
|
0
|
return 0; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
71
|
100
|
|
|
|
389
|
if(@{ $cfg->{filename_match} } > 0) { |
|
71
|
|
|
|
|
209
|
|
99
|
12
|
|
|
|
|
16
|
my $match = 0; |
100
|
12
|
|
|
|
|
32
|
foreach my $pattern (@{ $cfg->{filename_match} }) { |
|
12
|
|
|
|
|
29
|
|
101
|
|
|
|
|
|
|
|
102
|
12
|
100
|
|
|
|
37
|
if(ref($pattern) eq 'Regexp') { |
|
|
100
|
|
|
|
|
|
103
|
3
|
100
|
|
|
|
17
|
$match = 1 if $file =~ $pattern; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
elsif(ref($pattern) eq 'CODE') { |
107
|
3
|
100
|
|
|
|
9
|
$match = 1 if $pattern->($file); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
else { |
111
|
6
|
100
|
|
|
|
19
|
$match = 1 if $file eq $pattern; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
12
|
100
|
|
|
|
47
|
last if $match; |
115
|
|
|
|
|
|
|
} |
116
|
12
|
100
|
|
|
|
26
|
unless ($match) { |
117
|
8
|
|
|
|
|
76
|
$test->skip( "$file does not match filename_match" ); |
118
|
8
|
|
|
|
|
1679
|
return 0; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
63
|
|
|
|
|
108
|
my $ok = 1; |
123
|
63
|
|
|
|
|
107
|
my @diag; |
124
|
63
|
100
|
|
|
|
289
|
my @packages = $cfg->{multiple} ? $info->packages_inside : ($info->name); |
125
|
|
|
|
|
|
|
|
126
|
63
|
100
|
|
|
|
335
|
unless($_IN_VERSION_ALL_OK) { |
127
|
11
|
|
|
|
|
22
|
$consistent = 1; |
128
|
11
|
|
|
|
|
18
|
$version_number = undef; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
63
|
100
|
|
|
|
198
|
unless($cfg->{has_version}) { |
132
|
25
|
|
|
|
|
55
|
@packages = grep { $info->version($_) } @packages; |
|
25
|
|
|
|
|
71
|
|
133
|
25
|
100
|
|
|
|
492
|
unless(@packages) { |
134
|
6
|
|
|
|
|
76
|
$test->skip(qq{No versions were found in "$file" and has_version is false}); |
135
|
6
|
|
|
|
|
1242
|
$consistent = 0; |
136
|
6
|
|
|
|
|
26
|
$versions{$file}->{$info->name} = undef; |
137
|
6
|
|
|
|
|
56
|
return 1; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
57
|
50
|
|
|
|
126
|
unless(@packages) { |
142
|
0
|
|
|
|
|
0
|
$ok = 0; |
143
|
0
|
|
|
|
|
0
|
push @diag, "No packages found in '$file'"; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
57
|
|
|
|
|
121
|
foreach my $package (@packages) { |
147
|
|
|
|
|
|
|
|
148
|
63
|
|
|
|
|
162
|
my $version = $info->version($package); |
149
|
|
|
|
|
|
|
|
150
|
63
|
|
|
|
|
753
|
$versions{$file}->{$package} = $version; |
151
|
|
|
|
|
|
|
|
152
|
63
|
100
|
|
|
|
147
|
if (not defined $version) { |
153
|
10
|
|
|
|
|
17
|
$consistent = 0; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
63
|
|
|
|
|
90
|
$version_counter++; |
157
|
|
|
|
|
|
|
|
158
|
63
|
100
|
|
|
|
535
|
unless ( $version ) { |
159
|
10
|
|
|
|
|
16
|
$ok = 0; |
160
|
10
|
|
|
|
|
49
|
push @diag, "No version was found in '$file' ($package)."; |
161
|
10
|
|
|
|
|
27
|
next; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
53
|
100
|
|
|
|
217
|
unless (defined $version_number) { |
165
|
21
|
|
|
|
|
35
|
$version_number = $version; |
166
|
|
|
|
|
|
|
} |
167
|
53
|
100
|
|
|
|
230
|
if ($version ne $version_number) { |
168
|
27
|
|
|
|
|
50
|
$consistent = 0; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
53
|
100
|
|
|
|
152
|
unless ( is_lax( $version ) ) { |
172
|
3
|
|
|
|
|
110
|
$ok = 0; |
173
|
3
|
|
|
|
|
20
|
push @diag, "The version '$version' found in '$file' ($package) is invalid."; |
174
|
3
|
|
|
|
|
13
|
next; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
50
|
100
|
|
|
|
1794
|
if ( $cfg->{is_strict} ) { |
178
|
1
|
50
|
|
|
|
3
|
unless ( is_strict( $version ) ) { |
179
|
1
|
|
|
|
|
42
|
$ok = 0; |
180
|
1
|
|
|
|
|
6
|
push @diag, "The version '$version' found in '$file' ($package) is not strict."; |
181
|
1
|
|
|
|
|
4
|
next; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
57
|
100
|
|
|
|
139
|
unless($_IN_VERSION_ALL_OK) { |
187
|
11
|
100
|
100
|
|
|
67
|
if($ok && ! $consistent && $cfg->{consistent}) { |
|
|
|
100
|
|
|
|
|
188
|
1
|
|
|
|
|
2
|
$ok = 0; |
189
|
1
|
|
|
|
|
3
|
push @diag, "The versions found in '$file' are inconsistent."; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
57
|
|
|
|
|
432
|
$test->ok( $ok, $name ); |
194
|
57
|
|
|
|
|
24915
|
$test->diag($_) for @diag; |
195
|
57
|
|
|
|
|
2626
|
return $ok; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub version_all_ok { |
199
|
12
|
|
|
12
|
1
|
3239
|
my ( $dir, $name ) = @_; |
200
|
|
|
|
|
|
|
|
201
|
12
|
|
|
|
|
22
|
$version_counter = 0; |
202
|
12
|
|
|
|
|
23
|
$version_number = undef; |
203
|
12
|
|
|
|
|
19
|
$consistent = 1; |
204
|
12
|
|
|
|
|
28
|
%versions = (); |
205
|
|
|
|
|
|
|
|
206
|
12
|
0
|
|
|
|
58
|
$dir |
|
|
50
|
|
|
|
|
|
207
|
|
|
|
|
|
|
= defined $dir ? $dir |
208
|
|
|
|
|
|
|
: -d 'blib' ? 'blib' |
209
|
|
|
|
|
|
|
: 'lib' |
210
|
|
|
|
|
|
|
; |
211
|
|
|
|
|
|
|
|
212
|
12
|
50
|
|
|
|
292
|
croak $dir . ' does not exist, or is not a directory' unless -d $dir; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# Report failure location correctly - GH #1 |
215
|
12
|
|
|
|
|
40
|
local $Test::Builder::Level = $Test::Builder::Level + 1; ## no critic (Variables::ProhibitPackageVars) |
216
|
|
|
|
|
|
|
|
217
|
12
|
|
33
|
|
|
86
|
$name ||= "all modules in $dir have valid versions"; |
218
|
|
|
|
|
|
|
|
219
|
12
|
|
|
|
|
86
|
my @files = File::Find::Rule->perl_module->extras(\%FILE_FIND_RULE_EXTRAS)->in($dir); |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
{ |
222
|
12
|
|
|
|
|
21535
|
local $_IN_VERSION_ALL_OK = 1; |
|
12
|
|
|
|
|
31
|
|
223
|
12
|
|
|
|
|
28
|
foreach my $file ( @files ) { |
224
|
60
|
|
|
|
|
134
|
version_ok( $file ); |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
12
|
100
|
100
|
|
|
84
|
if ($cfg->{consistent} and not $consistent) { |
229
|
3
|
|
|
|
|
398
|
$test->ok( 0, $name ); |
230
|
3
|
|
|
|
|
1129
|
$test->diag('The version numbers in this distribution are not the same'); |
231
|
3
|
|
|
|
|
418
|
foreach my $file (sort keys %versions) { |
232
|
8
|
|
|
|
|
649
|
foreach my $package (sort keys %{ $versions{$file} }) { |
|
8
|
|
|
|
|
27
|
|
233
|
8
|
|
|
|
|
16
|
my $version = $versions{$file}->{$package}; |
234
|
8
|
100
|
|
|
|
82
|
$test->diag(sprintf "%10s %s (%s)", defined $version ? $version : 'undef', $file, $package); |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
} |
237
|
3
|
|
|
|
|
394
|
return; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# has at least 1 version in the dist |
241
|
9
|
100
|
100
|
|
|
50
|
if ( not $cfg->{has_version} and $version_counter < 1 ) { |
242
|
1
|
|
|
|
|
7
|
$test->ok( 0, $name ); |
243
|
1
|
|
|
|
|
424
|
$test->diag( |
244
|
|
|
|
|
|
|
'Your dist has no valid versions defined. ' |
245
|
|
|
|
|
|
|
. 'Must have at least one version' |
246
|
|
|
|
|
|
|
); |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
else { |
249
|
8
|
|
|
|
|
48
|
$test->ok( 1, $name ); |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
9
|
|
|
|
|
3448
|
return; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
1; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
# ABSTRACT: Check to see that version's in modules are sane |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
__END__ |