1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#line 1
use strict;
use warnings;
use 5.006;
package Module::Install::ExtraTests;
use Module::Install::Base;
BEGIN {
our $VERSION = '0.004';
our $ISCORE = 1;
our @ISA = qw{Module::Install::Base};
}
sub extra_tests {
my ($self) = @_;
return unless -d 'xt';
return unless my @content = grep { $_ =~ /^[.]/ } <xt/*>;
die "unknown files found in ./xt" if grep { -f } @content;
my %known = map {; $_ => 1 } qw(author smoke release);
my @unknown = grep { not $known{$_} } @content;
die "unknown directories found in ./xt: @unknown" if @unknown;
{
no warnings qw(closure once);
package # The newline tells PAUSE, "DO NOT INDEXING!"
MY;
sub test_via_harness {
my ($self, $perl, $tests) = @_;
my $a_str = -d 'xt/author' ? 'xt/author' : '';
my $r_str = -d 'xt/release' ? 'xt/release' : '';
my $s_str = -d 'xt/smoke' ? 'xt/smoke' : '';
my $is_author = $Module::Install::AUTHOR ? 1 : 0;
return qq{\t$perl "-Iinc" "-MModule::Install::ExtraTests" }
. qq{"-e" "Module::Install::ExtraTests::__harness('Test::Harness', $is_author, '$a_str', '$r_str', '$s_str', \$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
}
sub dist_test {
my ($self, @args) = @_;
my $text = $self->SUPER::dist_test(@args);
my @lines = split /\n/, $text;
$_ =~ s/ (\S*MAKE\S* test )/ RELEASE_TESTING=1 $1 / for grep { m/ test / } @lines;
return join "\n", @lines;
}
}
}
sub __harness {
my $harness_class = shift;
my $is_author = shift;
my $author_tests = shift;
my $release_tests = shift;
my $smoke_tests = shift;
eval "require $harness_class; 1" or die;
require File::Spec;
my $verbose = shift;
eval "\$$harness_class\::verbose = $verbose; 1" or die;
# Because Windows doesn't do this for us and listing all the *.t files
# out on the command line can blow over its exec limit.
require ExtUtils::Command;
push @ARGV, __PACKAGE__->_deep_t($author_tests)
if $author_tests and $is_author;
push @ARGV, __PACKAGE__->_deep_t($release_tests)
if $release_tests and $ENV{RELEASE_TESTING};
push @ARGV, __PACKAGE__->_deep_t($smoke_tests)
if $smoke_tests and $ENV{AUTOMATED_TESTING};
my @argv = ExtUtils::Command::expand_wildcards(@ARGV);
local @INC = @INC;
unshift @INC, map { File::Spec->rel2abs($_) } @_;
$harness_class->can('runtests')->(sort { lc $a cmp lc $b } @argv);
}
sub _wanted {
my $href = shift;
no warnings 'once';
sub { /\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 }
}
sub _deep_t {
my ($self, $dir) = @_;
require File::Find;
my %test_dir;
File::Find::find(_wanted(\%test_dir), $dir);
return map { "$_/*.t" } sort keys %test_dir;
}
1;
__END__
|