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
|
#!perl
# Expected to be run from ../ (make test) or ../blib/ (make disttest)
use strict;
use warnings;
use Test::More;
BEGIN {
if ( $ENV{ DEVEL_TESTS } ) {
plan tests => 3;
} else {
plan skip_all => "Version checks are only performed when DEVEL_TESTS=1";
}
}
sub slurp_file {
my $qfn = shift;
open( my $fh, '<', $qfn )
or die( "Can't open \"$qfn\": $!\n" );
local $/;
return <$fh>;
}
{
my $base_file = slurp_file( 'lib/DateTime/Format/RFC3339.pm' );
my $changes_file = slurp_file( 'Changes' );
my ( $version ) = $base_file =~ /\bqv\(\s*'v([^']*)'\s*\)/
or die( "Can't find version\n" );
my @parts = split( /\./, $version );
my ( $pod_version ) = $base_file =~ /^Version (\S+)/m
or die( "Can't find version in POD\n" );
my ( $changes_version ) = $changes_file =~ /^([0-9]\S*)/m
or die( "Can't find version in Changes file\n" );
is( $pod_version, $version, "Version in POD matches actual version" );
ok( $parts[1] % 2 == 0, "Version is a release version" );
is( $changes_version, $version, "Version in Changes file matches actual version" );
}
|