line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::CPAN::Changes; |
2
|
1
|
|
|
1
|
|
71100
|
use strict; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
476
|
use CPAN::Changes::Parser; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
51
|
|
6
|
1
|
|
|
1
|
|
9
|
use Test::Builder; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
7
|
1
|
|
|
1
|
|
533
|
use version (); |
|
1
|
|
|
|
|
1998
|
|
|
1
|
|
|
|
|
56
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.500_001'; |
10
|
|
|
|
|
|
|
$VERSION =~ tr/_//d; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
7
|
use Exporter; BEGIN { *import = \&Exporter::import }; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
|
1
|
|
|
|
|
139
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT = qw(changes_ok changes_file_ok); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $Test = Test::Builder->new; |
17
|
|
|
|
|
|
|
our $Parser = CPAN::Changes::Parser->new( |
18
|
|
|
|
|
|
|
_release_class => 'Test::CPAN::Changes::Release', |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub changes_ok { |
22
|
0
|
|
|
0
|
1
|
0
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
23
|
0
|
|
|
|
|
0
|
my ($arg) = @_; |
24
|
0
|
0
|
0
|
|
|
0
|
$Test->plan( tests => ( $arg && defined $arg->{version} ? 6 : 4 ) ); |
25
|
0
|
|
|
|
|
0
|
return changes_file_ok( undef, @_ ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
package |
30
|
|
|
|
|
|
|
Test::CPAN::Changes::Release; |
31
|
1
|
|
|
1
|
|
7
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
32
|
|
|
|
|
|
|
extends 'CPAN::Changes::Release'; |
33
|
|
|
|
|
|
|
has raw_date => (is => 'ro'); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub changes_file_ok { |
37
|
8
|
|
|
8
|
1
|
428
|
my ( $file, $arg ) = @_; |
38
|
8
|
|
50
|
|
|
22
|
$file ||= 'Changes'; |
39
|
8
|
|
100
|
|
|
36
|
$arg ||= {}; |
40
|
|
|
|
|
|
|
|
41
|
8
|
|
|
|
|
11
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
42
|
|
|
|
|
|
|
|
43
|
8
|
100
|
|
|
|
24
|
my $tests = defined $arg->{version} ? 6 : 4; |
44
|
8
|
|
|
|
|
10
|
my $ok = 1; |
45
|
|
|
|
|
|
|
|
46
|
8
|
|
|
|
|
11
|
my $changes; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$Test->ok( |
49
|
8
|
|
|
|
|
24
|
!!eval { $changes = $Parser->parse_file( $file ); 1 }, |
|
8
|
|
|
|
|
4572
|
|
50
|
|
|
|
|
|
|
"$file is loadable" |
51
|
8
|
50
|
|
|
|
16
|
) or do { |
52
|
0
|
|
|
|
|
0
|
$Test->diag("Error: $@"); |
53
|
0
|
|
|
|
|
0
|
$Test->skip("can't test unparsable change log") for 2 .. $tests; |
54
|
0
|
|
|
|
|
0
|
return !1; |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my @releases = |
58
|
|
|
|
|
|
|
map $_->[0], |
59
|
8
|
|
|
|
|
176
|
sort { $a->[1] <=> $b->[1] } |
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
map [$_, $_->line], |
61
|
|
|
|
|
|
|
$changes->releases; |
62
|
|
|
|
|
|
|
|
63
|
8
|
100
|
|
|
|
153
|
$Test->ok( !!@releases, "$file contains at least one release" ) or $ok = 0; |
64
|
|
|
|
|
|
|
|
65
|
8
|
|
|
|
|
116
|
my $date_err; |
66
|
8
|
|
|
|
|
20
|
for my $release ( @releases ) { |
67
|
7
|
100
|
66
|
|
|
37
|
if ( !defined $release->date || $release->date eq '' ) { |
68
|
1
|
|
|
|
|
9
|
$date_err = 'No date for version '.$release->version.' (line '.$release->line.')'; |
69
|
1
|
|
|
|
|
3
|
last; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
6
|
|
|
|
|
14
|
my $d = $release->raw_date; |
73
|
6
|
50
|
66
|
|
|
191
|
if ( |
74
|
|
|
|
|
|
|
$d !~ m{^${CPAN::Changes::Parser::_ISO_8601_DATE}$} |
75
|
|
|
|
|
|
|
&& $d !~ m{^(${CPAN::Changes::Parser::_UNKNOWN_DATE})$} |
76
|
|
|
|
|
|
|
) { |
77
|
1
|
|
|
|
|
27
|
$Test->note( 'Date "' . $d . '" is not in the recommended W3CDTF format, should be "'.$release->date.'" (line '.$release->line.')' ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
8
|
100
|
|
|
|
59
|
$Test->ok( !defined $date_err, "$file contains all valid release dates" ) |
81
|
|
|
|
|
|
|
or $Test->diag(' ERR: '.$date_err), $ok = 0; |
82
|
|
|
|
|
|
|
|
83
|
8
|
|
|
|
|
130
|
my $version_err; |
84
|
8
|
|
|
|
|
16
|
for my $release ( @releases ) { |
85
|
|
|
|
|
|
|
# strip off -TRIAL before testing |
86
|
7
|
|
|
|
|
30
|
(my $version = $release->version) =~ s/-TRIAL$//; |
87
|
7
|
100
|
|
|
|
18
|
if ( not version::is_lax($version) ) { |
88
|
1
|
|
|
|
|
19
|
$version_err = $release->version . ' (line '.$release->line.')'; |
89
|
1
|
|
|
|
|
3
|
last; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
8
|
100
|
|
|
|
199
|
$Test->ok( !defined $version_err, "$file contains all valid release versions" ) |
93
|
|
|
|
|
|
|
or $Test->diag(' ERR: '.$version_err), $ok = 0; |
94
|
|
|
|
|
|
|
|
95
|
8
|
100
|
|
|
|
140
|
if ( defined $arg->{version} ) { |
96
|
3
|
|
|
|
|
5
|
my $v = $arg->{version}; |
97
|
|
|
|
|
|
|
|
98
|
3
|
|
|
|
|
19
|
my $release = $changes->release( $v ); |
99
|
3
|
100
|
|
|
|
23
|
if ($Test->ok( !!$release, "$file has an entry for version $v" )) { |
100
|
2
|
|
|
|
|
79
|
my $entries = $release->entries; |
101
|
2
|
100
|
|
|
|
29
|
$Test->ok( !!@$entries, "$file version $v has content") |
102
|
|
|
|
|
|
|
or $ok = 0; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
else { |
105
|
1
|
|
|
|
|
28
|
$Test->skip("can't check for entries in nonexistant version"); |
106
|
1
|
|
|
|
|
12
|
$ok = 0; |
107
|
|
|
|
|
|
|
}; |
108
|
|
|
|
|
|
|
} |
109
|
8
|
|
|
|
|
78
|
return !!$ok; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |