diff --git a/t/00_local_versionsync.t b/t/00_local_versionsync.t new file mode 100644 index 00000000..b6a9a43c --- /dev/null +++ b/t/00_local_versionsync.t @@ -0,0 +1,43 @@ +#!/usr/bin/perl +# 00_local_versionsync.t - Private test to check all version numbers match +# $Id$ + +use warnings; +use strict; +use File::Find; +use Test::More qw(no_plan); + +eval "use File::Slurp"; +plan skip_all => "File::Slurp required for testing version sync" + if $@; + +my $last_version = undef; +find({wanted => \&check_version, no_chdir => 1}, 'blib'); +if (! defined $last_version) { + fail('Failed to find any files with $VERSION'); +} + +sub check_version { + # $_ is the full path to the file + return if (! m{blib/script/}xms && ! m{\.pm \z}xms); + + my $content = read_file($_); + + # only look at perl scripts, not sh scripts + return if (m{blib/script/}xms && $content !~ m/\A \#![^\r\n]+?perl/xms); + + my @version_lines = $content =~ m/ ( [^\n]* \$VERSION\s= [^\n]* ) /gxms; + if (@version_lines == 0) { + fail($_); + } + for my $line (@version_lines) { + if (!defined $last_version) { + $last_version = shift @version_lines; + pass($_); + } + else { + is($line, $last_version, $_); + } + } +} +