Also make sure that the kwalitee test unlinks its byproducts.
t/51-threads-teardown.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/Test/Leaner.pm
+t/lib/VPIT/TestHelpers.pm
t/lib/autovivification/TestCases.pm
t/lib/autovivification/TestRequired1.pm
t/lib/autovivification/TestRequired2.pm
use strict;
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();
use strict;
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;
+
+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);
-# 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 $@;
+eval 'use Test::Pod::Coverage'; # Make Kwalitee test happy
all_pod_coverage_ok({ also_private => [ qr/^A_HINT_/ ] });
--- /dev/null
+#!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();
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();
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(); };
--- /dev/null
+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;
+ }
+}
+
+my $test_sub = sub {
+ my $sub = shift;
+ my $stash;
+ if ($INC{'Test/Leaner.pm'}) {
+ $stash = \%Test::Leaner::;
+ } else {
+ require Test::More;
+ $stash = \%Test::More::;
+ }
+ my $glob = $stash->{$sub};
+ return $glob ? *$glob{CODE} : undef;
+};
+
+sub skip_all { $test_sub->('plan')->(skip_all => $_[0]) }
+
+sub diag {
+ my $diag = $test_sub->('diag');
+ $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 {
+ (my $file = "$pkg.pm") =~ s{::}{/}g;
+ delete $INC{$file};
+ skip_all "$spec $desc";
+ }
+}
+
+package VPIT::TestHelpers::Guard;
+
+sub new {
+ my ($class, $code) = @_;
+
+ bless { code => $code }, $class;
+}
+
+sub DESTROY { $_[0]->{code}->() }
+
+1;