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