blib/lib/Module/Install/ExtraTests.pm

filter: Statementstmt 31.7% 26 / 82 Branchbran 0.0% 0 / 34 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 53.3% 8 / 15 Podpod 100% 1 / 1 totaltotal 23.0% 35 / 152 CC 23 SCAR 36.8
CC
23
Cov
20%
__harness
102.9
test_via_harness
42.0
extra_tests
21.7
CRAP 39.8
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 package Module::Install::ExtraTests;
5 1 ▶use Module::Install::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 our $VERSION = '0.008';
9 1 our $ISCORE = 1;
10 1 our @ISA = qw{Module::Install::Base};
11 }
12  
13 1 our $use_extratests = 0;
14  
15 0 ▶sub extra_tests {
Subroutine extra_tests: not called CC=5 SCAR=30.8
Pod documented
16 0 my ($self) = @_;
17  
18 0 ▶ return unless -d 'xt';
Branch: 1 branch
BranchTrueFalseTotal
unless -d "xt" 0 0 0
19 0 ▶ return unless my @content = grep { $_ !~ /^[.]/ } <xt/*>;
Subroutine BEGIN: called CC=1 SCAR=1.7
Branch: 1 branch
BranchTrueFalseTotal
unless my(@content) = grep({not $_ =~ /^[.]/;} glob("xt/*")) 0 0 0
20  
21 0 ▶ die "unknown files found in ./xt" if grep { !-d } @content;
Branch: 1 branch
BranchTrueFalseTotal
if grep {not -d $_;} @content 0 0 0
22  
23 0 my %known = map {; "xt/$_" => 1 } qw(author smoke release);
24 0 my @unknown = grep { not $known{$_} } @content;
25 0 ▶ die "unknown directories found in ./xt: @unknown" if @unknown;
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 0 0 0
26  
27 0 $use_extratests = 1;
28  
29 0 return;
30 }
31  
32 {
33 1 ▶ no warnings qw(once);
Subroutine BEGIN: called CC=1 SCAR=0.0
34 package # The newline tells PAUSE, "DO NOT INDEXING!"
35 MY;
36 0 ▶ sub test_via_harness {
Subroutine test_via_harness: not called CC=6 SCAR=37.4
37 0 my $self = shift;
38  
39 0 ▶ return $self->SUPER::test_via_harness(@_)
Branch: 1 branch
BranchTrueFalseTotal
unless $Module::Install::ExtraTests::use_extratests 0 0 0
40 unless $use_extratests;
41  
42 0 my ($perl, $tests) = @_;
43 0 ▶ my $a_str = -d 'xt/author' ? 'xt/author' : '';
Branch: 1 branch
BranchTrueFalseTotal
-d 'xt/author' ? : 0 0 0
44 0 ▶ my $r_str = -d 'xt/release' ? 'xt/release' : '';
Branch: 1 branch
BranchTrueFalseTotal
-d 'xt/release' ? : 0 0 0
45 0 ▶ my $s_str = -d 'xt/smoke' ? 'xt/smoke' : '';
Branch: 1 branch
BranchTrueFalseTotal
-d 'xt/smoke' ? : 0 0 0
46 0 ▶ my $is_author = $Module::Install::AUTHOR ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$Module::Install::AUTHOR ? : 0 0 0
47  
48 0 return qq{\t$perl "-Iinc" "-MModule::Install::ExtraTests" }
49 . qq{"-e" "Module::Install::ExtraTests::__harness('Test::Harness', $is_author, '$a_str', '$r_str', '$s_str', \$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
50 }
51  
52 0 ▶ sub dist_test {
Subroutine dist_test: not called CC=3 SCAR=24.8
53 0 my ($self, @args) = @_;
54  
55 0 ▶ return $self->SUPER::dist_test(@args)
Branch: 1 branch
BranchTrueFalseTotal
unless $Module::Install::ExtraTests::use_extratests 0 0 0
56 unless $use_extratests;
57  
58 0 my $text = $self->SUPER::dist_test(@args);
59 0 my @lines = split /\n/, $text;
60 0 $_ =~ s/ (\S*MAKE\S* test )/ RELEASE_TESTING=1 $1 / for grep { m/ test / } @lines;
61 0 return join "\n", @lines;
62 }
63 }
64  
65 1 ▶sub __harness {
Subroutine __harness: not called CC=10 SCAR=46.3
66 0 my $harness_class = shift;
67 0 my $is_author = shift;
68 0 my $author_tests = shift;
69 0 my $release_tests = shift;
70 0 my $smoke_tests = shift;
71  
72 0 ▶ eval "require $harness_class; 1" or die;
Branch: 1 branch
BranchTrueFalseTotal
eval "require $harness_class; 1" or die 0 0 0
73 0 require File::Spec;
74  
75 0 my $verbose = shift;
76 0 ▶ eval "\$$harness_class\::verbose = $verbose; 1" or die;
Branch: 1 branch
BranchTrueFalseTotal
eval "\$${harness_class}::verbose = $verbose; 1" or die 0 0 0
77  
78 # Because Windows doesn't do this for us and listing all the *.t files
79 # out on the command line can blow over its exec limit.
80 0 require ExtUtils::Command;
81 push @ARGV, __PACKAGE__->_deep_t($author_tests)
82 0 ▶ if $author_tests and (exists $ENV{AUTHOR_TESTING} ? $ENV{AUTHOR_TESTING} : $is_author);
Branch: 2 branches
BranchTrueFalseTotal
if $author_tests and exists $ENV{"AUTHOR_TESTING"} ? $ENV{"AUTHOR_TESTING"} : $is_author 0 0 0
exists $ENV{'AUTHOR_TESTING'} ? : 0 0 0
Condition0%0/3
$author_tests and exists $ENV{"AUTHOR_TESTING"} ? $ENV{"AUTHOR_TESTING"} : $is_author
!ll&&!rl&&r
000
MC/DC0%0/2
$author_tests and exists $ENV{"AUTHOR_TESTING"} ? $ENV{"AUTHOR_TESTING"} : $is_author
$author_tests exists $ENV{"AUTHOR_TESTING"} ? $ENV{"AUTHOR_TESTING"} : $is_author
Truth table0%0/3
A and B
A= $author_testsB= exists $ENV{"AUTHOR_TESTING"} ? $ENV{"AUTHOR_TESTING"} : $is_author
ABresult
0X0
100
111
83  
84 push @ARGV, __PACKAGE__->_deep_t($release_tests)
85 0 ▶ if $release_tests and $ENV{RELEASE_TESTING};
Branch: 1 branch
BranchTrueFalseTotal
if $release_tests and $ENV{"RELEASE_TESTING"} 0 0 0
Condition0%0/3
$release_tests and $ENV{"RELEASE_TESTING"}
!ll&&!rl&&r
000
MC/DC0%0/2
$release_tests and $ENV{"RELEASE_TESTING"}
$release_tests $ENV{"RELEASE_TESTING"}
Truth table0%0/3
A and B
A= $release_testsB= $ENV{"RELEASE_TESTING"}
ABresult
0X0
100
111
86  
87 push @ARGV, __PACKAGE__->_deep_t($smoke_tests)
88 0 ▶ if $smoke_tests and $ENV{AUTOMATED_TESTING};
Branch: 1 branch
BranchTrueFalseTotal
if $smoke_tests and $ENV{"AUTOMATED_TESTING"} 0 0 0
Condition0%0/3
$smoke_tests and $ENV{"AUTOMATED_TESTING"}
!ll&&!rl&&r
000
MC/DC0%0/2
$smoke_tests and $ENV{"AUTOMATED_TESTING"}
$smoke_tests $ENV{"AUTOMATED_TESTING"}
Truth table0%0/3
A and B
A= $smoke_testsB= $ENV{"AUTOMATED_TESTING"}
ABresult
0X0
100
111
89  
90 0 my @argv = ExtUtils::Command::expand_wildcards(@ARGV);
91  
92 0 local @INC = @INC;
93 0 unshift @INC, map { File::Spec->rel2abs($_) } @_;
94 0 $harness_class->can('runtests')->(sort { lc $a cmp lc $b } @argv);
95 }
96  
97 0 ▶sub _wanted {
Subroutine _wanted: not called CC=1 SCAR=3.3
98 0 my $href = shift;
99 1 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
100 0 ▶ sub { /\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 }
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
/\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 0 0 0
Condition0%0/3
/\.t$/ and -f $_
!ll&&!rl&&r
000
MC/DC0%0/2
/\.t$/ and -f $_
/\.t$/ -f $_
Truth table0%0/3
A and B
A= /\.t$/B= -f $_
ABresult
0X0
100
111
101 0 }
102  
103 0 ▶sub _deep_t {
Subroutine _deep_t: not called CC=1 SCAR=6.9
104 0 my ($self, $dir) = @_;
105 0 require File::Find;
106  
107 0 my %test_dir;
108 0 File::Find::find(_wanted(\%test_dir), $dir);
109 0 return map { "$_/*.t" } sort keys %test_dir;
110 }
111  
112 1 1;
113 __END__
↑ Summary