BEGIN {
unless
(
$ENV
{RELEASE_TESTING} ) {
print
qq{1..0 # SKIP these tests are for release candidate testing\n}
;
exit
;
}
}
note
'Checking Changes'
;
my
$changes_file
=
'Changes'
;
my
$newver
=
'0.001'
;
my
$trial_token
=
'-TRIAL'
;
my
$encoding
=
'UTF-8'
;
SKIP: {
ok( -e
$changes_file
,
"$changes_file file exists"
)
or skip
'Changes is missing'
, 1;
ok( _get_changes(
$newver
),
"$changes_file has content for $newver"
);
}
done_testing;
sub
_get_changes {
my
$newver
=
shift
;
open
(
my
$fh
,
'<'
,
$changes_file
) or
die
"cannot open $changes_file: $!"
;
my
$changelog
=
join
(
''
, <
$fh
> );
if
(
$encoding
) {
$changelog
= Encode::decode(
$encoding
,
$changelog
, Encode::FB_CROAK() );
}
close
$fh
;
my
@content
=
grep
{ /^
$newver
(?:
$trial_token
)?(?:\s+|$)/ ... /^\S/ }
split
/\n/,
$changelog
;
shift
@content
;
pop
@content
while
(
@content
&&
$content
[-1] =~ /^(?:\S|\s*$)/ );
return
scalar
@content
;
}