]> git.vpit.fr Git - perl/modules/Scope-Upper.git/commitdiff
Update author tests, and add a POD spelling test
authorVincent Pit <vince@profvince.com>
Wed, 22 Aug 2012 09:34:25 +0000 (11:34 +0200)
committerVincent Pit <vince@profvince.com>
Wed, 22 Aug 2012 09:34:25 +0000 (11:34 +0200)
Also make sure that the kwalitee test unlinks its byproducts.

MANIFEST
t/91-pod.t
t/92-pod-coverage.t
t/93-pod-spelling.t [new file with mode: 0644]
t/95-portability-files.t
t/99-kwalitee.t
t/lib/VPIT/TestHelpers.pm [new file with mode: 0644]

index e3088a64d08cf73e7cf25c94c83dcf50f0e30453..b44fb3369a723dbd1fb406de70430a5da10bdec7 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -57,8 +57,10 @@ t/86-stress-uplevel.t
 t/87-stress-uid.t
 t/91-pod.t
 t/92-pod-coverage.t
+t/93-pod-spelling.t
 t/95-portability-files.t
 t/99-kwalitee.t
 t/lib/Scope/Upper/TestGenerator.pm
 t/lib/Scope/Upper/TestThreads.pm
 t/lib/Test/Leaner.pm
+t/lib/VPIT/TestHelpers.pm
index 62d2d7f7f907dc1922c07098415a89d239685f84..c2d16afc5e5e128da1975b349103c540ce71dd4b 100644 (file)
@@ -5,9 +5,12 @@ use warnings;
 
 use Test::More;
 
-# Ensure a recent version of Test::Pod
-my $min_tp = 1.22;
-eval "use Test::Pod $min_tp";
-plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
+use lib 't/lib';
+use VPIT::TestHelpers;
+
+load_or_skip('Test::Pod', '1.22', [ ],
+             'required for testing POD syntax');
+
+eval 'use Test::Pod'; # Make Kwalitee test happy
 
 all_pod_files_ok();
index f994974f248f3003a6f2d84ea48713300522e7c0..6399021751882f13c74fed4faf95e1070acfd53c 100644 (file)
@@ -5,15 +5,14 @@ use warnings;
 
 use Test::More;
 
-# Ensure a recent version of Test::Pod::Coverage
-my $min_tpc = 1.08;
-eval "use Test::Pod::Coverage $min_tpc";
-plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@;
+use lib 't/lib';
+use VPIT::TestHelpers;
 
-# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
-# but older versions don't recognize some common documentation styles
-my $min_pc = 0.18;
-eval "use Pod::Coverage $min_pc";
-plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@;
+my $desc = 'required for testing POD coverage';
+
+load_or_skip('Test::Pod::Coverage', '1.08', [ ],   $desc);
+load_or_skip('Pod::Coverage',       '0.18', undef, $desc);
+
+eval 'use Test::Pod::Coverage'; # Make Kwalitee test happy
 
 all_pod_coverage_ok( { also_private => [ qr/^_/, qr/^CLONE(_SKIP)?$/ ] } );
diff --git a/t/93-pod-spelling.t b/t/93-pod-spelling.t
new file mode 100644 (file)
index 0000000..acb2587
--- /dev/null
@@ -0,0 +1,14 @@
+#!perl -T
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use lib 't/lib';
+use VPIT::TestHelpers;
+
+load_or_skip('Test::Pod::Spelling::CommonMistakes', '1.0', [ ],
+             'required for testing POD spelling');
+
+all_pod_files_ok();
index ab541f3035c5a7691de45403760618ab068e83a5..55a900519fec914952ad4fbb9a6ed6fee0944f68 100644 (file)
@@ -5,6 +5,10 @@ use warnings;
 
 use Test::More;
 
-eval "use Test::Portability::Files";
-plan skip_all => "Test::Portability::Files required for testing filenames portability" if $@;
+use lib 't/lib';
+use VPIT::TestHelpers;
+
+load_or_skip('Test::Portability::Files', undef, [ ],
+             'required for testing filenames portability');
+
 run_tests();
index 4a664573fa9b2090bad47cd5c9343c7b509121ff..796fe6102f5a4e93c85e9476106898cf8fc8b407 100644 (file)
@@ -5,14 +5,18 @@ use warnings;
 
 use Test::More;
 
-eval { require Parse::RecDescent; 'Parse::RecDescent'->VERSION('1.967006') }
-  or plan skip_all => 'Parse::RecDescent version 1.967006 or greater required';
+use lib 't/lib';
+use VPIT::TestHelpers;
 
-eval { require Module::ExtractUse; 'Module::ExtractUse'->VERSION('0.24') }
-  or plan skip_all => 'Module::ExtractUse version 0.24 or greater required';
+my $guard = VPIT::TestHelpers::Guard->new(
+ sub { unlink for glob 'Debian_CPANTS.txt*' }
+);
 
-eval { require Test::Kwalitee; 1 }
-  or plan skip_all => 'Test::Kwalitee required';
+my $desc = 'required to test kwalitee';
+
+load_or_skip('Parse::RecDescent',  '1.967006', undef, $desc);
+load_or_skip('Module::ExtractUse', '0.24',     undef, $desc);
+load_or_skip('Test::Kwalitee',     '1.01',     undef, $desc);
 
 SKIP: {
  eval { Test::Kwalitee->import(); };
diff --git a/t/lib/VPIT/TestHelpers.pm b/t/lib/VPIT/TestHelpers.pm
new file mode 100644 (file)
index 0000000..18f2b17
--- /dev/null
@@ -0,0 +1,68 @@
+package VPIT::TestHelpers;
+
+use strict;
+use warnings;
+
+my %exports = (
+ load_or_skip => \&load_or_skip,
+ skip_all     => \&skip_all,
+);
+
+sub import {
+ my $pkg = caller;
+ while (my ($name, $code) = each %exports) {
+  no strict 'refs';
+  *{$pkg.'::'.$name} = $code;
+ }
+}
+
+sub skip_all {
+ my ($msg) = @_;
+ require Test::More;
+ Test::More::plan(skip_all => $msg);
+}
+
+sub diag {
+ require Test::More;
+ Test::More::diag($_) for @_;
+}
+
+our $TODO;
+local $TODO;
+
+sub load_or_skip {
+ my ($pkg, $ver, $imports, $desc) = @_;
+ my $spec = $ver && $ver !~ /^[0._]*$/ ? "$pkg $ver" : $pkg;
+ local $@;
+ if (eval "use $spec (); 1") {
+  $ver = do { no strict 'refs'; ${"${pkg}::VERSION"} };
+  $ver = 'undef' unless defined $ver;
+  if ($imports) {
+   my @imports = @$imports;
+   my $caller  = (caller 0)[0];
+   local $@;
+   my $res = eval <<"IMPORTER";
+package
+        $caller;
+BEGIN { \$pkg->import(\@imports) }
+1;
+IMPORTER
+   skip_all "Could not import '@imports' from $pkg $ver: $@" unless $res;
+  }
+  diag "Using $pkg $ver";
+ } else {
+  skip_all "$spec $desc";
+ }
+}
+
+package VPIT::TestHelpers::Guard;
+
+sub new {
+ my ($class, $code) = @_;
+
+ bless { code => $code }, $class;
+}
+
+sub DESTROY { $_[0]->{code}->() }
+
+1;