example/inc/Module/Install/Makefile.pm

filter: Statementstmt 64.2% 90 / 140 Branchbran 34.6% 18 / 52 Conditioncond 25.5% 11 / 43 MC/DCmcdc 4.0% 1 / 25 Subroutinesub 52.3% 11 / 21 Podpod 0.0% 0 / 14 totaltotal 44.4% 131 / 295 CC 48 SCAR 27.8
CC
48
Cov
51%
write
32.9
prompt
20.0
tests_recursive
20.0
CRAP 16.0
« example/inc/Module/Install/Metadata.pm ↑ Summary inc/ExtUtils/Depends.pm »
1 #line 1
2 #line 1
3 1 ▶package Module::Install::Makefile;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 use Module::Install::Base;
7 1 ▶use ExtUtils::MakeMaker ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 use vars qw{$VERSION $ISCORE @ISA};
10 1 BEGIN {
11 1 $VERSION = '0.77';
12 $ISCORE = 1;
13 @ISA = qw{Module::Install::Base};
14 0 ▶}
Subroutine Makefile: not called CC=1 SCAR=6.9
Pod undocumented
15  
16 1 sub Makefile { $_[0] }
17  
18 0 ▶my %seen = ();
Subroutine prompt: not called CC=4 SCAR=30.0
Pod undocumented
19 0  
20 sub prompt {
21 shift;
22 0  
23 0 ▶ # Infinite loop protection
Branch: 1 branch
BranchTrueFalseTotal
if (++$seen{"$c[1]|$c[2]|$_[0]"} > 3) 0 0 0
24 0 my @c = caller();
25 if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) {
26 die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])";
27 }
28 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'AUTOMATED_TESTING'} and not $ENV{'PERL_MM_USE_DEFAULT'}) { } 0 0 0
Condition0%0/3
$ENV{"AUTOMATED_TESTING"} and not $ENV{"PERL_MM_USE_DEFAULT"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"AUTOMATED_TESTING"} and not $ENV{"PERL_MM_USE_DEFAULT"}
$ENV{"AUTOMATED_TESTING"} not $ENV{"PERL_MM_USE_DEFAULT"}
Truth table0%0/3
A and not(B)
A= $ENV{"AUTOMATED_TESTING"}B= not $ENV{"PERL_MM_USE_DEFAULT"}
ABresult
0X0
100
111
29 0 # In automated testing, always use defaults
30 0 if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_MM_USE_DEFAULT} ) {
31 local $ENV{PERL_MM_USE_DEFAULT} = 1;
32 0 goto &ExtUtils::MakeMaker::prompt;
33 } else {
34 goto &ExtUtils::MakeMaker::prompt;
35 }
36 2 ▶}
Subroutine makemaker_args: called CC=2 SCAR=6.9
Pod undocumented
37 2  
38 2 ▶sub makemaker_args {
Condition100%2/2
$self->{"makemaker_args"} ||= {}
l!l
11
MC/DC100%1/1
$self->{"makemaker_args"} ||= {}
$self->{"makemaker_args"}
Truth table100%2/2
A
A= $self->{"makemaker_args"}
Aresult
11
00
39 2 my $self = shift;
40 2 my $args = ( $self->{makemaker_args} ||= {} );
41 %$args = ( %$args, @_ );
42 return $args;
43 }
44  
45 0 ▶# For mm args that take multiple space-seperated args,
Subroutine makemaker_append: not called CC=2 SCAR=17.9
Pod undocumented
46 0 # append an argument to the current list.
47 0 sub makemaker_append {
48 0 my $self = sShift;
49 my $name = shift;
50 0 ▶ my $args = $self->makemaker_args;
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{$name} ? : 0 0 0
51 $args->{name} = defined $args->{$name}
52 ? join( ' ', $args->{name}, @_ )
53 : join( ' ', @_ );
54 0 ▶}
Subroutine build_subdirs: not called CC=3 SCAR=24.8
Pod undocumented
55 0  
56 0 ▶sub build_subdirs {
Condition0%0/2
$self->makemaker_args->{"DIR"} ||= []
l!l
00
MC/DC0%0/1
$self->makemaker_args->{"DIR"} ||= []
$self->makemaker_args->{"DIR"}
Truth table0%0/2
A
A= $self->makemaker_args->{"DIR"}
Aresult
11
00
57 0 my $self = shift;
58 0 my $subdirs = $self->makemaker_args->{DIR} ||= [];
59 for my $subdir (@_) {
60 push @$subdirs, $subdir;
61 }
62 0 ▶}
Subroutine clean_files: not called CC=3 SCAR=24.8
Pod undocumented
63 0  
64 0 ▶sub clean_files {
Condition0%0/2
$self->makemaker_args->{"clean"} ||= {}
l!l
00
MC/DC0%0/1
$self->makemaker_args->{"clean"} ||= {}
$self->makemaker_args->{"clean"}
Truth table0%0/2
A
A= $self->makemaker_args->{"clean"}
Aresult
11
00
65 my $self = shift;
66 my $clean = $self->makemaker_args->{clean} ||= {};
67 0 ▶ %$clean = (
Condition0%0/3
$clean->{'FILES'} || ()
l!l&&r!l&&!r
000
MC/DC0%0/2
$clean->{'FILES'} || ()
$clean->{'FILES'} ()
Truth table0%0/3
A || B
A= $clean->{'FILES'}B= ()
ABresult
1X1
011
000
68 %$clean,
69 FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_),
70 );
71 0 ▶}
Subroutine realclean_files: not called CC=3 SCAR=24.8
Pod undocumented
72 0  
73 0 ▶sub realclean_files {
Condition0%0/2
$self->makemaker_args->{"realclean"} ||= {}
l!l
00
MC/DC0%0/1
$self->makemaker_args->{"realclean"} ||= {}
$self->makemaker_args->{"realclean"}
Truth table0%0/2
A
A= $self->makemaker_args->{"realclean"}
Aresult
11
00
74 my $self = shift;
75 my $realclean = $self->makemaker_args->{realclean} ||= {};
76 0 ▶ %$realclean = (
Condition0%0/3
$realclean->{'FILES'} || ()
l!l&&r!l&&!r
000
MC/DC0%0/2
$realclean->{'FILES'} || ()
$realclean->{'FILES'} ()
Truth table0%0/3
A || B
A= $realclean->{'FILES'}B= ()
ABresult
1X1
011
000
77 %$realclean,
78 FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_),
79 );
80 0 ▶}
Subroutine libs: not called CC=2 SCAR=17.9
Pod undocumented
81 0  
82 0 ▶sub libs {
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
83 0 my $self = shift;
84 my $libs = ref $_[0] ? shift : [ shift ];
85 $self->makemaker_args( LIBS => $libs );
86 0 ▶}
Subroutine inc: not called CC=1 SCAR=6.9
Pod undocumented
87 0  
88 0 sub inc {
89 my $self = shift;
90 $self->makemaker_args( INC => shift );
91 1 }
92  
93 0 ▶my %test_dir = ();
Subroutine _wanted_t: not called CC=3 SCAR=24.8
94 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
/\.t$/ and -f $_ and $test_dir{$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
95 sub _wanted_t {
96 /\.t$/ and -f $_ and $test_dir{$File::Find::dir} = 1;
97 0 ▶}
Subroutine tests_recursive: not called CC=4 SCAR=30.0
Pod undocumented
98 0  
99 0 ▶sub tests_recursive {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->tests) 0 0 0
100 0 my $self = shift;
101 if ( $self->tests ) {
102 0 ▶ die "tests_recursive will not work if tests are already defined";
Condition0%0/2
shift() || 't'
l!l
00
MC/DC0%0/1
shift() || 't'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
103 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 0 0 0
104 0 my $dir = shift || 't';
105 unless ( -d $dir ) {
106 0 die "tests_recursive dir '$dir' does not exist";
107 0 }
108 0 %test_dir = ();
109 0 require File::Find;
110 File::Find::find( \&_wanted_t, $dir );
111 $self->tests( join ' ', map { "$_/*.t" } sort keys %test_dir );
112 1 ▶}
Subroutine write: called CC=19 SCAR=34.9
Pod undocumented
113 1  
114 1 ▶sub write {
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
115 my $self = shift;
116 die "&Makefile->write() takes no arguments\n" if @_;
117 1  
118 # Make sure we have a new enough
119 require ExtUtils::MakeMaker;
120  
121 # MakeMaker can complain about module versions that include
122 # an underscore, even though its own version may contain one!
123 # Hence the funny regexp to get rid of it. See RT #35800
124 1 # for details.
125  
126 $self->configure_requires( 'ExtUtils::MakeMaker' => $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/ );
127 1  
128 1 # Generate the
129 1 ▶ my $args = $self->makemaker_args;
Condition33%1/3
$self->module_name || $self->name
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->module_name || $self->name
$self->module_name $self->name
Truth table33%1/3
A || B
A= $self->module_nameB= $self->name
ABresult
1X1
011
000
130 1 $args->{DISTNAME} = $self->name;
131 1 $args->{NAME} = $self->module_name || $self->name;
132 1 ▶ $args->{VERSION} = $self->version;
Branch: 1 branch
BranchTrueFalseTotal
if ($self->tests) 1 0 1
133 1 $args->{NAME} =~ s/-/::/g;
134 if ( $self->tests ) {
135 1 ▶ $args->{test} = { TESTS => $self->tests };
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= "5.005") 1 0 1
136 1 }
137 1 if ($] >= 5.005) {
138 $args->{ABSTRACT} = $self->abstract;
139 1 ▶ $args->{AUTHOR} = $self->author;
Branch: 1 branch
BranchTrueFalseTotal
if (eval $ExtUtils::MakeMaker::VERSION >= "6.1") 1 0 1
140 1 }
141 if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) {
142 1 ▶ $args->{NO_META} = 1;
Branch: 1 branch
BranchTrueFalseTotal
if (eval $ExtUtils::MakeMaker::VERSION > "6.17" and $self->sign) 0 1 1
Condition33%1/3
eval $ExtUtils::MakeMaker::VERSION > "6.17" and $self->sign
!ll&&!rl&&r
010
MC/DC0%0/2
eval $ExtUtils::MakeMaker::VERSION > "6.17" and $self->sign
eval $ExtUtils::MakeMaker::VERSION > "6.17" $self->sign
Truth table33%1/3
A and B
A= eval $ExtUtils::MakeMaker::VERSION > "6.17"B= $self->sign
ABresult
0X0
100
111
143 0 }
144 if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 and $self->sign ) {
145 1 ▶ $args->{SIGN} = 1;
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_admin) 1 0 1
146 1 }
147 unless ( $self->is_admin ) {
148 delete $args->{SIGN};
149 }
150 1 ▶ 
Condition50%1/2
$args->{"PREREQ_PM"} ||= {}
l!l
01
MC/DC0%0/1
$args->{"PREREQ_PM"} ||= {}
$args->{"PREREQ_PM"}
Truth table50%1/2
A
A= $args->{"PREREQ_PM"}
Aresult
11
00
151 # merge both kinds of requires into prereq_pm
152 3 my $prereq = ($args->{PREREQ_PM} ||= {});
153 1 %$prereq = ( %$prereq,
154 map { @$_ }
155 map { @$_ }
156 grep $_,
157 ($self->configure_requires, $self->build_requires, $self->requires)
158 );
159 1  
160 # Remove any reference to perl, PREREQ_PM doesn't support it
161 delete $args->{PREREQ_PM}->{perl};
162 1 ▶ 
Condition50%1/2
$args->{"DIR"} ||= []
l!l
01
MC/DC0%0/1
$args->{"DIR"} ||= []
$args->{"DIR"}
Truth table50%1/2
A
A= $args->{"DIR"}
Aresult
11
00
163 1 ▶ # merge both kinds of requires into prereq_pm
Branch: 1 branch
BranchTrueFalseTotal
if ($self->bundles) 0 1 1
164 0 my $subdirs = ($args->{DIR} ||= []);
165 0 if ($self->bundles) {
166 0 ▶ foreach my $bundle (@{ $self->bundles }) {
Branch: 1 branch
BranchTrueFalseTotal
if -d $dir 0 0 0
167 0 my ($file, $dir) = @$bundle;
168 push @$subdirs, $dir if -d $dir;
169 delete $prereq->{$file};
170 }
171 1 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
if (my $perl_version = $self->perl_version) 1 0 1
172 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.1
Branch: 1 branch
BranchTrueFalseTotal
eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version" 1 0 1
173 if ( my $perl_version = $self->perl_version ) {
174 eval "use $perl_version; 1"
175 or die "ERROR: perl: Version $] is installed, "
176 . "but we need version >= $perl_version";
177 1 }
178  
179 1 $args->{INSTALLDIRS} = $self->installdirs;
180  
181 1 my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_})} keys %$args;
182 1 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (my $preop = $self->admin->preop($user_preop)) 0 1 1
183 0 my $user_preop = delete $args{dist}->{PREOP};
184 0 if (my $preop = $self->admin->preop($user_preop)) {
185 foreach my $key ( keys %$preop ) {
186 $args{dist}->{$key} = $preop->{$key};
187 }
188 1 }
189 1 ▶ 
Condition50%1/2
$mm->{'FIRST_MAKEFILE'} || 'Makefile'
l!l
10
MC/DC0%0/1
$mm->{'FIRST_MAKEFILE'} || 'Makefile'
$mm->{'FIRST_MAKEFILE'}
Truth table50%1/2
A
A= $mm->{'FIRST_MAKEFILE'}
Aresult
11
00
190 my $mm = ExtUtils::MakeMaker::WriteMakefile(%args);
191 $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile');
192 1 ▶}
Subroutine fix_up_makefile: called CC=10 SCAR=24.0
Pod undocumented
193 1  
194 1 sub fix_up_makefile {
195 1 ▶ my $self = shift;
Condition50%1/2
ref $self->_top || ''
l!l
10
MC/DC0%0/1
ref $self->_top || ''
ref $self->_top
Truth table50%1/2
A
A= ref $self->_top
Aresult
11
00
196 1 ▶ my $makefile_name = shift;
Condition50%1/2
$self->_top->VERSION || ''
l!l
10
MC/DC0%0/1
$self->_top->VERSION || ''
$self->_top->VERSION
Truth table50%1/2
A
A= $self->_top->VERSION
Aresult
11
00
197 my $top_class = ref($self->_top) || '';
198 1 ▶ my $top_version = $self->_top->VERSION || '';
Branch: 1 branch
BranchTrueFalseTotal
$self->preamble ? : 0 1 1
199  
200 my $preamble = $self->preamble
201 ? "# Preamble by $top_class $top_version\n"
202 1 ▶ . $self->preamble
Condition50%1/2
$self->postamble || ''
l!l
01
MC/DC0%0/1
$self->postamble || ''
$self->postamble
Truth table50%1/2
A
A= $self->postamble
Aresult
11
00
203 : '';
204 my $postamble = "# Postamble by $top_class $top_version\n"
205 1 . ($self->postamble || '');
206 1 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open ${makefile_name}: $!" 1 0 1
207 1 local *MAKEFILE;
208 1 ▶ open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
Branch: 1 branch
BranchTrueFalseTotal
close MAKEFILE or die $! 1 0 1
209 my $makefile = do { local $/; <MAKEFILE> };
210 1 close MAKEFILE or die $!;
211 1  
212 1 $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
213 1 $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
214 1 $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g;
215 $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m;
216 $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m;
217  
218 # Module::Install will never be used to build the Core Perl
219 1 # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks
220 # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist
221 $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m;
222 #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m;
223 1  
224 # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well.
225 $makefile =~ s/(\"?)-I\$\(PERL_LIB\)\1//g;
226  
227 # XXX - This is currently unused; not sure if it breaks other MM-users
228 1 ▶ # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg;
Branch: 1 branch
BranchTrueFalseTotal
open MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open ${makefile_name}: $!" 1 0 1
229 1 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
print MAKEFILE "$preamble$makefile$postamble" or die $! 1 0 1
230 1 ▶ open MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
Branch: 1 branch
BranchTrueFalseTotal
close MAKEFILE or die $! 1 0 1
231 print MAKEFILE "$preamble$makefile$postamble" or die $!;
232 1 close MAKEFILE or die $!;
233  
234 1;
235 1 ▶}
Subroutine preamble: called CC=2 SCAR=7.1
Pod undocumented
236 1  
237 1 ▶sub preamble {
Branch: 1 branch
BranchTrueFalseTotal
if defined $text 0 1 1
238 1 my ($self, $text) = @_;
239 $self->{preamble} = $text . $self->{preamble} if defined $text;
240 $self->{preamble};
241 1 ▶}
Subroutine postamble: called CC=3 SCAR=12.0
Pod undocumented
242 1  
243 1 ▶sub postamble {
Condition33%1/3
$self->{"postamble"} ||= $self->admin->postamble
l!l&&r!l&&!r
001
MC/DC0%0/2
$self->{"postamble"} ||= $self->admin->postamble
$self->{"postamble"} $self->admin->postamble
Truth table33%1/3
A ||= B
A= $self->{"postamble"}B= $self->admin->postamble
ABresult
1X1
011
000
244 1 ▶ my ($self, $text) = @_;
Branch: 1 branch
BranchTrueFalseTotal
if defined $text 0 1 1
245 $self->{postamble} ||= $self->admin->postamble;
246 1 $self->{postamble} .= $text if defined $text;
247 $self->{postamble}
248 1 }
249  
250 1;
251  
252 __END__
« example/inc/Module/Install/Metadata.pm ↑ Summary inc/ExtUtils/Depends.pm »