Also make sure that the kwalitee test unlinks its byproducts.
t/80-leaks.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/VPIT/TestHelpers.pm
t/lib/Variable/Magic/TestDestroyRequired.pm
t/lib/Variable/Magic/TestGlobalDestruction.pm
t/lib/Variable/Magic/TestScopeEnd.pm
use Variable::Magic qw<wizard cast dispell VMG_UVAR>;
-if (!VMG_UVAR) {
- plan skip_all => 'No nice uvar magic for this perl';
-}
-
-{
- local $@;
- if (eval { require Hash::Util::FieldHash; 1 }) {
- plan tests => 2 * 5 + 7 + 1;
- defined and diag "Using Hash::Util::FieldHash $_"
- for $Hash::Util::FieldHash::VERSION;
- } else {
- plan skip_all => 'Hash::Util::FieldHash required for testing uvar interaction'
- }
+use lib 't/lib';
+use VPIT::TestHelpers;
+
+if (VMG_UVAR) {
+ load_or_skip('Hash::Util::FieldHash', undef, [ ],
+ 'required for testing uvar interaction');
+ plan tests => 2 * 5 + 7 + 1;
+} else {
+ skip_all 'No nice uvar magic for this perl';
}
-use lib 't/lib';
use Variable::Magic::TestWatcher;
my $wiz = init_watcher [ qw<fetch store> ], 'huf';
use Test::More;
+use lib 't/lib';
+use VPIT::TestHelpers;
+
BEGIN {
- local $@;
- if (eval "use Symbol qw<gensym>; 1") {
- plan tests => 2 * 17 + 1;
- defined and diag "Using Symbol $_" for $Symbol::VERSION;
- } else {
- plan skip_all => "Symbol::gensym required for testing magic for globs";
- }
+ load_or_skip('Symbol', undef, [ 'gensym' ],
+ 'required for testing magic for globs');
+
+ plan tests => 2 * 17 + 1;
}
use Variable::Magic qw<cast dispell VMG_COMPAT_GLOB_GET>;
use Test::More;
-eval "use Test::Pod 1.14";
-plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+use lib 't/lib';
+use VPIT::TestHelpers;
+
+load_or_skip('Test::Pod', '1.14', [ ],
+ 'required for testing POD syntax');
+
+eval 'use Test::Pod'; # Make Kwalitee test happy
+
all_pod_files_ok();
use Test::More;
-eval "use Test::Pod::Coverage 1.04";
-plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+use lib 't/lib';
+use VPIT::TestHelpers;
+
+load_or_skip('Test::Pod::Coverage', '1.04', [ ],
+ 'required for testing POD coverage');
+
+eval 'use Test::Pod::Coverage'; # Make Kwalitee test happy
+
all_pod_coverage_ok( { also_private => [ qr/^_/, qr/^CLONE(_SKIP)?$/ ] } );
--- /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', undef, 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;
+ }
+}
+
+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;
use Variable::Magic qw<VMG_THREADSAFE>;
-sub skipall {
- my ($msg) = @_;
- require Test::More;
- Test::More::plan(skip_all => $msg);
-}
+use VPIT::TestHelpers;
sub diag {
require Test::More;
sub import {
shift;
- skipall 'This Variable::Magic isn\'t thread safe' unless VMG_THREADSAFE;
+ skip_all 'This Variable::Magic isn\'t thread safe' unless VMG_THREADSAFE;
my $force = $ENV{PERL_VARIABLE_MAGIC_TEST_THREADS} ? 1 : !1;
- skipall 'This perl wasn\'t built to support threads'
+ skip_all 'This perl wasn\'t built to support threads'
unless $Config{useithreads};
- skipall 'perl 5.13.4 required to test thread safety'
+ skip_all 'perl 5.13.4 required to test thread safety'
unless $force or "$]" >= 5.013_004;
- my $t_v = $force ? '0' : '1.67';
- my $has_threads = do {
- local $@;
- eval "use threads $t_v; 1";
- };
- skipall "threads $t_v required to test thread safety" unless $has_threads;
-
- my $ts_v = $force ? '0' : '1.14';
- my $has_threads_shared = do {
- local $@;
- eval "use threads::shared $ts_v; 1";
- };
- skipall "threads::shared $ts_v required to test thread safety"
- unless $has_threads_shared;
-
- defined and diag "Using threads $_" for $threads::VERSION;
- defined and diag "Using threads::shared $_" for $threads::shared::VERSION;
+ my $desc = 'required to test thread safety';
+ load_or_skip('threads', $force ? '0' : '1.67', [ ], $desc);
+ load_or_skip('threads::shared', $force ? '0' : '1.14', [ ], $desc);
my %exports = (
spawn => \&spawn,