File: release-changes_has_content.t

package info (click to toggle)
libdist-zilla-plugin-requiresexternal-perl 1.009-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 252 kB
  • sloc: perl: 622; makefile: 4
file content (49 lines) | stat: -rw-r--r-- 1,274 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

BEGIN {
    unless ( $ENV{RELEASE_TESTING} ) {
        print qq{1..0 # SKIP these tests are for release candidate testing\n};
        exit;
    }
}

use Test::More tests => 2;

note 'Checking Changes';
my $changes_file = 'Changes';
my $newver       = '1.009';
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;

    # parse changelog to find commit message
    open( my $fh, '<', $changes_file ) or die "cannot open $changes_file: $!";
    my $changelog = join( '', <$fh> );
    if ($encoding) {
        require Encode;
        $changelog
            = Encode::decode( $encoding, $changelog, Encode::FB_CROAK() );
    }
    close $fh;

    my @content
        = grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented
        split /\n/, $changelog;
    shift @content;    # drop the version line

    # drop unindented last line and trailing blank lines
    pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ );

    # return number of non-blank lines
    return scalar @content;
}