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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#!/usr/bin/env perl
# $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/consistent_version_numbers.t $
# $Date: 2010-03-14 17:05:21 -0500 (Sun, 14 Mar 2010) $
# $Author: clonezone $
# $Revision: 3789 $
# Taken from
# http://www.chrisdolan.net/talk/index.php/2005/11/14/private-regression-tests/.
use 5.006;
use strict;
use warnings;
our $VERSION = '1.000001';
use File::Find;
use File::Slurp;
use Test::More qw(no_plan);
my $last_version = undef;
find({wanted => \&check_version, no_chdir => 1}, 'blib');
if (! defined $last_version) {
## no critic (RequireInterpolationOfMetachars)
fail('Failed to find any files with $VERSION');
## use critic
} # end if
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 [^\n]* ) /gxms;
if (@version_lines == 0) {
fail($_);
} # end if
foreach my $line (@version_lines) {
if (!defined $last_version) {
$last_version = shift @version_lines;
pass($_);
} else {
is($line, $last_version, $_);
} # end if
} # end foreach
return;
} # end check_version()
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 78
# indent-tabs-mode: nil
# c-indentation-style: bsd
# End:
# setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab :
# setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent :
# setup vim: set foldmethod=indent foldlevel=0 :
|