5
package Module::Install::ExtraTests;
6
use Module::Install::Base;
9
our $VERSION = '0.007';
11
our @ISA = qw{Module::Install::Base};
14
our $use_extratests = 0;
19
return unless -d 'xt';
20
return unless my @content = grep { $_ !~ /^[.]/ } <xt/*>;
22
die "unknown files found in ./xt" if grep { !-d } @content;
24
my %known = map {; "xt/$_" => 1 } qw(author smoke release);
25
my @unknown = grep { not $known{$_} } @content;
26
die "unknown directories found in ./xt: @unknown" if @unknown;
35
package # The newline tells PAUSE, "DO NOT INDEXING!"
37
sub test_via_harness {
40
return $self->SUPER::test_via_harness(@_)
41
unless $use_extratests;
43
my ($perl, $tests) = @_;
44
my $a_str = -d 'xt/author' ? 'xt/author' : '';
45
my $r_str = -d 'xt/release' ? 'xt/release' : '';
46
my $s_str = -d 'xt/smoke' ? 'xt/smoke' : '';
47
my $is_author = $Module::Install::AUTHOR ? 1 : 0;
49
return qq{\t$perl "-Iinc" "-MModule::Install::ExtraTests" }
50
. qq{"-e" "Module::Install::ExtraTests::__harness('Test::Harness', $is_author, '$a_str', '$r_str', '$s_str', \$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
54
my ($self, @args) = @_;
56
return $self->SUPER::dist_test(@args)
57
unless $use_extratests;
59
my $text = $self->SUPER::dist_test(@args);
60
my @lines = split /\n/, $text;
61
$_ =~ s/ (\S*MAKE\S* test )/ RELEASE_TESTING=1 $1 / for grep { m/ test / } @lines;
62
return join "\n", @lines;
67
my $harness_class = shift;
68
my $is_author = shift;
69
my $author_tests = shift;
70
my $release_tests = shift;
71
my $smoke_tests = shift;
73
eval "require $harness_class; 1" or die;
77
eval "\$$harness_class\::verbose = $verbose; 1" or die;
79
# Because Windows doesn't do this for us and listing all the *.t files
80
# out on the command line can blow over its exec limit.
81
require ExtUtils::Command;
82
push @ARGV, __PACKAGE__->_deep_t($author_tests)
83
if $author_tests and (exists $ENV{AUTHOR_TESTING} ? $ENV{AUTHOR_TESTING} : $is_author);
85
push @ARGV, __PACKAGE__->_deep_t($release_tests)
86
if $release_tests and $ENV{RELEASE_TESTING};
88
push @ARGV, __PACKAGE__->_deep_t($smoke_tests)
89
if $smoke_tests and $ENV{AUTOMATED_TESTING};
91
my @argv = ExtUtils::Command::expand_wildcards(@ARGV);
94
unshift @INC, map { File::Spec->rel2abs($_) } @_;
95
$harness_class->can('runtests')->(sort { lc $a cmp lc $b } @argv);
101
sub { /\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 }
105
my ($self, $dir) = @_;
109
File::Find::find(_wanted(\%test_dir), $dir);
110
return map { "$_/*.t" } sort keys %test_dir;