| 1 |
use Test::More tests => 2; |
| 2 |
|
| 3 |
note 'Checking Changes'; |
| 4 |
my $changes_file = 'Changes'; |
| 5 |
my $newver = '0.650'; |
| 6 |
my $trial_token = '-TRIAL'; |
| 7 |
my $encoding = 'UTF-8'; |
| 8 |
|
| 9 |
SKIP: { |
| 10 |
ok(-e $changes_file, "$changes_file file exists") |
| 11 |
or skip 'Changes is missing', 1; |
| 12 |
|
| 13 |
ok(_get_changes($newver), "$changes_file has content for $newver"); |
| 14 |
} |
| 15 |
|
| 16 |
done_testing; |
| 17 |
|
| 18 |
sub _get_changes |
| 19 |
{ |
| 20 |
my $newver = shift; |
| 21 |
|
| 22 |
# parse changelog to find commit message |
| 23 |
open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!"; |
| 24 |
my $changelog = join('', <$fh>); |
| 25 |
if ($encoding) { |
| 26 |
require Encode; |
| 27 |
$changelog = Encode::decode($encoding, $changelog, Encode::FB_CROAK()); |
| 28 |
} |
| 29 |
close $fh; |
| 30 |
|
| 31 |
my @content = |
| 32 |
grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented |
| 33 |
split /\n/, $changelog; |
| 34 |
shift @content; # drop the version line |
| 35 |
|
| 36 |
# drop unindented last line and trailing blank lines |
| 37 |
pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); |
| 38 |
|
| 39 |
# return number of non-blank lines |
| 40 |
return scalar @content; |
| 41 |
} |
| 42 |
|