Test-ConsistentVersion-v0.2.3000755000765000024 011457266335 15661 5ustar00Glennstaff000000000000Test-ConsistentVersion-v0.2.3/Build.PL000444000765000024 130611457266335 17312 0ustar00Glennstaff000000000000use strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'Test::ConsistentVersion', license => 'perl', dist_author => 'Glenn Fowler ', dist_version_from => 'lib/Test/ConsistentVersion.pm', requires => { 'Test::Builder' => 0.94, 'version' => 0, 'autodie' => 0, }, recommends => { 'Test::Pod::Content' => 0, }, meta_merge => { resources => { repository => 'http://github.com/cebjyre/Test-ConsistentVersion', }, }, add_to_cleanup => [ 'Test-ConsistentVersion-*' ], ); $builder->create_build_script(); Test-ConsistentVersion-v0.2.3/Changes000444000765000024 165511457266335 17320 0ustar00Glennstaff000000000000Revision history for Test-ConsistentVersion 0.2.3 Tue Oct 19 2010 Fixed test that was broken by change to regex in Perl v5.13.5 0.2.2 Fri Sep 18 2009 Fixed test that had a hardcoded assumption of where Test::Pod::Content lives 0.2.1 Thu Sep 17 2009 Fixed tests when Test::Pod::Content is not available 0.2.0 Thu Sep 17 2009 Improved tests No longer trying to plan tests if a plan has already been made 0.1.0 Tue Sep 15 2009 Now checking README for version consistency 0.0.4 Mon Sep 7 2009 Requiring minimum of 0.94 of Test-Simple for the subtest functionality 0.0.3 Sun Sep 6 2009 Updated MANIFEST to actually include the test developed for 0.0.2 0.0.2 Sun Sep 6 2009 Added a test, repository and recommended modules metadata 0.0.1 Sun Aug 30 2009 Initial release. Test-ConsistentVersion-v0.2.3/MANIFEST000444000765000024 62611457266335 17133 0ustar00Glennstaff000000000000Build.PL Changes lib/Test/ConsistentVersion.pm MANIFEST META.yml README t/00.load.t t/01.good.t t/02.bad.t t/perlcritic.t t/pod-coverage.t t/pod.t t/Sample-Bad/Changes t/Sample-Bad/lib/Sample/Bad.pm t/Sample-Bad/lib/Sample/StillBad.pm t/Sample-Bad/MANIFEST t/Sample-Good/Changes t/Sample-Good/lib/Sample/Good.pm t/Sample-Good/lib/Sample/StillGood.pm t/Sample-Good/MANIFEST t/Sample-Good/README t/version.t Test-ConsistentVersion-v0.2.3/META.yml000444000765000024 122211457266335 17264 0ustar00Glennstaff000000000000--- abstract: 'Ensures a CPAN distribution has consistent versioning.' author: - 'Glenn Fowler ' configure_requires: Module::Build: 0.36 generated_by: 'Module::Build version 0.3607' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Test-ConsistentVersion provides: Test::ConsistentVersion: file: lib/Test/ConsistentVersion.pm version: v0.2.3 recommends: Test::Pod::Content: 0 requires: Test::Builder: 0.94 autodie: 0 version: 0 resources: license: http://dev.perl.org/licenses/ repository: http://github.com/cebjyre/Test-ConsistentVersion version: v0.2.3 Test-ConsistentVersion-v0.2.3/README000444000765000024 160111457266335 16674 0ustar00Glennstaff000000000000Test-ConsistentVersion version 0.2.3 The purpose of this module is to make it easy for other distribution authors to have consistent version numbers within the modules (and changelog and readme) of the distribution. I recommend using Dist-Zilla with the PkgVersion, PodVersion (or PodWeaver) and NextRelease plugins as a more elegant and simple approach than this module (handling the numbering automatically, rather than informing you of what needs to be fixed); however I do still plan to fix bugs that may arise. INSTALLATION To install this module, run the following commands: perl Build.PL ./Build ./Build test ./Build install DEPENDENCIES Test::Builder autodie version Optional: Test::Pod::Content COPYRIGHT AND LICENCE Copyright (C) 2010, Glenn Fowler This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Test-ConsistentVersion-v0.2.3/lib000755000765000024 011457266335 16427 5ustar00Glennstaff000000000000Test-ConsistentVersion-v0.2.3/lib/Test000755000765000024 011457266335 17346 5ustar00Glennstaff000000000000Test-ConsistentVersion-v0.2.3/lib/Test/ConsistentVersion.pm000444000765000024 1476211457266335 23572 0ustar00Glennstaff000000000000package Test::ConsistentVersion; use warnings; use autodie; use strict; use Carp; use Test::Builder; use version; our $VERSION = qv('0.2.3'); my $TEST = Test::Builder->new; my %ARGS; sub check_consistent_versions { %ARGS = @_; my @modules = _find_modules(); my $file_count = @modules; unless(@modules) { $TEST->diag('No files to get version from.'); } my $test_count = $file_count; unless($ARGS{no_pod}) { eval { require Test::Pod::Content; }; if ($@) { $TEST->diag('Test::Pod::Content required to test POD version consistency'); $ARGS{no_pod} = 1; } else { $test_count+=$file_count } } $test_count++ unless $ARGS{no_changelog}; $test_count++ unless $ARGS{no_readme}; $TEST->plan(tests => $test_count) unless $TEST->has_plan; ## no critic (eval) #Find the version number eval "require $modules[0]"; my $distro_version = $modules[0]->VERSION; $TEST->diag("Distribution version: $distro_version"); _check_module_versions($distro_version, @modules); _check_pod_versions(@modules) unless $ARGS{no_pod}; _check_changelog($distro_version) unless $ARGS{no_changelog}; _check_readme($distro_version) unless $ARGS{no_readme}; } sub _find_modules { my @modules; if($ARGS{files}) { @modules = @{$ARGS{modules}}; } if(-e 'MANIFEST') { open(my $fh, '<', 'MANIFEST'); @modules = map { my $str = $_; $str =~ s{^lib/(.*)\.pm}{$1}; $str =~ s(/)(::)g; chomp $str; $str; } grep { /^lib.*\.pm$/ } <$fh>; close $fh; } return @modules; } sub _check_pod_versions { my @modules = @_; unless(@modules) { $TEST->diag('No files to check POD of.'); } ## no critic (eval) foreach my $module (@modules) { eval "require $module" or $TEST->diag($@); my $module_version = $module->VERSION; Test::Pod::Content::pod_section_like( $module, 'VERSION', qr{(^|\s)\Q$module_version\E(\s|$)}, "$module POD version is the same as module version") } } sub _check_module_versions { my $version = shift; my @modules = @_; ## no critic (eval) foreach my $module (@modules) { eval "require $module" or $TEST->diag($@); $TEST->is_eq($module->VERSION, $version, "$module is the same as the distribution version"); } } sub _check_changelog { my $version = shift; if(-e 'Changes') { open(my $fh, '<', 'Changes'); my $version_check = quotemeta($version); my $changelog = join "\n", <$fh>; $TEST->like($changelog, qr{\b$version_check\b}, 'Changelog includes reference to the distribution version: ' . $version); close $fh; } else { $TEST->ok(0, 'Unable to find Changes file'); } } sub _check_readme { my $version = shift; if(-e 'README') { open(my $fh, '<', 'README'); my $version_check = quotemeta($version); my $readme = join "\n", <$fh>; $TEST->like($readme, qr{\b$version_check\b}, 'README file includes reference to the distribution version: ' . $version); close $fh; } else { $TEST->ok(0, 'Unable to find README file'); } } 1; # Magic true value required at end of module __END__ =head1 NAME Test::ConsistentVersion - Ensures a CPAN distribution has consistent versioning. =head1 VERSION This document describes Test::ConsistentVersion version 0.2.3 =head1 SYNOPSIS [In a test file] use Test::More; if ( not $ENV{TEST_AUTHOR} ) { my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; plan( skip_all => $msg ); } eval "use Test::ConsistentVersion"; plan skip_all => "Test::ConsistentVersion required for checking versions" if $@; Test::ConsistentVersion::check_consistent_versions(); =head1 DESCRIPTION The purpose of this module is to make it easy for other distribution authors to have consistent version numbers within the modules (as well as readme file and changelog) of the distribution. =head1 INTERFACE =over =item check_consistent_versions check_consistent_versions() Checks the various versions throughout the distribution to ensure they are all consistent. =back =head1 DIAGNOSTICS Nothing so far. =head1 CONFIGURATION AND ENVIRONMENT Test::ConsistentVersion requires no configuration files or environment variables. =head1 DEPENDENCIES =over =item L =item L =back B =over =item L For ensuring the module version matches that referenced in the POD. =back =head1 INCOMPATIBILITIES None reported. =head1 BUGS AND LIMITATIONS No bugs have been reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR Glenn Fowler C<< >> Thanks to L. =head1 LICENCE AND COPYRIGHT Copyright (c) 2009, Glenn Fowler C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Test-ConsistentVersion-v0.2.3/t000755000765000024 011457266335 16124 5ustar00Glennstaff000000000000Test-ConsistentVersion-v0.2.3/t/00.load.t000444000765000024 23111457266335 17557 0ustar00Glennstaff000000000000use Test::More tests => 1; BEGIN { use_ok( 'Test::ConsistentVersion' ); } diag( "Testing Test::ConsistentVersion $Test::ConsistentVersion::VERSION" ); Test-ConsistentVersion-v0.2.3/t/01.good.t000444000765000024 271711457266335 17624 0ustar00Glennstaff000000000000chdir 't/Sample-Good'; use lib 'lib'; use Test::Builder::Tester tests => 2; use Test::More; my $expected_tests = 2; #number of modules to check my $testing_pod = eval {require Test::Pod::Content}; $expected_tests *= 2 if $testing_pod; #double it if we are checking for pod versions $expected_tests+=2; #plus one each for the Changelog and README file my $test_count = 1; test_out(sprintf 'ok %d - Sample::Good is the same as the distribution version', $test_count++); test_out(sprintf 'ok %d - Sample::StillGood is the same as the distribution version', $test_count++); test_out(sprintf 'ok %d - Sample::Good POD version is the same as module version', $test_count++) if $testing_pod; test_out(sprintf 'ok %d - Sample::StillGood POD version is the same as module version', $test_count++) if $testing_pod; test_out(sprintf 'ok %d - Changelog includes reference to the distribution version: 1.2.31', $test_count++); test_out(sprintf 'ok %d - README file includes reference to the distribution version: 1.2.31', $test_count++); test_diag('Test::Pod::Content required to test POD version consistency') unless $testing_pod; test_diag(q{Distribution version: 1.2.31}); use Test::ConsistentVersion; my $T = Test::Builder->new; Test::ConsistentVersion::check_consistent_versions(); my $tests_run = $T->current_test; test_test('Failing version check'); is($tests_run, $expected_tests, "Expected number of tests ($expected_tests) were performed"); Test-ConsistentVersion-v0.2.3/t/02.bad.t000444000765000024 525211457266335 17420 0ustar00Glennstaff000000000000chdir 't/Sample-Bad'; use lib 'lib'; use Test::Builder::Tester tests => 2; use Test::More; my $expected_tests = 2; #number of modules to check my $testing_pod = eval {require Test::Pod::Content}; $expected_tests *= 2 if $testing_pod; #double it if we are checking for pod versions $expected_tests += 2; #changelog and readme use Test::ConsistentVersion; my $RE_DEFAULT_FLAGS = qr// eq '(?-xism:)' ? '-xism' : '^'; my $test_count = 1; test_out(sprintf 'ok %d - Sample::Bad is the same as the distribution version', $test_count++); test_out(sprintf 'not ok %d - Sample::StillBad is the same as the distribution version', $test_count++); test_out(sprintf 'not ok %d - Sample::Bad POD version is the same as module version', $test_count++) if $testing_pod; test_out(sprintf 'ok %d - Sample::StillBad POD version is the same as module version', $test_count++) if $testing_pod; test_out(sprintf 'not ok %d - Changelog includes reference to the distribution version: 1.2.31', $test_count++); test_out(sprintf 'not ok %d - Unable to find README file', $test_count++); test_diag('Test::Pod::Content required to test POD version consistency') unless $testing_pod; test_diag(q{Distribution version: 1.2.31}); # Sample::StillBad has a different version number test_err(q{# Failed test 'Sample::StillBad is the same as the distribution version'}); test_err(q{# at lib/Test/ConsistentVersion.pm line 45.}); test_err(q{# got: '1.2.30'}); test_err(q{# expected: '1.2.31'}); # Sample::Bad has different POD to the module version if($testing_pod) { test_err(q{# Failed test 'Sample::Bad POD version is the same as module version'}); test_err(sprintf '/#\s+ at .+%s .+/', quotemeta 'Test/Pod/Content.pm'); test_err(q{# '1.2.30'}); test_err(sprintf q{# doesn't match '(?%s:(^|\s)1\.2\.31(\s|$))'}, $RE_DEFAULT_FLAGS); } # Changelog doesn't have the current version test_err(q{# Failed test 'Changelog includes reference to the distribution version: 1.2.31'}); test_err(q{# at lib/Test/ConsistentVersion.pm line 47.}); test_err(q{# 'Changelog}); test_err(q{# }); test_err(q{# }); test_err(q{# }); test_err(q{# 1.2.30}); test_err(q{# }); test_err(q{# First version.}); test_err(q{# '}); test_err(sprintf q{# doesn't match '(?%s:\b1\.2\.31\b)'}, $RE_DEFAULT_FLAGS); # No readme file: test_err(q{# Failed test 'Unable to find README file'}); test_err(q{# at lib/Test/ConsistentVersion.pm line 48.}); Test::ConsistentVersion::check_consistent_versions(); my $T = Test::Builder->new; my $tests_run = $T->current_test; test_test('Failing version check'); is($tests_run, $expected_tests, 'Expected number of tests were run') Test-ConsistentVersion-v0.2.3/t/perlcritic.t000444000765000024 66011457266335 20570 0ustar00Glennstaff000000000000#!perl use strict; use warnings; use File::Spec; use Test::More; use English qw(-no_match_vars); if ( not $ENV{TEST_AUTHOR} ) { my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; plan( skip_all => $msg ); } eval { require Test::Perl::Critic; }; if ( $EVAL_ERROR ) { my $msg = 'Test::Perl::Critic required to criticise code'; plan( skip_all => $msg ); } Test::Perl::Critic::all_critic_ok(); Test-ConsistentVersion-v0.2.3/t/pod-coverage.t000444000765000024 47111457266335 21003 0ustar00Glennstaff000000000000#!perl -T use Test::More; if ( not $ENV{TEST_AUTHOR} ) { my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; plan( skip_all => $msg ); } eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); Test-ConsistentVersion-v0.2.3/t/pod.t000444000765000024 43111457266335 17206 0ustar00Glennstaff000000000000#!perl -T use Test::More; if ( not $ENV{TEST_AUTHOR} ) { my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; plan( skip_all => $msg ); } eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); Test-ConsistentVersion-v0.2.3/t/version.t000444000765000024 51011457266335 20107 0ustar00Glennstaff000000000000use Test::More; if ( not $ENV{TEST_AUTHOR} ) { my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; plan( skip_all => $msg ); } eval "use Test::ConsistentVersion"; plan skip_all => "Test::ConsistentVersion required for checking versions" if $@; Test::ConsistentVersion::check_consistent_versions(); Test-ConsistentVersion-v0.2.3/t/Sample-Bad000755000765000024 011457266335 20031 5ustar00Glennstaff000000000000Test-ConsistentVersion-v0.2.3/t/Sample-Bad/Changes000444000765000024 4511457266335 21420 0ustar00Glennstaff000000000000Changelog 1.2.30 First version. Test-ConsistentVersion-v0.2.3/t/Sample-Bad/MANIFEST000444000765000024 7211457266335 21256 0ustar00Glennstaff000000000000lib/Sample/Bad.pm lib/Sample/StillBad.pm Changes MANIFEST Test-ConsistentVersion-v0.2.3/t/Sample-Bad/lib000755000765000024 011457266335 20577 5ustar00Glennstaff000000000000Test-ConsistentVersion-v0.2.3/t/Sample-Bad/lib/Sample000755000765000024 011457266335 22020 5ustar00Glennstaff000000000000Test-ConsistentVersion-v0.2.3/t/Sample-Bad/lib/Sample/Bad.pm000444000765000024 32711457266335 23163 0ustar00Glennstaff000000000000package Sample::Bad; use warnings; use strict; use version; our $VERSION = qv('1.2.31'); 1; __END__ =head1 NAME Sample::Bad - Sample module for testing Test::ConsistentVersion. =head1 VERSION 1.2.30 =cut Test-ConsistentVersion-v0.2.3/t/Sample-Bad/lib/Sample/StillBad.pm000444000765000024 34111457266335 24167 0ustar00Glennstaff000000000000package Sample::StillBad; use warnings; use strict; use version; our $VERSION = qv('1.2.30'); 1; __END__ =head1 NAME Sample::StillBad - Sample module for testing Test::ConsistentVersion. =head1 VERSION 1.2.30 =cut Test-ConsistentVersion-v0.2.3/t/Sample-Good000755000765000024 011457266335 20233 5ustar00Glennstaff000000000000Test-ConsistentVersion-v0.2.3/t/Sample-Good/Changes000444000765000024 10311457266335 21635 0ustar00Glennstaff000000000000Changelog 1.2.31 Added README file 1.2.30 First version. Test-ConsistentVersion-v0.2.3/t/Sample-Good/MANIFEST000444000765000024 7411457266335 21462 0ustar00Glennstaff000000000000lib/Sample/Good.pm lib/Sample/StillGood.pm Changes MANIFEST Test-ConsistentVersion-v0.2.3/t/Sample-Good/README000444000765000024 12711457266335 21230 0ustar00Glennstaff000000000000Sample-Good version 1.2.31 This is just a sample README file for a test distribution. Test-ConsistentVersion-v0.2.3/t/Sample-Good/lib000755000765000024 011457266335 21001 5ustar00Glennstaff000000000000Test-ConsistentVersion-v0.2.3/t/Sample-Good/lib/Sample000755000765000024 011457266335 22222 5ustar00Glennstaff000000000000Test-ConsistentVersion-v0.2.3/t/Sample-Good/lib/Sample/Good.pm000444000765000024 33111457266335 23562 0ustar00Glennstaff000000000000package Sample::Good; use warnings; use strict; use version; our $VERSION = qv('1.2.31'); 1; __END__ =head1 NAME Sample::Good - Sample module for testing Test::ConsistentVersion. =head1 VERSION 1.2.31 =cut Test-ConsistentVersion-v0.2.3/t/Sample-Good/lib/Sample/StillGood.pm000444000765000024 34311457266335 24575 0ustar00Glennstaff000000000000package Sample::StillGood; use warnings; use strict; use version; our $VERSION = qv('1.2.31'); 1; __END__ =head1 NAME Sample::StillGood - Sample module for testing Test::ConsistentVersion. =head1 VERSION 1.2.31 =cut