Skip to content

Instantly share code, notes, and snippets.

@jbarrett
Created November 27, 2013 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbarrett/7680305 to your computer and use it in GitHub Desktop.
Save jbarrett/7680305 to your computer and use it in GitHub Desktop.
Check Module, Dist::Zilla's dist.ini, POD and Changelog version number consistency. Probably better to let Dist::Zilla do versioning and changelog generation, but there you go.
BEGIN {
unless ($ENV{AUTHOR_TESTING}) {
require Test::More;
Test::More::plan(skip_all => 'these tests are for testing by the author');
}
}
use strict;
use warnings;
use autodie;
use Test::More tests => 3;
use Module::Metadata;
use FindBin;
open my $changes, '<', "$FindBin::Bin/../Changes";
my ($changes_latest_version) = grep { s/^([0-9]+\.[0-9]+).*/$1/s } (<$changes>);
close $changes;
open my $dist, '<', "$FindBin::Bin/../dist.ini";
my ($dist_version) = grep { s/^version = ([0-9]+\.[0-9]+).*/$1/is } (<$dist>);
close $dist;
my $module = Module::Metadata->new_from_module('My::Module', collect_pod => 1);
(my $pod_version = $module->pod('VERSION')) =~ s/.*Version\ ([0-9]+\.[0-9]+).*/$1/is;
is $module->version, $pod_version, 'POD Version matches module $VERSION';
is $module->version, $dist_version, 'dist.ini version matches module $VERSION';
is $module->version, $changes_latest_version, 'Last Changes version matches module $VERSION';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment