Test-HasVersion-0.012/0000755000175200010010000000000010512507750013723 5ustar FerreiraNoneTest-HasVersion-0.012/t/0000755000175200010010000000000010512507750014166 5ustar FerreiraNoneTest-HasVersion-0.012/t/04_all.ok.t0000755000175200010010000000107310507204236016037 0ustar FerreiraNone#!/usr/bin/perl use Test::More tests => 4 + 3; use File::Spec; my $null = File::Spec->devnull; ok(chdir "t/eg/", "cd t/eg"); my @tap = `$^X -Mblib ../../t/97_has_version.t 2>$null`; ok(scalar @tap, 't/97_has_version.t run ok'); ok(chdir "../..", "cd ../.."); my @expected = ( 'A.pm' => 'ok', 'lib/B.pm' => 'ok', 'lib/B/C.pm' => 'not ok', ); like(shift @tap, qr/^1\.\.3/, 'good plan'); for (@tap) { next if /^#/; my $f = shift @expected; my $ans = shift @expected; like($_, qr/^$ans \d+ - $f/, $ans eq 'ok' ? "$f has version" : "$f has no version"); }Test-HasVersion-0.012/t/eg/0000755000175200010010000000000010512507750014561 5ustar FerreiraNoneTest-HasVersion-0.012/t/eg/MANIFEST0000644000175200010010000000015010507204236015703 0ustar FerreiraNone A.pm MANIFEST This list of files (for t/eg/) lib/B.pm lib/B/C.pm inc/Foo.pm Test-HasVersion-0.012/t/eg/lib/0000755000175200010010000000000010512507750015327 5ustar FerreiraNoneTest-HasVersion-0.012/t/eg/lib/B/0000755000175200010010000000000010512507750015510 5ustar FerreiraNoneTest-HasVersion-0.012/t/eg/lib/B/C.pm0000644000175200010010000000000010507204234016211 0ustar FerreiraNoneTest-HasVersion-0.012/t/eg/lib/B.pm0000644000175200010010000000002710507204234016040 0ustar FerreiraNone our $VERSION = '0.1'; Test-HasVersion-0.012/t/eg/A.pm0000644000175200010010000000002110507204236015265 0ustar FerreiraNone $VERSION = 0.1; Test-HasVersion-0.012/t/eg/inc/0000755000175200010010000000000010512507750015332 5ustar FerreiraNoneTest-HasVersion-0.012/t/eg/inc/Foo.pm0000644000175200010010000000000010507204236016376 0ustar FerreiraNoneTest-HasVersion-0.012/t/98_pod-coverage.t0000644000175200010010000000024310507204236017242 0ustar FerreiraNone use Test::More; 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-HasVersion-0.012/t/01_use.t0000644000175200010010000000022110507204236015437 0ustar FerreiraNone use Test::More tests => 1; BEGIN { use_ok('Test::HasVersion'); } diag( "Testing Test::HasVersion $Test::HasVersion::VERSION, Perl $], $^X" ); Test-HasVersion-0.012/t/97_has_version.t0000644000175200010010000000022710507204236017210 0ustar FerreiraNone use Test::More; eval "use Test::HasVersion"; plan skip_all => 'Test::HasVersion required for testing for version numbers' if $@; all_pm_version_ok(); Test-HasVersion-0.012/t/99_pod.t0000644000175200010010000000025210507204236015452 0ustar FerreiraNone use Test::More; eval "use Test::Pod 1.18"; plan skip_all => "Test::Pod 1.18 required for testing POD" if $@; #all_pod_files_ok(all_pod_files(".")); all_pod_files_ok(); Test-HasVersion-0.012/t/09_self_test.t0000644000175200010010000000023710507204236016652 0ustar FerreiraNone use Test::More tests => 2; BEGIN { use_ok( "Test::HasVersion" ); } my $self = $INC{'Test/HasVersion.pm'}; pm_version_ok($self, "My own version is ok"); Test-HasVersion-0.012/t/03_all_pm_files.t0000755000175200010010000000140310507204236017301 0ustar FerreiraNone#!/usr/bin/perl use Test::More tests => 7; require_ok('Test::HasVersion'); # alias to have a short name *all_pm_files = \&Test::HasVersion::all_pm_files; # and here we test &all_pm_files { my @pm_files = all_pm_files(); is_deeply(\@pm_files, [ qw(HasVersion.pm) ]); } { ok(chdir "t/eg", "cd t/eg"); my @pm_files = all_pm_files(); is_deeply(\@pm_files, [ qw(A.pm lib/B.pm lib/B/C.pm) ] ); # *.pm lib/**/*.pm ok(chdir "../..", "cd ../.."); } { my @pm_files = all_pm_files("t/eg"); is_deeply(\@pm_files, [ qw(t/eg/A.pm t/eg/inc/Foo.pm t/eg/lib/B.pm t/eg/lib/B/C.pm ) ] ); # every .pm under t/eg } { my @pm_files = all_pm_files("t/eg/A.pm", "t/eg/MANIFEST"); is_deeply(\@pm_files, [ qw(t/eg/A.pm t/eg/MANIFEST) ]); } Test-HasVersion-0.012/t/02_basic.t0000755000175200010010000000107410507204236015737 0ustar FerreiraNone#!/usr/bin/perl use strict; use Test::Builder::Tester 1.04 tests => 6; use Test::More; # tests pm_version_ok BEGIN { use_ok('Test::HasVersion'); } ok(chdir "t/eg", "cd t/eg"); test_out("ok 1 - A.pm has version"); pm_version_ok("A.pm"); test_test(); test_out("not ok 1 - X.pm has version"); test_fail(+1); pm_version_ok("X.pm"); test_diag("X.pm does not exist"); test_test(); test_out("ok 1 - lib/B.pm has version"); pm_version_ok("lib/B.pm"); test_test(); test_out("not ok 1 - lib/B/C.pm has version"); test_fail(+1); pm_version_ok("lib/B/C.pm"); test_test(); Test-HasVersion-0.012/Changes0000644000175200010010000000135410512505700015212 0ustar FerreiraNoneRevision history for Perl extension Test-HasVersion. 0.012 Sat Sep 7 2006 - Test::Builder is a prereq - test_version has version (same as HasVersion.pm) 0.011 Mon Jul 17 2006 - Test::Builder::Tester 1.04 restored compabibility and demanded changes to t/02_basic.t - minor tweaks in Makefile.PL (we a have a license there now) 0.01 Sat Jul 15 2006 - first release to CPAN undef Wed Jul 12 2006 - Gabor Szabo posts a message to perl-qa@perl.org wondering about a Test module to check modules in a distro provide correct version information. http://www.nntp.perl.org/group/perl.qa/6384 Test-HasVersion-0.012/HasVersion.pm0000644000175200010010000001360610511766400016346 0ustar FerreiraNone package Test::HasVersion; use strict; use warnings; our $VERSION = '0.012'; =head1 NAME Test::HasVersion - Check Perl modules have version numbers =head1 SYNOPSIS C lets you check a Perl module has a version number in a C fashion. use Test::HasVersion tests => 1; pm_version_ok("M.pm", "Valid version"); Module authors can include the following in a F file and let C find and check all installable PM files in a distribution. use Test::More; eval "use Test::HasVersion"; plan skip_all => 'Test::HasVersion required for testing for version numbers' if $@; all_pm_version_ok(); =head1 DESCRIPTION Do you wanna check that every one of your Perl modules in a distribution has a version number? You wanna make sure you don't forget the brand new modules you just added? Well, that's the module you have been looking for. Use it! Do you wanna check someone else's distribution to make sure the author have not commited the sin of leaving Perl modules without a version that can be used to tell if you have this or that feature? C is also for you, nasty little fellow. There's a script F which is installed with this distribution. You may invoke it from within the root directory of a distribution you just unpacked, and it will check every F<.pm> file in the directory and under F (if any). $ test_version You may also provide directories and files as arguments. $ test_version *.pm lib/ inc/ $ test_version . (Be warned that many Perl modules in a F directory do not receive versions because they are not used outside the distribution.) Ok. That's not a very useful module by now. But it will be. Wait for the upcoming releases. =head2 FUNCTIONS =over 4 =cut # most of the following code was borrowed from Test::Pod use Test::Builder; use ExtUtils::MakeMaker; # to lay down my hands on MM->parse_version my $Test = Test::Builder->new; our @EXPORTS = qw( pm_version_ok all_pm_version_ok all_pm_files ); sub import { my $self = shift; my $caller = caller; for my $func ( @EXPORTS ) { no strict 'refs'; *{$caller."::".$func} = \&$func; } $Test->exported_to($caller); $Test->plan(@_); } # from Module::Which #=begin private =item PRIVATE B<_pm_version> $v = _pm_version($pm); Parses a PM file and return what it thinks is $VERSION in this file. (Actually implemented with C<< use ExtUtils::MakeMaker; MM->parse_version($file) >>.) C<$pm> is the filename (eg., F). =cut #=end private sub _pm_version { my $pm = shift; my $v; eval { $v = MM->parse_version($pm); }; return $@ ? undef : $v; } =item B pm_version_ok('Module.pm'); pm_version_ok('M.pm', 'Has valid version'); Checks to see if the given file has a valid version. Actually a valid version number is defined and not equal to C<'undef'> (the string) which is return by C<_pm_version> if a version cannot be determined. =cut sub pm_version_ok { my $file = shift; my $name = @_ ? shift : "$file has version"; if (!-f $file) { $Test->ok(0, $name); $Test->diag("$file does not exist"); return; } my $v = _pm_version($file); my $ok = _is_valid_version($v); $Test->ok($ok, $name); #$Test->diag("$file $v ") if $ok && $noisy; } sub _is_valid_version { defined $_[0] && $_[0] ne 'undef'; } =item B all_pm_version_ok(); all_pm_version_ok(@PM_FILES); Checks every given file and F<.pm> files found under given directories to see if they provide valid version numbers. If no argument is given, it defaults to check every file F<*.pm> in the current directory and recurses under the F directory (if it exists). If no test plan was setted, C will set one after computing the number of files to be tested. Otherwise, the plan is left untouched. =cut sub all_pm_version_ok { my @pm_files = all_pm_files(@_); $Test->plan(tests => scalar @pm_files) unless $Test->has_plan; for (@pm_files) { pm_version_ok($_); } } #=begin private =item PRIVATE B<_list_pm_files> @pm_files = _list_pm_files(@dirs); Returns all PM files under the given directories. =cut #=end private # from Module::Which::List - eglob("**/*.pm") use File::Find qw(find); sub _list_pm_files { my @INC = @_; my @files; my $wanted = sub { push @files, $_ if /\.pm$/; }; for (@INC) { my $base = $_; if (-d $base) { find({ wanted => $wanted, no_chdir => 1 }, $base); } } return sort @files; } =item B @files = all_pm_files() @files = all_pm_files(@files_and_dirs); Implements finding the Perl modules according to the semantics of the previous function C. =cut sub all_pm_files { my @args; if (@_) { @args = @_; } else { @args = ( grep(-f, glob("*.pm")), "lib/" ); } my @pm_files; for (@args) { if (-f) { push @pm_files, $_; } elsif (-d) { push @pm_files, _list_pm_files($_); } else { # not a file or directory: ignore silently } } return @pm_files; } =back =head1 USAGE Other usage patterns besides the ones given in the synopsis. use Test::More tests => $num_tests; use Test::HasVersion; pm_version_ok($file1); pm_version_ok($file2); Obviously, you can't plan twice. use Test::More; use Test::HasVersion; plan tests => $num_tests; pm_version_ok($file); C comes from C. use Test::More; use Test::HasVersion; plan 'no_plan'; pm_version_ok($file); C is ok either. =head1 SEE ALSO Test::Version Please reports bugs via CPAN RT, http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-HasVersion =head1 AUTHOR A. R. Ferreira, Eferreira@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2006 by A. R. Ferreira This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; Test-HasVersion-0.012/MANIFEST0000644000175200010010000000055710512507754015067 0ustar FerreiraNone Makefile.PL MANIFEST This list of files Changes README HasVersion.pm bin/test_version t/01_use.t t/02_basic.t t/03_all_pm_files.t t/04_all.ok.t t/09_self_test.t t/97_has_version.t t/98_pod-coverage.t t/99_pod.t t/eg/A.pm t/eg/inc/Foo.pm t/eg/lib/B.pm t/eg/lib/B/C.pm t/eg/MANIFEST META.yml Module meta-data (added by MakeMaker) Test-HasVersion-0.012/bin/0000755000175200010010000000000010512507750014473 5ustar FerreiraNoneTest-HasVersion-0.012/bin/test_version0000755000175200010010000000017610512505646017153 0ustar FerreiraNone#!perl use strict; use warnings; use Test::HasVersion; our $VERSION = $Test::HasVersion::VERSION; all_pm_version_ok(@ARGV);Test-HasVersion-0.012/README0000644000175200010010000000032110511766636014610 0ustar FerreiraNoneThis is alpha release 0.012 of Test::HasVersion. Test::HasVersion is a test module intented to check all Perl modules in a distribution have version numbers. Adriano Ferreira Jul 14 2006 Test-HasVersion-0.012/Makefile.PL0000644000175200010010000000126610511766436015711 0ustar FerreiraNone use ExtUtils::MakeMaker; my $EUMM_VERSION = eval $ExtUtils::MakeMaker::VERSION; WriteMakefile( NAME => 'Test::HasVersion', VERSION_FROM => 'HasVersion.pm', PREREQ_PM => { 'Test::Builder' => 0, 'ExtUtils::MakeMaker' => 0, 'File::Find' => 0, # required for testing 'Test::More' => 0, 'Test::Builder::Tester' => 1.04, 'File::Spec' => 0, }, EXE_FILES => [ 'bin/test_version' ], ($] >= 5.005 ? ( ABSTRACT_FROM => 'HasVersion.pm', AUTHOR => 'Adriano R. Ferreira ' ) : ()), ($EUMM_VERSION >= 6.30_01 ? ( LICENSE => 'perl', ) : ()), ); Test-HasVersion-0.012/META.yml0000644000175200010010000000120610512507754015177 0ustar FerreiraNone--- #YAML:1.0 name: Test-HasVersion version: 0.012 abstract: Check Perl modules have version numbers license: perl generated_by: ExtUtils::MakeMaker version 6.30_01 author: Adriano R. Ferreira distribution_type: module requires: ExtUtils::MakeMaker: 0 File::Find: 0 File::Spec: 0 Test::Builder: 0 Test::Builder::Tester: 1.04 Test::More: 0 meta-spec: url: ; version: 1.1