X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FVPIT%2FTestHelpers.pm;h=8e056293f5ab422177c0b0fe65a4a4c9bf423a44;hb=ad3fa9ca5eefe61d54be06d88b6f8281779f88ac;hp=591adf2182fd90d3f57feb9c56e857e080fe65f3;hpb=94d725fac2ac4e3361763cac7c338f228c136205;p=perl%2Fmodules%2FVPIT-TestHelpers.git diff --git a/lib/VPIT/TestHelpers.pm b/lib/VPIT/TestHelpers.pm index 591adf2..8e05629 100644 --- a/lib/VPIT/TestHelpers.pm +++ b/lib/VPIT/TestHelpers.pm @@ -10,21 +10,33 @@ my %exports = ( 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); -} +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 { - require Test::More; - Test::More::diag($_) for @_; + my $diag = $test_sub->('diag'); + $diag->($_) for @_; } our $TODO; @@ -37,6 +49,7 @@ sub load_or_skip { 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];