new Class test wrapper
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::Class::Load qw<xt/lib>;
|
||||
59
xt/21_run.t
Normal file
59
xt/21_run.t
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use lib 'xt/lib';
|
||||
use Module::Find;
|
||||
|
||||
my @BAD_MODULES = qw(
|
||||
Test::SNMP::Info::MAU
|
||||
Test::SNMP::Info::Layer3::C4000
|
||||
);
|
||||
|
||||
my @found = findallmod 'Test::SNMP::Info';
|
||||
unshift @found, 'Test::SNMP::Info';
|
||||
|
||||
# pass a specific module to test,
|
||||
# using e.g. "prove xt/21_run.t :: Test::SNMP::Info::MAU"
|
||||
if (scalar @ARGV) { @found = @ARGV }
|
||||
|
||||
# cannot do this inline with findallmod
|
||||
@found = sort { (scalar split m/::/, $a) <=> (scalar split m/::/, $b)
|
||||
or
|
||||
$a cmp $b } @found;
|
||||
|
||||
my $total = scalar @found - scalar @BAD_MODULES;
|
||||
my $count = 0;
|
||||
|
||||
# fake test plan
|
||||
print "1..$total\n";
|
||||
|
||||
foreach my $module (@found) {
|
||||
if (grep m/^${module}$/, @BAD_MODULES) {
|
||||
# printf STDERR "!!> skipping: %s\n", $module;
|
||||
next;
|
||||
}
|
||||
|
||||
my $preamble = <<'END_CODE_PREAMBLE';
|
||||
# this is to avoid annoying plan warnings with the way subtests are done
|
||||
{
|
||||
use Hook::LexWrap;
|
||||
use Test::Builder;
|
||||
no warnings 'redefine';
|
||||
wrap *Test::Builder::diag, pre => sub {
|
||||
$_[-1] = 1
|
||||
if $_[1] and $_[1] =~ m/Tests were run but no plan was declared/;
|
||||
};
|
||||
}
|
||||
END_CODE_PREAMBLE
|
||||
|
||||
my $code = <<"END_CODE";
|
||||
$module->builder->current_test($count);
|
||||
Test::More::subtest '$module' => sub { $module->runtests() };
|
||||
END_CODE
|
||||
|
||||
# printf STDERR "--> %d: %s\n", ($count + 1), $module;
|
||||
system (qw{perl -Ilib -Ixt/lib}, "-M$module", '-e', $preamble . $code);
|
||||
++$count;
|
||||
}
|
||||
@@ -41,7 +41,8 @@ use base qw<Test::Class Class::Data::Inheritable>;
|
||||
# Don't run the base tests defined in this class, run them in subclasses only
|
||||
My::Test::Class->SKIP_CLASS(1);
|
||||
|
||||
INIT { Test::Class->runtests }
|
||||
# add a test which runs "use Test::Class::Load qw<xt/lib>;" and uncomment:
|
||||
# INIT { Test::Class->runtests }
|
||||
|
||||
my $EMPTY = q{};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user