lib/Module/Build/Base.pm

filter: Statementstmt 73.4% 2023 / 2756 Branchbran 57.4% 838 / 1460 Conditioncond 48.1% 257 / 534 MC/DCmcdc 23.5% 74 / 314 Subroutinesub 83.0% 270 / 325 Podpod 0.0% 0 / 198 totaltotal 61.9% 3462 / 5587 CC 1035 SCAR 31.0
CC
1035
Cov
66%
read_modulebuildrc
182.1
_feature_deps_msg
156.0
prereq_report
156.0
CRAP 22.2
« blib/lib/Module/Build/Compat.pm ↑ Summary blib/lib/Module/Build/Platform/Windows.pm »
1 # -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*-
2 # vim:ts=8:sw=2:et:sta:sts=2
3 package Module::Build::Base;
4  
5 301 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 301 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 297 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 297 our $VERSION = '0.4234';
10 297 $VERSION = eval $VERSION;
11  
12 297 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 297 ▶use Cwd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 297 ▶use File::Copy ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 297 ▶use File::Find ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 297 ▶use File::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 297 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 297 ▶use File::Spec 0.82 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 297 ▶use File::Compare ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 297 ▶use Module::Build::Dumper ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21 297 ▶use Text::ParseWords ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 297 ▶use Module::Metadata;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 297 ▶use Module::Build::Notes;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 297 ▶use Module::Build::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 297 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28  
29 #################### Constructors ###########################
30 91 ▶sub new {
Subroutine new: called CC=9 SCAR=23.1
Pod undocumented
31 91 my $self = shift()->_construct(@_);
32  
33 80 ▶ $self->{invoked_action} = $self->{action} ||= 'Build_PL';
Condition50%1/2
$self->{"action"} ||= "Build_PL"
l!l
080
MC/DC0%0/1
$self->{"action"} ||= "Build_PL"
$self->{"action"}
Truth table50%1/2
A
A= $self->{"action"}
Aresult
11
00
34 80 $self->cull_args(@ARGV);
35  
36 die "Too early to specify a build action '$self->{action}'. Do 'Build $self->{action}' instead.\n"
37 80 ▶ if $self->{action} && $self->{action} ne 'Build_PL';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"action"} and $self->{"action"} ne "Build_PL" 0 80 80
Condition33%1/3
$self->{"action"} and $self->{"action"} ne "Build_PL"
!ll&&!rl&&r
0800
MC/DC0%0/2
$self->{"action"} and $self->{"action"} ne "Build_PL"
$self->{"action"} $self->{"action"} ne "Build_PL"
Truth table33%1/3
A and B
A= $self->{"action"}B= $self->{"action"} ne "Build_PL"
ABresult
0X0
100
111
38  
39 80 $self->check_manifest;
40 80 $self->auto_require;
41  
42 # All checks must run regardless if one fails, so no short circuiting!
43 80 ▶ if( grep { !$_ } $self->check_prereq, $self->check_autofeatures ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not $_;} $self->check_prereq, $self->check_autofeatures) 10 70 80
44 10 $self->log_warn(<<EOF);
45  
46 ERRORS/WARNINGS FOUND IN PREREQUISITES. You may wish to install the versions
47 of the modules indicated above before proceeding with this installation
48  
49 EOF
50 10 ▶ unless (
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->dist_name eq "Module-Build" or $ENV{"PERL5_CPANPLUS_IS_RUNNING"} or $ENV{"PERL5_CPAN_IS_RUNNING"}) 10 0 10
Condition33%2/6
$self->dist_name eq "Module-Build" or $ENV{"PERL5_CPANPLUS_IS_RUNNING"} or $ENV{"PERL5_CPAN_IS_RUNNING"}
l!l&&r!l&&!r
0010
$self->dist_name eq "Module-Build" or $ENV{"PERL5_CPANPLUS_IS_RUNNING"}
l!l&&r!l&&!r
0010
MC/DC0%0/3
$self->dist_name eq "Module-Build" or $ENV{"PERL5_CPANPLUS_IS_RUNNING"} or $ENV{"PERL5_CPAN_IS_RUNNING"}
$self->dist_name eq "Module-Build" $ENV{"PERL5_CPANPLUS_IS_RUNNING"} $ENV{"PERL5_CPAN_IS_RUNNING"}
Truth table25%1/4
A or B or C
A= $self->dist_name eq "Module-Build"B= $ENV{"PERL5_CPANPLUS_IS_RUNNING"}C= $ENV{"PERL5_CPAN_IS_RUNNING"}
ABCresult
1XX1
01X1
0011
0000
51 $self->dist_name eq 'Module-Build' ||
52 $ENV{PERL5_CPANPLUS_IS_RUNNING} || $ENV{PERL5_CPAN_IS_RUNNING}
53 ) {
54 10 $self->log_warn(
55 "Run 'Build installdeps' to install missing prerequisites.\n\n"
56 );
57 }
58 }
59  
60 # record for later use in resume;
61 80 $self->{properties}{_added_to_INC} = [ $self->_added_to_INC ];
62  
63 69 $self->set_bundle_inc;
64  
65 69 $self->dist_name;
66 69 $self->dist_version;
67 69 $self->release_status;
68 69 ▶ $self->_guess_module_name unless $self->module_name;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->module_name 5 64 69
69  
70 69 $self->_find_nested_builds;
71  
72 69 return $self;
73 }
74  
75 472 ▶sub resume {
Subroutine resume: called CC=10 SCAR=31.1
Pod undocumented
76 472 my $package = shift;
77 472 my $self = $package->_construct(@_);
78 469 $self->read_config;
79  
80 469 ▶ my @added_earlier = @{ $self->{properties}{_added_to_INC} || [] };
Condition50%1/2
$self->{'properties'}{'_added_to_INC'} || []
l!l
4690
MC/DC0%0/1
$self->{'properties'}{'_added_to_INC'} || []
$self->{'properties'}{'_added_to_INC'}
Truth table50%1/2
A
A= $self->{'properties'}{'_added_to_INC'}
Aresult
11
00
81  
82 469 @INC = ($self->_added_to_INC, @added_earlier, $self->_default_INC);
83  
84 # If someone called Module::Build->current() or
85 # Module::Build->new_from_context() and the correct class to use is
86 # actually a *subclass* of Module::Build, we may need to load that
87 # subclass here and re-delegate the resume() method to it.
88 465 ▶ unless ( $package->isa($self->build_class) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($package->isa($self->build_class)) 0 465 465
89 0 my $build_class = $self->build_class;
90 0 ▶ my $config_dir = $self->config_dir || '_build';
Condition0%0/2
$self->config_dir || '_build'
l!l
00
MC/DC0%0/1
$self->config_dir || '_build'
$self->config_dir
Truth table0%0/2
A
A= $self->config_dir
Aresult
11
00
91 0 my $build_lib = File::Spec->catdir( $config_dir, 'lib' );
92 0 unshift( @INC, $build_lib );
93 0 ▶ unless ( $build_class->can('new') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($build_class->can("new")) 0 0 0
94 0 ▶ eval "require $build_class; 1" or die "Failed to re-load '$build_class': $@";
Branch: 1 branch
BranchTrueFalseTotal
eval "require $build_class; 1" or die "Failed to re-load '${build_class}': $@" 0 0 0
95 }
96 0 return $build_class->resume(@_);
97 }
98  
99 465 ▶ unless ($self->_perl_is_same($self->{properties}{perl})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_perl_is_same($self->{"properties"}{"perl"})) 0 368 368
100 0 my $perl = $self->find_perl_interpreter;
101 0 die(<<"DIEFATAL");
102 * FATAL ERROR: Perl interpreter mismatch. Configuration was initially
103 created with '$self->{properties}{perl}'
104 but we are now using '$perl'. You must
105 run 'Build realclean' or 'make realclean' and re-configure.
106 DIEFATAL
107 }
108  
109 368 $self->cull_args(@ARGV);
110  
111 368 ▶ unless ($self->allow_mb_mismatch) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->allow_mb_mismatch) 368 0 368
112 368 my $mb_version = $Module::Build::VERSION;
113 368 ▶ if ( $mb_version ne $self->{properties}{mb_version} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb_version ne $self->{"properties"}{"mb_version"}) 0 368 368
114 0 $self->log_warn(<<"MISMATCH");
115 * WARNING: Configuration was initially created with Module::Build
116 version '$self->{properties}{mb_version}' but we are now using version '$mb_version'.
117 If errors occur, you must re-run the Build.PL or Makefile.PL script.
118 MISMATCH
119 }
120 }
121  
122 368 ▶ $self->{invoked_action} = $self->{action} ||= 'build';
Condition100%2/2
$self->{"action"} ||= "build"
l!l
1367
MC/DC100%1/1
$self->{"action"} ||= "build"
$self->{"action"}
Truth table100%2/2
A
A= $self->{"action"}
Aresult
11
00
123  
124 368 return $self;
125 }
126  
127 481 ▶sub new_from_context {
Subroutine new_from_context: called CC=1 SCAR=0.0
Pod undocumented
128 481 my ($package, %args) = @_;
129  
130 481 $package->run_perl_script('Build.PL',[],[$package->unparse_args(\%args)]);
131 427 return $package->resume;
132 }
133  
134 21 ▶sub current {
Subroutine current: called CC=1 SCAR=0.0
Pod undocumented
135 # hmm, wonder what the right thing to do here is
136 21 local @ARGV;
137 21 return shift()->resume;
138 }
139  
140 563 ▶sub _construct {
Subroutine _construct: called CC=20 SCAR=31.4
141 563 my ($package, %input) = @_;
142  
143 563 ▶ my $args = delete $input{args} || {};
Condition50%1/2
delete $input{'args'} || {}
l!l
0563
MC/DC0%0/1
delete $input{'args'} || {}
delete $input{'args'}
Truth table50%1/2
A
A= delete $input{'args'}
Aresult
11
00
144 563 ▶ my $config = delete $input{config} || {};
Condition100%2/2
delete $input{'config'} || {}
l!l
6557
MC/DC100%1/1
delete $input{'config'} || {}
delete $input{'config'}
Truth table100%2/2
A
A= delete $input{'config'}
Aresult
11
00
145  
146 563 my $self = bless {
147 args => {%$args},
148 config => Module::Build::Config->new(values => $config),
149 properties => {
150 base_dir => $package->cwd,
151 mb_version => $Module::Build::VERSION,
152 %input,
153 },
154 phash => {},
155 stash => {}, # temporary caching, not stored in _build
156 }, $package;
157  
158 563 $self->_set_defaults;
159 563 my ($p, $ph) = ($self->{properties}, $self->{phash});
160  
161 563 foreach (qw(notes config_data features runtime_params cleanup auto_features)) {
162 3378 my $file = File::Spec->catfile($self->config_dir, $_);
163 3378 $ph->{$_} = Module::Build::Notes->new(file => $file);
164 3378 ▶ $ph->{$_}->restore if -e $file;
Branch: 1 branch
BranchTrueFalseTotal
if -e $file 2880 498 3378
165 3378 ▶ if (exists $p->{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $p->{$_}) 0 3378 3378
166 0 my $vals = delete $p->{$_};
167 0 foreach my $k (sort keys %$vals) {
168 0 $self->$_($k, $vals->{$k});
169 }
170 }
171 }
172  
173 # The following warning could be unnecessary if the user is running
174 # an embedded perl, but there aren't too many of those around, and
175 # embedded perls aren't usually used to install modules, and the
176 # installation process sometimes needs to run external scripts
177 # (e.g. to run tests).
178 563 ▶ $p->{perl} = $self->find_perl_interpreter
Branch: 1 branch
BranchTrueFalseTotal
$p->{"perl"} = $self->find_perl_interpreter or $self->log_warn("Warning: Can't locate your perl binary") 549 0 549
179 or $self->log_warn("Warning: Can't locate your perl binary");
180  
181 549 ▶ my $blibdir = sub { File::Spec->catdir($p->{blib}, @_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
182 549 ▶ $p->{bindoc_dirs} ||= [ $blibdir->("script") ];
Condition100%2/2
$p->{"bindoc_dirs"} ||= [&$blibdir("script")]
l!l
2547
MC/DC100%1/1
$p->{"bindoc_dirs"} ||= [&$blibdir("script")]
$p->{"bindoc_dirs"}
Truth table100%2/2
A
A= $p->{"bindoc_dirs"}
Aresult
11
00
183 549 ▶ $p->{libdoc_dirs} ||= [ $blibdir->("lib"), $blibdir->("arch") ];
Condition100%2/2
$p->{"libdoc_dirs"} ||= [&$blibdir("lib"), &$blibdir("arch")]
l!l
1548
MC/DC100%1/1
$p->{"libdoc_dirs"} ||= [&$blibdir("lib"), &$blibdir("arch")]
$p->{"libdoc_dirs"}
Truth table100%2/2
A
A= $p->{"libdoc_dirs"}
Aresult
11
00
184  
185 549 ▶ $p->{dist_author} = [ $p->{dist_author} ] if defined $p->{dist_author} and not ref $p->{dist_author};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->{"dist_author"} and not ref $p->{"dist_author"} 8 541 549
Condition66%2/3
defined $p->{"dist_author"} and not ref $p->{"dist_author"}
!ll&&!rl&&r
54108
MC/DC50%1/2
defined $p->{"dist_author"} and not ref $p->{"dist_author"}
defined $p->{"dist_author"} not ref $p->{"dist_author"}
Truth table66%2/3
A and not(B)
A= defined $p->{"dist_author"}B= not ref $p->{"dist_author"}
ABresult
0X0
100
111
186  
187 # Synonyms
188 549 ▶ $p->{requires} = delete $p->{prereq} if defined $p->{prereq};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->{"prereq"} 0 549 549
189 549 ▶ $p->{script_files} = delete $p->{scripts} if defined $p->{scripts};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->{"scripts"} 2 547 549
190  
191 # Convert to from shell strings to arrays
192 549 for ('extra_compiler_flags', 'extra_linker_flags') {
193 1098 ▶ $p->{$_} = [ $self->split_like_shell($p->{$_}) ] if exists $p->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if exists $p->{$_} 1098 0 1098
194 }
195  
196 # Convert to arrays
197 549 for ('include_dirs') {
198 549 ▶ $p->{$_} = [ $p->{$_} ] if exists $p->{$_} && !ref $p->{$_}
Branch: 1 branch
BranchTrueFalseTotal
if exists $p->{$_} and not ref $p->{$_} 3 546 549
Condition66%2/3
exists $p->{$_} and not ref $p->{$_}
!ll&&!rl&&r
05463
MC/DC50%1/2
exists $p->{$_} and not ref $p->{$_}
exists $p->{$_} not ref $p->{$_}
Truth table66%2/3
A and not(B)
A= exists $p->{$_}B= not ref $p->{$_}
ABresult
0X0
100
111
199 }
200  
201 0 $self->add_to_cleanup( @{delete $p->{add_to_cleanup}} )
202 549 ▶ if $p->{add_to_cleanup};
Branch: 1 branch
BranchTrueFalseTotal
if $p->{"add_to_cleanup"} 0 549 549
203  
204 549 return $self;
205 }
206  
207 ################## End constructors #########################
208  
209 168 ▶sub log_info {
Subroutine log_info: called CC=4 SCAR=14.2
Pod undocumented
210 168 my $self = shift;
211 168 ▶ print @_ if ref($self) && ( $self->verbose || ! $self->quiet );
Branch: 1 branch
BranchTrueFalseTotal
if ref $self and $self->verbose || !$self->quiet 78 90 168
Condition66%4/6
ref $self and $self->verbose || !$self->quiet
!ll&&!rl&&r
09078
$self->verbose or not $self->quiet
l!l&&r!l&&!r
07890
MC/DC33%1/3
ref $self and $self->verbose || !$self->quiet
ref $self $self->verbose not $self->quiet
Truth table50%2/4
A and B or not(C)
A= ref $selfB= $self->verboseC= not $self->quiet
ABCresult
0XX0
1000
11X1
1011
212 }
213 4817 ▶sub log_verbose {
Subroutine log_verbose: called CC=3 SCAR=11.0
Pod undocumented
214 4817 my $self = shift;
215 4817 ▶ print @_ if ref($self) && $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self and $self->verbose 23 4794 4817
Condition100%3/3
ref $self and $self->verbose
!ll&&!rl&&r
3471132323
MC/DC100%2/2
ref $self and $self->verbose
ref $self $self->verbose
Truth table100%3/3
A and B
A= ref $selfB= $self->verbose
ABresult
0X0
100
111
216 }
217 796 ▶sub log_debug {
Subroutine log_debug: called CC=3 SCAR=13.1
Pod undocumented
218 796 my $self = shift;
219 796 ▶ print @_ if ref($self) && $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self and $self->debug 0 796 796
Condition33%1/3
ref $self and $self->debug
!ll&&!rl&&r
07960
MC/DC0%0/2
ref $self and $self->debug
ref $self $self->debug
Truth table33%1/3
A and B
A= ref $selfB= $self->debug
ABresult
0X0
100
111
220 }
221  
222 103 ▶sub log_warn {
Subroutine log_warn: called CC=3 SCAR=14.2
Pod undocumented
223 # Try to make our call stack invisible
224 103 shift;
225 103 ▶ if (@_ and $_[-1] !~ /\n$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and not $_[-1] =~ /\n$/) { } 0 103 103
Condition33%1/3
@_ and not $_[-1] =~ /\n$/
!ll&&!rl&&r
01030
MC/DC0%0/2
@_ and not $_[-1] =~ /\n$/
@_ not $_[-1] =~ /\n$/
Truth table33%1/3
A and not(B)
A= @_B= not $_[-1] =~ /\n$/
ABresult
0X0
100
111
226 0 my (undef, $file, $line) = caller();
227 0 warn @_, " at $file line $line.\n";
228 } else {
229 103 warn @_;
230 }
231 }
232  
233  
234 # install paths must be generated when requested to be sure all changes
235 # to config (from various sources) are included
236 365 ▶sub _default_install_paths {
Subroutine _default_install_paths: called CC=28 SCAR=42.0
237 365 my $self = shift;
238 365 my $c = $self->{config};
239 365 my $p = {};
240  
241 365 ▶ my @libstyle = $c->get('installstyle') ?
Branch: 1 branch
BranchTrueFalseTotal
$c->get('installstyle') ? : 365 0 365
242 File::Spec->splitdir($c->get('installstyle')) : qw(lib perl5);
243 365 my $arch = $c->get('archname');
244 365 my $version = $c->get('version');
245  
246 365 ▶ my $bindoc = $c->get('installman1dir') || undef;
Condition100%2/2
$c->get('installman1dir') || undef
l!l
187178
MC/DC100%1/1
$c->get('installman1dir') || undef
$c->get('installman1dir')
Truth table100%2/2
A
A= $c->get('installman1dir')
Aresult
11
00
247 365 ▶ my $libdoc = $c->get('installman3dir') || undef;
Condition100%2/2
$c->get('installman3dir') || undef
l!l
187178
MC/DC100%1/1
$c->get('installman3dir') || undef
$c->get('installman3dir')
Truth table100%2/2
A
A= $c->get('installman3dir')
Aresult
11
00
248  
249 365 ▶ my $binhtml = $c->get('installhtml1dir') || $c->get('installhtmldir') || undef;
Condition80%4/5
$c->get('installhtml1dir') || $c->get('installhtmldir') || undef
l!l
123242
$c->get("installhtml1dir") or $c->get("installhtmldir")
l!l&&r!l&&!r
1230242
MC/DC50%1/2
$c->get('installhtml1dir') || $c->get('installhtmldir') || undef
$c->get("installhtml1dir") $c->get("installhtmldir")
Truth table66%2/3
A or B
A= $c->get("installhtml1dir")B= $c->get("installhtmldir")
ABresult
1X1
011
000
250 365 ▶ my $libhtml = $c->get('installhtml3dir') || $c->get('installhtmldir') || undef;
Condition80%4/5
$c->get('installhtml3dir') || $c->get('installhtmldir') || undef
l!l
123242
$c->get("installhtml3dir") or $c->get("installhtmldir")
l!l&&r!l&&!r
1230242
MC/DC50%1/2
$c->get('installhtml3dir') || $c->get('installhtmldir') || undef
$c->get("installhtml3dir") $c->get("installhtmldir")
Truth table66%2/3
A or B
A= $c->get("installhtml3dir")B= $c->get("installhtmldir")
ABresult
1X1
011
000
251  
252 $p->{install_sets} =
253 {
254 365 ▶ core => {
Condition52%22/42
$c->get('installsitebin') || $c->get('installbin')
l!l&&r!l&&!r
36500
$c->get('installsitescript') || $c->get('installsitebin') || $c->get('installscript')
l!l&&r!l&&!r
36500
$c->get("installsitescript") or $c->get("installsitebin")
l!l&&r!l&&!r
36500
$c->get('installsiteman1dir') || $bindoc
l!l&&r!l&&!r
271094
$c->get('installsiteman3dir') || $libdoc
l!l&&r!l&&!r
271094
$c->get('installsitehtml1dir') || $binhtml
l!l&&r!l&&!r
1570208
$c->get('installsitehtml3dir') || $libhtml
l!l&&r!l&&!r
1570208
$c->get('installvendorbin') || $c->get('installbin')
l!l&&r!l&&!r
03650
$c->get('installvendorscript') || $c->get('installvendorbin') || $c->get('installscript')
l!l&&r!l&&!r
03650
$c->get("installvendorscript") or $c->get("installvendorbin")
l!l&&r!l&&!r
00365
$c->get('installvendorman1dir') || $bindoc
l!l&&r!l&&!r
0187178
$c->get('installvendorman3dir') || $libdoc
l!l&&r!l&&!r
0187178
$c->get('installvendorhtml1dir') || $binhtml
l!l&&r!l&&!r
0123242
$c->get('installvendorhtml3dir') || $libhtml
l!l&&r!l&&!r
0123242
MC/DC0%0/2
$c->get('installsitebin') || $c->get('installbin')
$c->get('installsitebin') $c->get('installbin')
MC/DC0%0/3
$c->get('installsitescript') || $c->get('installsitebin') || $c->get('installscript')
$c->get("installsitescript") $c->get("installsitebin") $c->get('installscript')
MC/DC50%1/2
$c->get('installsiteman1dir') || $bindoc
$c->get('installsiteman1dir') $bindoc
MC/DC50%1/2
$c->get('installsiteman3dir') || $libdoc
$c->get('installsiteman3dir') $libdoc
MC/DC50%1/2
$c->get('installsitehtml1dir') || $binhtml
$c->get('installsitehtml1dir') $binhtml
MC/DC50%1/2
$c->get('installsitehtml3dir') || $libhtml
$c->get('installsitehtml3dir') $libhtml
MC/DC0%0/2
$c->get('installvendorbin') || $c->get('installbin')
$c->get('installvendorbin') $c->get('installbin')
MC/DC0%0/3
$c->get('installvendorscript') || $c->get('installvendorbin') || $c->get('installscript')
$c->get("installvendorscript") $c->get("installvendorbin") $c->get('installscript')
MC/DC50%1/2
$c->get('installvendorman1dir') || $bindoc
$c->get('installvendorman1dir') $bindoc
MC/DC50%1/2
$c->get('installvendorman3dir') || $libdoc
$c->get('installvendorman3dir') $libdoc
MC/DC50%1/2
$c->get('installvendorhtml1dir') || $binhtml
$c->get('installvendorhtml1dir') $binhtml
MC/DC50%1/2
$c->get('installvendorhtml3dir') || $libhtml
$c->get('installvendorhtml3dir') $libhtml
Truth table33%1/3
A || B
A= $c->get('installsitebin')B= $c->get('installbin')
ABresult
1X1
011
000
Truth table25%1/4
A or B || C
A= $c->get("installsitescript")B= $c->get("installsitebin")C= $c->get('installscript')
ABCresult
1XX1
01X1
0011
0000
Truth table66%2/3
A || B
A= $c->get('installsiteman1dir')B= $bindoc
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $c->get('installsiteman3dir')B= $libdoc
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $c->get('installsitehtml1dir')B= $binhtml
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $c->get('installsitehtml3dir')B= $libhtml
ABresult
1X1
011
000
Truth table33%1/3
A || B
A= $c->get('installvendorbin')B= $c->get('installbin')
ABresult
1X1
011
000
Truth table25%1/4
A or B || C
A= $c->get("installvendorscript")B= $c->get("installvendorbin")C= $c->get('installscript')
ABCresult
1XX1
01X1
0011
0000
Truth table66%2/3
A || B
A= $c->get('installvendorman1dir')B= $bindoc
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $c->get('installvendorman3dir')B= $libdoc
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $c->get('installvendorhtml1dir')B= $binhtml
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $c->get('installvendorhtml3dir')B= $libhtml
ABresult
1X1
011
000
255 lib => $c->get('installprivlib'),
256 arch => $c->get('installarchlib'),
257 bin => $c->get('installbin'),
258 script => $c->get('installscript'),
259 bindoc => $bindoc,
260 libdoc => $libdoc,
261 binhtml => $binhtml,
262 libhtml => $libhtml,
263 },
264 site => {
265 lib => $c->get('installsitelib'),
266 arch => $c->get('installsitearch'),
267 bin => $c->get('installsitebin') || $c->get('installbin'),
268 script => $c->get('installsitescript') ||
269 $c->get('installsitebin') || $c->get('installscript'),
270 bindoc => $c->get('installsiteman1dir') || $bindoc,
271 libdoc => $c->get('installsiteman3dir') || $libdoc,
272 binhtml => $c->get('installsitehtml1dir') || $binhtml,
273 libhtml => $c->get('installsitehtml3dir') || $libhtml,
274 },
275 vendor => {
276 lib => $c->get('installvendorlib'),
277 arch => $c->get('installvendorarch'),
278 bin => $c->get('installvendorbin') || $c->get('installbin'),
279 script => $c->get('installvendorscript') ||
280 $c->get('installvendorbin') || $c->get('installscript'),
281 bindoc => $c->get('installvendorman1dir') || $bindoc,
282 libdoc => $c->get('installvendorman3dir') || $libdoc,
283 binhtml => $c->get('installvendorhtml1dir') || $binhtml,
284 libhtml => $c->get('installvendorhtml3dir') || $libhtml,
285 },
286 };
287  
288 $p->{original_prefix} =
289 {
290 365 ▶ core => $c->get('installprefixexp') || $c->get('installprefix') ||
Branch: 1 branch
BranchTrueFalseTotal
$c->get('usevendorprefix') ? : 0 365 365
Condition36%4/11
$c->get('installprefixexp') || $c->get('installprefix') || $c->get('prefixexp') || $c->get('prefix') || ''
l!l
3650
$c->get("installprefixexp") or $c->get("installprefix") or $c->get("prefixexp") or $c->get("prefix")
l!l&&r!l&&!r
36500
$c->get("installprefixexp") or $c->get("installprefix") or $c->get("prefixexp")
l!l&&r!l&&!r
36500
$c->get("installprefixexp") or $c->get("installprefix")
l!l&&r!l&&!r
36500
MC/DC0%0/4
$c->get('installprefixexp') || $c->get('installprefix') || $c->get('prefixexp') || $c->get('prefix') || ''
$c->get("installprefixexp") $c->get("installprefix") $c->get("prefixexp") $c->get("prefix")
Truth table20%1/5
A or B or C or D
A= $c->get("installprefixexp")B= $c->get("installprefix")C= $c->get("prefixexp")D= $c->get("prefix")
ABCDresult
1XXX1
01XX1
001X1
00011
00000
291 $c->get('prefixexp') || $c->get('prefix') || '',
292 site => $c->get('siteprefixexp'),
293 vendor => $c->get('usevendorprefix') ? $c->get('vendorprefixexp') : '',
294 };
295 365 ▶ $p->{original_prefix}{site} ||= $p->{original_prefix}{core};
Condition33%1/3
$p->{"original_prefix"}{"site"} ||= $p->{"original_prefix"}{"core"}
l!l&&r!l&&!r
36500
MC/DC0%0/2
$p->{"original_prefix"}{"site"} ||= $p->{"original_prefix"}{"core"}
$p->{"original_prefix"}{"site"} $p->{"original_prefix"}{"core"}
Truth table33%1/3
A ||= B
A= $p->{"original_prefix"}{"site"}B= $p->{"original_prefix"}{"core"}
ABresult
1X1
011
000
296  
297 # Note: you might be tempted to use $Config{installstyle} here
298 # instead of hard-coding lib/perl5, but that's been considered and
299 # (at least for now) rejected. `perldoc Config` has some wisdom
300 # about it.
301 $p->{install_base_relpaths} =
302 {
303 365 lib => ['lib', 'perl5'],
304 arch => ['lib', 'perl5', $arch],
305 bin => ['bin'],
306 script => ['bin'],
307 bindoc => ['man', 'man1'],
308 libdoc => ['man', 'man3'],
309 binhtml => ['html'],
310 libhtml => ['html'],
311 };
312  
313 $p->{prefix_relpaths} =
314 {
315 365 core => {
316 lib => [@libstyle],
317 arch => [@libstyle, $version, $arch],
318 bin => ['bin'],
319 script => ['bin'],
320 bindoc => ['man', 'man1'],
321 libdoc => ['man', 'man3'],
322 binhtml => ['html'],
323 libhtml => ['html'],
324 },
325 vendor => {
326 lib => [@libstyle],
327 arch => [@libstyle, $version, $arch],
328 bin => ['bin'],
329 script => ['bin'],
330 bindoc => ['man', 'man1'],
331 libdoc => ['man', 'man3'],
332 binhtml => ['html'],
333 libhtml => ['html'],
334 },
335 site => {
336 lib => [@libstyle, 'site_perl'],
337 arch => [@libstyle, 'site_perl', $version, $arch],
338 bin => ['bin'],
339 script => ['bin'],
340 bindoc => ['man', 'man1'],
341 libdoc => ['man', 'man3'],
342 binhtml => ['html'],
343 libhtml => ['html'],
344 },
345 };
346 365 return $p
347 }
348  
349 69 ▶sub _find_nested_builds {
Subroutine _find_nested_builds: called CC=8 SCAR=33.8
350 69 my $self = shift;
351 69 ▶ my $r = $self->recurse_into or return;
Branch: 1 branch
BranchTrueFalseTotal
my $r = $self->recurse_into or return 69 0 69
352  
353 69 my ($file, @r);
354 69 ▶ if (!ref($r) && $r eq 'auto') {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $r and $r eq "auto") 0 69 69
Condition33%1/3
not ref $r and $r eq "auto"
!ll&&!rl&&r
6900
MC/DC0%0/2
not ref $r and $r eq "auto"
not ref $r $r eq "auto"
Truth table33%1/3
not(A) and B
A= not ref $rB= $r eq "auto"
ABresult
0X0
100
111
355 0 local *DH;
356 0 ▶ opendir DH, $self->base_dir
Branch: 1 branch
BranchTrueFalseTotal
opendir DH, $self->base_dir or die q[Can't scan directory ] . $self->base_dir . " for nested builds: $!" 0 0 0
357 or die "Can't scan directory " . $self->base_dir . " for nested builds: $!";
358 0 ▶ while (defined($file = readdir DH)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($file = readdir DH)) 0 0 0
359 0 my $subdir = File::Spec->catdir( $self->base_dir, $file );
360 0 ▶ next unless -d $subdir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $subdir 0 0 0
361 0 ▶ push @r, $subdir if -e File::Spec->catfile( $subdir, 'Build.PL' );
Branch: 1 branch
BranchTrueFalseTotal
if -e "File::Spec"->catfile($subdir, "Build.PL") 0 0 0
362 }
363 }
364  
365 69 $self->recurse_into(\@r);
366 }
367  
368 581 ▶sub cwd {
Subroutine cwd: called CC=1 SCAR=0.0
Pod undocumented
369 581 return Cwd::cwd();
370 }
371  
372 7 ▶sub _quote_args {
Subroutine _quote_args: called CC=3 SCAR=11.0
373 # Returns a string that can become [part of] a command line with
374 # proper quoting so that the subprocess sees this same list of args.
375 7 my ($self, @args) = @_;
376  
377 7 my @quoted;
378  
379 7 for (@args) {
380 28 ▶ if ( /^[^\s*?!\$<>;\\|'"\[\]\{\}]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^[^\s*?!\$<>;\\|'"\[\]\{\}]+$/) { } 21 7 28
381 # Looks pretty safe
382 21 push @quoted, $_;
383 } else {
384 # XXX this will obviously have to improve - is there already a
385 # core module lying around that does proper quoting?
386 7 s/('+)/'"$1"'/g;
387 7 push @quoted, qq('$_');
388 }
389 }
390  
391 7 return join " ", @quoted;
392 }
393  
394 2541 ▶sub _backticks {
Subroutine _backticks: called CC=5 SCAR=16.6
395 2541 my ($self, @cmd) = @_;
396 2541 ▶ if ($self->have_forkpipe) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->have_forkpipe) { } 2541 0 2541
397 2541 local *FH;
398 2541 my $pid = open *FH, "-|";
399 2541 ▶ if ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid) { } 2296 245 2541
400 2296 ▶ return wantarray ? <FH> : join '', <FH>;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 198 2098 2296
401 } else {
402 245 ▶ die "Can't execute @cmd: $!\n" unless defined $pid;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pid 0 245 245
403 245 exec { $cmd[0] } @cmd;
404 }
405 } else {
406 0 my $cmd = $self->_quote_args(@cmd);
407 0 return `$cmd`;
408 }
409 }
410  
411 # Tells us whether the construct open($fh, '-|', @command) is
412 # supported. It would probably be better to dynamically sense this.
413 2541 ▶sub have_forkpipe { 1 }
Subroutine have_forkpipe: called CC=1 SCAR=0.0
Pod undocumented
414  
415 # Determine whether a given binary is the same as the perl
416 # (configuration) that started this process.
417 757 ▶sub _perl_is_same {
Subroutine _perl_is_same: called CC=2 SCAR=7.2
418 757 my ($self, $perl) = @_;
419  
420 757 my @cmd = ($perl);
421  
422 # When run from the perl core, @INC will include the directories
423 # where perl is yet to be installed. We need to reference the
424 # absolute path within the source distribution where it can find
425 # it's Config.pm This also prevents us from picking up a Config.pm
426 # from a different configuration that happens to be already
427 # installed in @INC.
428 757 ▶ if ($ENV{PERL_CORE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"PERL_CORE"}) 0 757 757
429 0 push @cmd, '-I' . File::Spec->catdir(File::Basename::dirname($perl), 'lib');
430 }
431  
432 757 push @cmd, qw(-MConfig=myconfig -e print -e myconfig);
433 757 return $self->_backticks(@cmd) eq Config->myconfig;
434 }
435  
436 # cache _discover_perl_interpreter() results
437 {
438 297 my $known_perl;
439 4289 ▶ sub find_perl_interpreter {
Subroutine find_perl_interpreter: called CC=2 SCAR=6.9
Pod undocumented
440 4289 my $self = shift;
441  
442 4289 ▶ return $known_perl if defined($known_perl);
Branch: 1 branch
BranchTrueFalseTotal
if defined $known_perl 3997 292 4289
443 292 return $known_perl = $self->_discover_perl_interpreter;
444 }
445 }
446  
447 # Returns the absolute path of the perl interpreter used to invoke
448 # this process. The path is derived from $^X or $Config{perlpath}. On
449 # some platforms $^X contains the complete absolute path of the
450 # interpreter, on other it may contain a relative path, or simply
451 # 'perl'. This can also vary depending on whether a path was supplied
452 # when perl was invoked. Additionally, the value in $^X may omit the
453 # executable extension on platforms that use one. It's a fatal error
454 # if the interpreter can't be found because it can result in undefined
455 # behavior by routines that depend on it (generating errors or
456 # invoking the wrong perl.)
457 297 ▶sub _discover_perl_interpreter {
Subroutine _discover_perl_interpreter: called CC=11 SCAR=29.3
458 292 my $proto = shift;
459 292 ▶ my $c = ref($proto) ? $proto->{config} : 'Module::Build::Config';
Branch: 1 branch
BranchTrueFalseTotal
ref $proto ? : 54 238 292
460  
461 292 my $perl = $^X;
462 292 my $perl_basename = File::Basename::basename($perl);
463  
464 292 my @potential_perls;
465  
466 # Try 1, Check $^X for absolute path
467 292 ▶ push( @potential_perls, $perl )
Branch: 1 branch
BranchTrueFalseTotal
if "File::Spec"->file_name_is_absolute($perl) 292 0 292
468 if File::Spec->file_name_is_absolute($perl);
469  
470 # Try 2, Check $^X for a valid relative path
471 292 my $abs_perl = File::Spec->rel2abs($perl);
472 292 push( @potential_perls, $abs_perl );
473  
474 # Try 3, Last ditch effort: These two option use hackery to try to locate
475 # a suitable perl. The hack varies depending on whether we are running
476 # from an installed perl or an uninstalled perl in the perl source dist.
477 292 ▶ if ($ENV{PERL_CORE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'PERL_CORE'}) { } 0 292 292
478  
479 # Try 3.A, If we are in a perl source tree, running an uninstalled
480 # perl, we can keep moving up the directory tree until we find our
481 # binary. We wouldn't do this under any other circumstances.
482  
483 # CBuilder is also in the core, so it should be available here
484 0 require ExtUtils::CBuilder;
485 0 my $perl_src = Cwd::realpath( ExtUtils::CBuilder->perl_src );
486 0 ▶ if ( defined($perl_src) && length($perl_src) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $perl_src and length $perl_src) 0 0 0
Condition0%0/3
defined $perl_src and length $perl_src
!ll&&!rl&&r
000
MC/DC0%0/2
defined $perl_src and length $perl_src
defined $perl_src length $perl_src
Truth table0%0/3
A and B
A= defined $perl_srcB= length $perl_src
ABresult
0X0
100
111
487 0 my $uninstperl =
488 File::Spec->rel2abs(File::Spec->catfile( $perl_src, $perl_basename ));
489 0 push( @potential_perls, $uninstperl );
490 }
491  
492 } else {
493  
494 # Try 3.B, First look in $Config{perlpath}, then search the user's
495 # PATH. We do not want to do either if we are running from an
496 # uninstalled perl in a perl source tree.
497  
498 292 push( @potential_perls, $c->get('perlpath') );
499  
500 292 push( @potential_perls,
501 map File::Spec->catfile($_, $perl_basename), File::Spec->path() );
502 }
503  
504 # Now that we've enumerated the potential perls, it's time to test
505 # them to see if any of them match our configuration, returning the
506 # absolute path of the first successful match.
507 292 my $exe = $c->get('exe_ext');
508 292 foreach my $thisperl ( @potential_perls ) {
509  
510 292 ▶ if (defined $exe) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $exe) 292 0 292
511 292 ▶ $thisperl .= $exe unless $thisperl =~ m/$exe$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $thisperl =~ /$exe$/i 0 292 292
512 }
513  
514 292 ▶ if ( -f $thisperl && $proto->_perl_is_same($thisperl) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $thisperl and $proto->_perl_is_same($thisperl)) 245 0 245
Condition66%2/3
-f $thisperl and $proto->_perl_is_same($thisperl)
!ll&&!rl&&r
047245
MC/DC0%0/2
-f $thisperl and $proto->_perl_is_same($thisperl)
-f $thisperl $proto->_perl_is_same($thisperl)
Truth table33%1/3
A and B
A= -f $thisperlB= $proto->_perl_is_same($thisperl)
ABresult
0X0
100
111
515 245 return $thisperl;
516 }
517 }
518  
519 # We've tried all alternatives, and didn't find a perl that matches
520 # our configuration. Throw an exception, and list alternatives we tried.
521 0 my @paths = map File::Basename::dirname($_), @potential_perls;
522 0 die "Can't locate the perl binary used to run this script " .
523 "in (@paths)\n";
524 }
525  
526 # Adapted from IPC::Cmd::can_run()
527 7 ▶sub find_command {
Subroutine find_command: called CC=4 SCAR=20.1
Pod undocumented
528 7 my ($self, $command) = @_;
529  
530 7 ▶ if( File::Spec->file_name_is_absolute($command) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('File::Spec'->file_name_is_absolute($command)) { } 7 0 7
531 7 return $self->_maybe_command($command);
532  
533 } else {
534 0 for my $dir ( File::Spec->path ) {
535 0 my $abs = File::Spec->catfile($dir, $command);
536 0 ▶ return $abs if $abs = $self->_maybe_command($abs);
Branch: 1 branch
BranchTrueFalseTotal
if $abs = $self->_maybe_command($abs) 0 0 0
537 }
538 }
539 }
540  
541 # Copied from ExtUtils::MM_Unix::maybe_command
542 7 ▶sub _maybe_command {
Subroutine _maybe_command: called CC=3 SCAR=12.5
543 7 my($self,$file) = @_;
544 7 ▶ return $file if -x $file && ! -d $file;
Branch: 1 branch
BranchTrueFalseTotal
if -x $file and not -d $file 0 7 7
Condition33%1/3
-x $file and not -d $file
!ll&&!rl&&r
700
MC/DC0%0/2
-x $file and not -d $file
-x $file not -d $file
Truth table33%1/3
A and not(B)
A= -x $fileB= not -d $file
ABresult
0X0
100
111
545 7 return;
546 }
547  
548 0 ▶sub _is_interactive {
Subroutine _is_interactive: not called CC=4 SCAR=30.0
549 0 ▶ return -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
Condition0%0/9
-t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT))
!ll&&!rl&&r
000
-t STDOUT or not -f STDOUT || -c STDOUT
l!l&&r!l&&!r
000
-f STDOUT || -c STDOUT
l!l&&r!l&&!r
000
MC/DC0%0/4
-t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT))
-t STDIN -t STDOUT -f STDOUT -c STDOUT
Truth table0%0/5
A && B or not(C || D)
A= -t STDINB= -t STDOUTC= -f STDOUTD= -c STDOUT
ABCDresult
0XXX0
101X0
10010
11XX1
10001
550 }
551  
552 # NOTE this is a blocking operation if(-t STDIN)
553 8 ▶sub _is_unattended {
Subroutine _is_unattended: called CC=3 SCAR=12.5
554 8 my $self = shift;
555 return $ENV{PERL_MM_USE_DEFAULT} ||
556 8 ▶ ( !$self->_is_interactive && eof STDIN );
Condition50%3/6
$ENV{'PERL_MM_USE_DEFAULT'} || !$self->_is_interactive && eof STDIN
l!l&&r!l&&!r
206
not $self->_is_interactive and eof STDIN
!ll&&!rl&&r
600
MC/DC33%1/3
$ENV{'PERL_MM_USE_DEFAULT'} || !$self->_is_interactive && eof STDIN
$ENV{'PERL_MM_USE_DEFAULT'} not $self->_is_interactive eof STDIN
Truth table50%2/4
A || not(B) and C
A= $ENV{'PERL_MM_USE_DEFAULT'}B= not $self->_is_interactiveC= eof STDIN
ABCresult
1XX1
0111
00X0
0100
557 }
558  
559 0 ▶sub _readline {
Subroutine _readline: not called CC=3 SCAR=24.8
560 0 my $self = shift;
561 0 ▶ return undef if $self->_is_unattended;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_unattended 0 0 0
562  
563 0 my $answer = <STDIN>;
564 0 ▶ chomp $answer if defined $answer;
Branch: 1 branch
BranchTrueFalseTotal
if defined $answer 0 0 0
565 0 return $answer;
566 }
567  
568 9 ▶sub prompt {
Subroutine prompt: called CC=10 SCAR=23.0
Pod undocumented
569 9 my $self = shift;
570 9 ▶ my $mess = shift
Branch: 1 branch
BranchTrueFalseTotal
my $mess = shift() or die "prompt() called without a prompt message" 8 1 9
571 or die "prompt() called without a prompt message";
572  
573 # use a list to distinguish a default of undef() from no default
574 8 my @def;
575 8 ▶ @def = (shift) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 3 5 8
576 # use dispdef for output
577 8 ▶ my @dispdef = scalar(@def) ?
Branch: 2 branches
BranchTrueFalseTotal
scalar @def ? : 3 5 8
defined $def[0] ? : 2 1 3
578 ('[', (defined($def[0]) ? $def[0] . ' ' : ''), ']') :
579 (' ', '');
580  
581 8 local $|=1;
582 8 print "$mess ", @dispdef;
583  
584 8 ▶ if ( $self->_is_unattended && !@def ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_unattended and not @def) 2 6 8
Condition66%2/3
$self->_is_unattended and not @def
!ll&&!rl&&r
602
MC/DC50%1/2
$self->_is_unattended and not @def
$self->_is_unattended not @def
Truth table66%2/3
A and not(B)
A= $self->_is_unattendedB= not @def
ABresult
0X0
100
111
585 2 die <<EOF;
586 ERROR: This build seems to be unattended, but there is no default value
587 for this question. Aborting.
588 EOF
589 }
590  
591 6 my $ans = $self->_readline();
592  
593 6 ▶ if ( !defined($ans) # Ctrl-D or unattended
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ans and length $ans) 4 2 6
Condition66%2/3
defined $ans and length $ans
!ll&&!rl&&r
042
MC/DC50%1/2
defined $ans and length $ans
defined $ans length $ans
Truth table66%2/3
A and B
A= defined $ansB= length $ans
ABresult
0X0
100
111
594 or !length($ans) ) { # User hit return
595 4 print "$dispdef[1]\n";
596 4 ▶ $ans = scalar(@def) ? $def[0] : '';
Branch: 1 branch
BranchTrueFalseTotal
scalar @def ? : 3 1 4
597 }
598  
599 6 return $ans;
600 }
601  
602 5 ▶sub y_n {
Subroutine y_n: called CC=6 SCAR=19.1
Pod undocumented
603 5 my $self = shift;
604 5 my ($mess, $def) = @_;
605  
606 5 ▶ die "y_n() called without a prompt message" unless $mess;
Branch: 1 branch
BranchTrueFalseTotal
unless $mess 1 4 5
607 4 ▶ die "Invalid default value: y_n() default must be 'y' or 'n'"
Branch: 1 branch
BranchTrueFalseTotal
if $def and not $def =~ /^[yn]/i 1 3 4
Condition100%3/3
$def and not $def =~ /^[yn]/i
!ll&&!rl&&r
211
MC/DC100%2/2
$def and not $def =~ /^[yn]/i
$def not $def =~ /^[yn]/i
Truth table100%3/3
A and not(B)
A= $defB= not $def =~ /^[yn]/i
ABresult
0X0
100
111
608 if $def && $def !~ /^[yn]/i;
609  
610 3 my $answer;
611 3 while (1) { # XXX Infinite or a large number followed by an exception ?
612 3 $answer = $self->prompt(@_);
613 2 ▶ return 1 if $answer =~ /^y/i;
Branch: 1 branch
BranchTrueFalseTotal
if $answer =~ /^y/i 2 0 2
614 0 ▶ return 0 if $answer =~ /^n/i;
Branch: 1 branch
BranchTrueFalseTotal
if $answer =~ /^n/i 0 0 0
615 0 local $|=1;
616 0 print "Please answer 'y' or 'n'.\n";
617 }
618 }
619  
620 0 ▶sub current_action { shift->{action} }
Subroutine current_action: not called CC=1 SCAR=6.9
Pod undocumented
621 112 ▶sub invoked_action { shift->{invoked_action} }
Subroutine invoked_action: called CC=1 SCAR=0.0
Pod undocumented
622  
623 31 ▶sub notes { shift()->{phash}{notes}->access(@_) }
Subroutine notes: called CC=1 SCAR=0.0
Pod undocumented
624 2 ▶sub config_data { shift()->{phash}{config_data}->access(@_) }
Subroutine config_data: called CC=1 SCAR=0.0
Pod undocumented
625 4 ▶sub runtime_params { shift->{phash}{runtime_params}->read( @_ ? shift : () ) } # Read-only
Subroutine runtime_params: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 4 4
626 82 ▶sub auto_features { shift()->{phash}{auto_features}->access(@_) }
Subroutine auto_features: called CC=1 SCAR=0.0
Pod undocumented
627  
628 2 ▶sub features {
Subroutine features: called CC=16 SCAR=37.0
Pod undocumented
629 2 my $self = shift;
630 2 my $ph = $self->{phash};
631  
632 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 0 2
633 2 my $key = shift;
634 2 ▶ if ($ph->{features}->exists($key)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ph->{"features"}->exists($key)) 0 2 2
635 0 return $ph->{features}->access($key, @_);
636 }
637  
638 2 ▶ if (my $info = $ph->{auto_features}->access($key)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $info = $ph->{"auto_features"}->access($key)) 1 1 2
639 1 my $disabled;
640 1 for my $type ( @{$self->prereq_action_types} ) {
641 5 ▶ next if $type eq 'description' || $type eq 'recommends' || ! exists $info->{$type};
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "description" or $type eq "recommends" or not exists $info->{$type} 4 1 5
Condition83%5/6
$type eq "description" or $type eq "recommends" or not exists $info->{$type}
l!l&&r!l&&!r
131
$type eq "description" or $type eq "recommends"
l!l&&r!l&&!r
014
MC/DC66%2/3
$type eq "description" or $type eq "recommends" or not exists $info->{$type}
$type eq "description" $type eq "recommends" not exists $info->{$type}
Truth table75%3/4
A or B or not(C)
A= $type eq "description"B= $type eq "recommends"C= not exists $info->{$type}
ABCresult
1XX1
01X1
0011
0000
642 1 my $prereqs = $info->{$type};
643 1 for my $modname ( sort keys %$prereqs ) {
644 1 my $spec = $prereqs->{$modname};
645 1 my $status = $self->check_installed_status($modname, $spec);
646 0 ▶ if ((!$status->{ok}) xor ($type =~ /conflicts$/)) { return 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (not $status->{"ok"} xor $type =~ /conflicts$/) 0 1 1
Condition25%1/4
not $status->{"ok"} xor $type =~ /conflicts$/
l&&rl&&!r!l&&r!l&&!r
0001
MC/DC0%0/2
not $status->{"ok"} xor $type =~ /conflicts$/
not $status->{"ok"} $type =~ /conflicts$/
Truth table25%1/4
not(A) xor B
A= not $status->{"ok"}B= $type =~ /conflicts$/
ABresult
110
101
011
000
647 0 ▶ if ( ! eval "require $modname; 1" ) { return 0; }
Branch: 1 branch
BranchTrueFalseTotal
unless (eval "require $modname; 1") 0 1 1
648 }
649 }
650 1 return 1;
651 }
652  
653 1 return $ph->{features}->access($key, @_);
654 }
655  
656 # No args - get the auto_features & overlay the regular features
657 0 my %features;
658 0 my %auto_features = $ph->{auto_features}->access();
659 0 ▶ while (my ($name, $info) = each %auto_features) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %auto_features) 0 0 0
660 0 my $failures = $self->prereq_failures($info);
661 0 ▶ my $disabled = grep( /^(?:\w+_)?(?:requires|conflicts)$/,
Branch: 1 branch
BranchTrueFalseTotal
grep(/^(?:\w+_)?(?:requires|conflicts)$/, keys %$failures) ? : 0 0 0
662 keys %$failures ) ? 1 : 0;
663 0 ▶ $features{$name} = $disabled ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$disabled ? : 0 0 0
664 }
665 0 %features = (%features, $ph->{features}->access());
666  
667 0 ▶ return wantarray ? %features : \%features;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
668 }
669 297 ▶BEGIN { *feature = \&features } # Alias
Subroutine BEGIN: called CC=1 SCAR=0.0
670  
671 56 ▶sub _mb_feature {
Subroutine _mb_feature: called CC=3 SCAR=12.0
672 56 my $self = shift;
673  
674 56 ▶ if (($self->module_name || '') eq 'Module::Build') {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->module_name || '') eq 'Module::Build') { } 0 56 56
Condition50%1/2
$self->module_name || ''
l!l
560
MC/DC0%0/1
$self->module_name || ''
$self->module_name
Truth table50%1/2
A
A= $self->module_name
Aresult
11
00
675 # We're building Module::Build itself, so ...::ConfigData isn't
676 # valid, but $self->features() should be.
677 0 return $self->feature(@_);
678 } else {
679 56 require Module::Build::ConfigData;
680 56 return Module::Build::ConfigData->feature(@_);
681 }
682 }
683  
684 0 ▶sub _warn_mb_feature_deps {
Subroutine _warn_mb_feature_deps: not called CC=1 SCAR=6.9
685 0 my $self = shift;
686 0 my $name = shift;
687 0 $self->log_warn(
688 "The '$name' feature is not available. Please install missing\n" .
689 "feature dependencies and try again.\n".
690 $self->_feature_deps_msg($name) . "\n"
691 );
692 }
693  
694 2 ▶sub add_build_element {
Subroutine add_build_element: called CC=2 SCAR=6.9
Pod undocumented
695 2 my ($self, $elem) = @_;
696 2 my $elems = $self->build_elements;
697 2 ▶ push @$elems, $elem unless grep { $_ eq $elem } @$elems;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $elem;} @$elems 1 1 2
698 }
699  
700 62 ▶sub ACTION_config_data {
Subroutine ACTION_config_data: called CC=4 SCAR=13.9
Pod undocumented
701 62 my $self = shift;
702 62 ▶ return unless $self->has_config_data;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_config_data 60 2 62
703  
704 2 ▶ my $module_name = $self->module_name
Branch: 1 branch
BranchTrueFalseTotal
my $module_name = $self->module_name or die "The config_data feature requires that 'module_name' be set" 2 0 2
705 or die "The config_data feature requires that 'module_name' be set";
706 2 my $notes_name = $module_name . '::ConfigData'; # TODO: Customize name ???
707 2 my $notes_pm = File::Spec->catfile($self->blib, 'lib', split /::/, "$notes_name.pm");
708  
709 2 ▶ return if $self->up_to_date(['Build.PL',
Branch: 1 branch
BranchTrueFalseTotal
if $self->up_to_date(["Build.PL", $self->config_file("config_data"), $self->config_file("features")], $notes_pm) 1 1 2
710 $self->config_file('config_data'),
711 $self->config_file('features')
712 ], $notes_pm);
713  
714 1 $self->log_verbose("Writing config notes to $notes_pm\n");
715 1 File::Path::mkpath(File::Basename::dirname($notes_pm));
716  
717 Module::Build::Notes->write_config_data
718 (
719 file => $notes_pm,
720 module => $module_name,
721 config_module => $notes_name,
722 config_data => scalar $self->config_data,
723 1 feature => scalar $self->{phash}{features}->access(),
724 auto_features => scalar $self->auto_features,
725 );
726 }
727  
728 ########################################################################
729 { # enclosing these lexicals -- TODO
730 297 my %valid_properties = ( __PACKAGE__, {} );
731 297 my %additive_properties;
732  
733 31509 ▶ sub _mb_classes {
Subroutine _mb_classes: called CC=2 SCAR=7.1
734 31509 ▶ my $class = ref($_[0]) || $_[0];
Condition66%2/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
4935265740
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table66%2/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
735 31509 return ($class, $class->mb_parents);
736 }
737  
738 28360 ▶ sub valid_property {
Subroutine valid_property: called CC=1 SCAR=0.0
Pod undocumented
739 28360 my ($class, $prop) = @_;
740 28360 return grep exists( $valid_properties{$_}{$prop} ), $class->_mb_classes;
741 }
742  
743 0 ▶ sub valid_properties {
Subroutine valid_properties: not called CC=1 SCAR=6.9
Pod undocumented
744 0 return keys %{ shift->valid_properties_defaults() };
745 }
746  
747 563 ▶ sub valid_properties_defaults {
Subroutine valid_properties_defaults: called CC=2 SCAR=6.9
Pod undocumented
748 563 my %out;
749 563 for my $class (reverse shift->_mb_classes) {
750 1728 @out{ keys %{ $valid_properties{$class} } } = map {
751 50135 $_->()
752 1728 } values %{ $valid_properties{$class} };
753 }
754 563 return \%out;
755 }
756  
757 564 ▶ sub array_properties {
Subroutine array_properties: called CC=2 SCAR=6.9
Pod undocumented
758 564 ▶ map { exists $additive_properties{$_}->{ARRAY} ? @{$additive_properties{$_}->{ARRAY}} : () } shift->_mb_classes;
Branch: 1 branch
BranchTrueFalseTotal
exists $additive_properties{$_}{'ARRAY'} ? : 565 1167 1732
759 }
760  
761 2022 ▶ sub hash_properties {
Subroutine hash_properties: called CC=2 SCAR=6.9
Pod undocumented
762 2022 ▶ map { exists $additive_properties{$_}->{HASH} ? @{$additive_properties{$_}->{HASH}} : () } shift->_mb_classes;
Branch: 1 branch
BranchTrueFalseTotal
exists $additive_properties{$_}{'HASH'} ? : 2044 4155 6199
763 }
764  
765 26458 ▶ sub add_property {
Subroutine add_property: called CC=9 SCAR=22.0
Pod undocumented
766 26458 my ($class, $property) = (shift, shift);
767 26458 ▶ die "Property '$property' already exists"
Branch: 1 branch
BranchTrueFalseTotal
if $class->valid_property($property) 1 26457 26458
768 if $class->valid_property($property);
769 26457 ▶ my %p = @_ == 1 ? ( default => shift ) : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 12779 13678 26457
770  
771 26457 my $type = ref $p{default};
772 $valid_properties{$class}{$property} =
773 $type eq 'CODE' ? $p{default} :
774 8451 ▶ $type eq 'HASH' ? sub { return { %{ $p{default} } } } :
Subroutine __ANON__: called CC=1 SCAR=0.0
775 3941 ▶ $type eq 'ARRAY'? sub { return [ @{ $p{default} } ] } :
Subroutine __ANON__: called CC=1 SCAR=0.0
776 26457 ▶ sub { return $p{default} } ;
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 3 branches
BranchTrueFalseTotal
$type eq 'CODE' ? : 6 26451 26457
$type eq 'HASH' ? : 4460 21991 26451
$type eq 'ARRAY' ? : 2080 19911 21991
777  
778 26457 ▶ push @{$additive_properties{$class}->{$type}}, $property
Branch: 1 branch
BranchTrueFalseTotal
if $type 6546 19911 26457
779 if $type;
780  
781 26457 ▶ unless ($class->can($property)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->can($property)) 20517 5940 26457
782 # TODO probably should put these in a util package
783 20517 ▶ my $sub = $type eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'HASH' ? : 2975 17542 20517
784 ? _make_hash_accessor($property, \%p)
785 : _make_accessor($property, \%p);
786 297 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
787 20517 *{"$class\::$property"} = $sub;
788 }
789  
790 26457 return $class;
791 }
792  
793 4 ▶ sub property_error {
Subroutine property_error: called CC=1 SCAR=0.0
Pod undocumented
794 4 my $self = shift;
795 4 die 'ERROR: ', @_;
796 }
797  
798 563 ▶ sub _set_defaults {
Subroutine _set_defaults: called CC=9 SCAR=24.0
799 563 my $self = shift;
800  
801 # Set the build class.
802 563 ▶ $self->{properties}{build_class} ||= ref $self;
Condition66%2/3
$self->{"properties"}{"build_class"} ||= ref $self
l!l&&r!l&&!r
45590
MC/DC0%0/2
$self->{"properties"}{"build_class"} ||= ref $self
$self->{"properties"}{"build_class"} ref $self
Truth table66%2/3
A ||= B
A= $self->{"properties"}{"build_class"}B= ref $self
ABresult
1X1
011
000
803  
804 # If there was no orig_dir, set to the same as base_dir
805 563 ▶ $self->{properties}{orig_dir} ||= $self->{properties}{base_dir};
Condition33%1/3
$self->{"properties"}{"orig_dir"} ||= $self->{"properties"}{"base_dir"}
l!l&&r!l&&!r
05630
MC/DC0%0/2
$self->{"properties"}{"orig_dir"} ||= $self->{"properties"}{"base_dir"}
$self->{"properties"}{"orig_dir"} $self->{"properties"}{"base_dir"}
Truth table33%1/3
A ||= B
A= $self->{"properties"}{"orig_dir"}B= $self->{"properties"}{"base_dir"}
ABresult
1X1
011
000
806  
807 563 my $defaults = $self->valid_properties_defaults;
808  
809 563 foreach my $prop (keys %$defaults) {
810 $self->{properties}{$prop} = $defaults->{$prop}
811 50135 ▶ unless exists $self->{properties}{$prop};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"properties"}{$prop} 47705 2430 50135
812 }
813  
814 # Copy defaults for arrays any arrays.
815 563 for my $prop ($self->array_properties) {
816 0 $self->{properties}{$prop} = [@{$defaults->{$prop}}]
817 3941 ▶ unless exists $self->{properties}{$prop};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"properties"}{$prop} 0 3941 3941
818 }
819 # Copy defaults for arrays any hashes.
820 563 for my $prop ($self->hash_properties) {
821 0 $self->{properties}{$prop} = {%{$defaults->{$prop}}}
822 8451 ▶ unless exists $self->{properties}{$prop};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"properties"}{$prop} 0 8451 8451
823 }
824 }
825  
826 } # end enclosure
827 ########################################################################
828 297 ▶sub _make_hash_accessor {
Subroutine _make_hash_accessor: called CC=2 SCAR=7.0
829 2975 my ($property, $p) = @_;
830 2975 ▶ my $check = $p->{check} || sub { 1 };
Subroutine __ANON__: called CC=1 SCAR=0.1
Condition66%2/3
$p->{'check'} || sub { 1; }
l!l&&r!l&&!r
329720
MC/DC0%0/2
$p->{'check'} || sub { 1; }
$p->{'check'} sub { 1; }
Truth table66%2/3
A || B
A= $p->{'check'}B= sub { 1; }
ABresult
1X1
011
000
831  
832 1262 ▶ return sub {
Subroutine __ANON__: called CC=12 SCAR=25.6
833 1262 my $self = shift;
834  
835 # This is only here to deprecate the historic accident of calling
836 # properties as class methods - I suspect it only happens in our
837 # test suite.
838 1262 ▶ unless(ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 0 1262 1262
839 0 carp("\n$property not a class method (@_)");
840 0 return;
841 }
842  
843 1262 my $x = $self->{properties};
844 1262 ▶ return $x->{$property} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1254 8 1262
845  
846 8 my $prop = $x->{$property};
847 8 ▶ if ( defined $_[0] && !ref $_[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0] and not ref $_[0]) { } 4 4 8
Condition100%3/3
defined $_[0] and not ref $_[0]
!ll&&!rl&&r
134
MC/DC100%2/2
defined $_[0] and not ref $_[0]
defined $_[0] not ref $_[0]
Truth table100%3/3
A and not(B)
A= defined $_[0]B= not ref $_[0]
ABresult
0X0
100
111
848 4 ▶ if ( @_ == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1) { } 1 3 4
elsif (@_ % 2 == 0) { } 3 0 3
849 1 ▶ return exists $prop->{$_[0]} ? $prop->{$_[0]} : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $$prop{$_[0]} ? : 1 0 1
850 } elsif ( @_ % 2 == 0 ) {
851 3 my %new = (%{ $prop }, @_);
852 3 local $_ = \%new;
853 3 ▶ $x->{$property} = \%new if $check->($self);
Branch: 1 branch
BranchTrueFalseTotal
if &$check($self) 3 0 3
854 3 return $x->{$property};
855 } else {
856 0 die "Unexpected arguments for property '$property'\n";
857 }
858 } else {
859 4 ▶ die "Unexpected arguments for property '$property'\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] and ref $_[0] ne "HASH" 1 3 4
Condition100%3/3
defined $_[0] and ref $_[0] ne "HASH"
!ll&&!rl&&r
121
MC/DC100%2/2
defined $_[0] and ref $_[0] ne "HASH"
defined $_[0] ref $_[0] ne "HASH"
Truth table100%3/3
A and B
A= defined $_[0]B= ref $_[0] ne "HASH"
ABresult
0X0
100
111
860 if defined $_[0] && ref $_[0] ne 'HASH';
861 3 local $_ = $_[0];
862 3 ▶ $x->{$property} = shift if $check->($self);
Branch: 1 branch
BranchTrueFalseTotal
if &$check($self) 2 0 2
863 }
864 2975 };
865 }
866 ########################################################################
867 17542 ▶sub _make_accessor {
Subroutine _make_accessor: called CC=2 SCAR=7.2
868 17542 my ($property, $p) = @_;
869 17542 ▶ my $check = $p->{check} || sub { 1 };
Subroutine __ANON__: called CC=1 SCAR=0.1
Condition66%2/3
$p->{'check'} || sub { 1; }
l!l&&r!l&&!r
300172420
MC/DC0%0/2
$p->{'check'} || sub { 1; }
$p->{'check'} sub { 1; }
Truth table66%2/3
A || B
A= $p->{'check'}B= sub { 1; }
ABresult
1X1
011
000
870  
871 12096 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=14.6
872 12096 my $self = shift;
873  
874 # This is only here to deprecate the historic accident of calling
875 # properties as class methods - I suspect it only happens in our
876 # test suite.
877 12096 ▶ unless(ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 0 12096 12096
878 0 carp("\n$property not a class method (@_)");
879 0 return;
880 }
881  
882 12096 my $x = $self->{properties};
883 12096 ▶ return $x->{$property} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 11909 187 12096
884 187 local $_ = $_[0];
885 187 ▶ $x->{$property} = shift if $check->($self);
Branch: 1 branch
BranchTrueFalseTotal
if &$check($self) 184 0 184
886 184 return $x->{$property};
887 17542 };
888 }
889 ########################################################################
890  
891 # Add the default properties.
892 297 __PACKAGE__->add_property(auto_configure_requires => 1);
893 297 __PACKAGE__->add_property(blib => 'blib');
894 297 __PACKAGE__->add_property(build_class => 'Module::Build');
895 297 __PACKAGE__->add_property(build_elements => [qw(PL support pm xs share_dir pod script)]);
896 297 __PACKAGE__->add_property(build_script => 'Build');
897 297 __PACKAGE__->add_property(build_bat => 0);
898 297 __PACKAGE__->add_property(bundle_inc => []);
899 297 __PACKAGE__->add_property(bundle_inc_preload => []);
900 297 __PACKAGE__->add_property(config_dir => '_build');
901 297 __PACKAGE__->add_property(dynamic_config => 1);
902 297 __PACKAGE__->add_property(include_dirs => []);
903 297 __PACKAGE__->add_property(license => 'unknown');
904 297 __PACKAGE__->add_property(metafile => 'META.yml');
905 297 __PACKAGE__->add_property(mymetafile => 'MYMETA.yml');
906 297 __PACKAGE__->add_property(metafile2 => 'META.json');
907 297 __PACKAGE__->add_property(mymetafile2 => 'MYMETA.json');
908 297 __PACKAGE__->add_property(recurse_into => []);
909 297 __PACKAGE__->add_property(use_rcfile => 1);
910 297 __PACKAGE__->add_property(create_packlist => 1);
911 297 __PACKAGE__->add_property(allow_mb_mismatch => 0);
912 297 __PACKAGE__->add_property(config => undef);
913 297 __PACKAGE__->add_property(test_file_exts => ['.t']);
914 297 __PACKAGE__->add_property(use_tap_harness => 0);
915 297 __PACKAGE__->add_property(cpan_client => 'cpan');
916 297 __PACKAGE__->add_property(tap_harness_args => {});
917 297 __PACKAGE__->add_property(pureperl_only => 0);
918 297 __PACKAGE__->add_property(allow_pureperl => 0);
919 __PACKAGE__->add_property(
920 'installdirs',
921 default => 'site',
922 7 ▶ check => sub {
Subroutine __ANON__: called CC=4 SCAR=16.1
923 7 ▶ return 1 if /^(core|site|vendor)$/;
Branch: 1 branch
BranchTrueFalseTotal
if /^(core|site|vendor)$/ 5 2 7
924 return shift->property_error(
925 2 ▶ $_ eq 'perl'
Branch: 1 branch
BranchTrueFalseTotal
$_ eq 'perl' ? : 1 1 2
926 ? 'Perhaps you meant installdirs to be "core" rather than "perl"?'
927 : 'installdirs must be one of "core", "site", or "vendor"'
928 );
929 0 ▶ return shift->property_error("Perhaps you meant 'core'?") if $_ eq 'perl';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "perl" 0 0 0
930 0 return 0;
931 },
932 297 );
933  
934 {
935 297 __PACKAGE__->add_property(html_css => '');
936 }
937  
938 {
939 297 my @prereq_action_types = qw(requires build_requires test_requires conflicts recommends);
940 297 foreach my $type (@prereq_action_types) {
941 1485 __PACKAGE__->add_property($type => {});
942 }
943 297 __PACKAGE__->add_property(prereq_action_types => \@prereq_action_types);
944 }
945  
946 297 __PACKAGE__->add_property($_ => {}) for qw(
947 get_options
948 install_base_relpaths
949 install_path
950 install_sets
951 meta_add
952 meta_merge
953 original_prefix
954 prefix_relpaths
955 configure_requires
956 );
957  
958 297 __PACKAGE__->add_property($_) for qw(
959 PL_files
960 autosplit
961 base_dir
962 bindoc_dirs
963 c_source
964 cover
965 create_license
966 create_makefile_pl
967 create_readme
968 debugger
969 destdir
970 dist_abstract
971 dist_author
972 dist_name
973 dist_suffix
974 dist_version
975 dist_version_from
976 extra_compiler_flags
977 extra_linker_flags
978 has_config_data
979 install_base
980 libdoc_dirs
981 magic_number
982 mb_version
983 module_name
984 needs_compiler
985 orig_dir
986 perl
987 pm_files
988 pod_files
989 pollute
990 prefix
991 program_name
992 quiet
993 recursive_test_files
994 release_status
995 script_files
996 scripts
997 share_dir
998 sign
999 test_files
1000 verbose
1001 debug
1002 xs_files
1003 extra_manify_args
1004 );
1005  
1006 7886 ▶sub config {
Subroutine config: called CC=4 SCAR=13.9
Pod undocumented
1007 7886 my $self = shift;
1008 7886 ▶ my $c = ref($self) ? $self->{config} : 'Module::Build::Config';
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 970 6916 7886
1009 7886 ▶ return $c->all_config unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 30 7856 7886
1010  
1011 7856 my $key = shift;
1012 7856 ▶ return $c->get($key) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 7853 3 7856
1013  
1014 3 my $val = shift;
1015 3 return $c->set($key => $val);
1016 }
1017  
1018 31513 ▶sub mb_parents {
Subroutine mb_parents: called CC=7 SCAR=19.5
Pod undocumented
1019 # Code borrowed from Class::ISA.
1020 31513 my @in_stack = (shift);
1021 31513 my %seen = ($in_stack[0] => 1);
1022  
1023 31513 my ($current, @out);
1024 31513 ▶ while (@in_stack) {
Branch: 1 branch
BranchTrueFalseTotal
if (@in_stack) 42049 31513 73562
1025 42049 ▶ next unless defined($current = shift @in_stack)
Branch: 1 branch
BranchTrueFalseTotal
unless defined($current = shift @in_stack) and $current->isa("Module::Build::Base") 1 42048 42049
Condition66%2/3
defined($current = shift @in_stack) and $current->isa("Module::Build::Base")
!ll&&!rl&&r
0142048
MC/DC50%1/2
defined($current = shift @in_stack) and $current->isa("Module::Build::Base")
defined($current = shift @in_stack) $current->isa("Module::Build::Base")
Truth table66%2/3
A and B
A= defined($current = shift @in_stack)B= $current->isa("Module::Build::Base")
ABresult
0X0
100
111
1026 && $current->isa('Module::Build::Base');
1027 42048 push @out, $current;
1028 42048 ▶ next if $current eq 'Module::Build::Base';
Branch: 1 branch
BranchTrueFalseTotal
if $current eq "Module::Build::Base" 31513 10535 42048
1029 297 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1030 unshift @in_stack,
1031 map {
1032 10537 my $c = $_; # copy, to avoid being destructive
1033 10537 ▶ substr($c,0,2) = "main::" if substr($c,0,2) eq '::';
Branch: 1 branch
BranchTrueFalseTotal
if substr($c, 0, 2) eq "::" 0 10537 10537
1034 # Canonize the :: -> main::, ::foo -> main::foo thing.
1035 # Should I ever canonize the Foo'Bar = Foo::Bar thing?
1036 10537 ▶ $seen{$c}++ ? () : $c;
Branch: 1 branch
BranchTrueFalseTotal
$seen{$c}++ ? : 1 10536 10537
1037 10535 } @{"$current\::ISA"};
1038  
1039 # I.e., if this class has any parents (at least, ones I've never seen
1040 # before), push them, in order, onto the stack of classes I need to
1041 # explore.
1042 }
1043 31513 shift @out;
1044 31513 return @out;
1045 }
1046  
1047 19 ▶sub extra_linker_flags { shift->_list_accessor('extra_linker_flags', @_) }
Subroutine extra_linker_flags: called CC=1 SCAR=0.0
Pod undocumented
1048 23 ▶sub extra_compiler_flags { shift->_list_accessor('extra_compiler_flags', @_) }
Subroutine extra_compiler_flags: called CC=1 SCAR=0.0
Pod undocumented
1049  
1050 42 ▶sub _list_accessor {
Subroutine _list_accessor: called CC=4 SCAR=14.6
1051 42 (my $self, local $_) = (shift, shift);
1052 42 my $p = $self->{properties};
1053 42 ▶ $p->{$_} = [@_] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 42 42
1054 42 ▶ $p->{$_} = [] unless exists $p->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $p->{$_} 0 42 42
1055 42 ▶ return ref($p->{$_}) ? $p->{$_} : [$p->{$_}];
Branch: 1 branch
BranchTrueFalseTotal
ref $p->{$_} ? : 42 0 42
1056 }
1057  
1058 # XXX Problem - if Module::Build is loaded from a different directory,
1059 # it'll look for (and perhaps destroy/create) a _build directory.
1060 22 ▶sub subclass {
Subroutine subclass: called CC=9 SCAR=22.2
Pod undocumented
1061 22 my ($pack, %opts) = @_;
1062  
1063 22 my $build_dir = '_build'; # XXX The _build directory is ostensibly settable by the user. Shouldn't hard-code here.
1064 22 ▶ $pack->delete_filetree($build_dir) if -e $build_dir;
Branch: 1 branch
BranchTrueFalseTotal
if -e $build_dir 7 15 22
1065  
1066 die "Must provide 'code' or 'class' option to subclass()\n"
1067 22 ▶ unless $opts{code} or $opts{class};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"code"} or $opts{"class"} 0 22 22
Condition66%2/3
$opts{"code"} or $opts{"class"}
l!l&&r!l&&!r
1660
MC/DC0%0/2
$opts{"code"} or $opts{"class"}
$opts{"code"} $opts{"class"}
Truth table66%2/3
A or B
A= $opts{"code"}B= $opts{"class"}
ABresult
1X1
011
000
1068  
1069 22 ▶ $opts{code} ||= '';
Condition100%2/2
$opts{"code"} ||= ""
l!l
166
MC/DC100%1/1
$opts{"code"} ||= ""
$opts{"code"}
Truth table100%2/2
A
A= $opts{"code"}
Aresult
11
00
1070 22 ▶ $opts{class} ||= 'MyModuleBuilder';
Condition100%2/2
$opts{"class"} ||= "MyModuleBuilder"
l!l
715
MC/DC100%1/1
$opts{"class"} ||= "MyModuleBuilder"
$opts{"class"}
Truth table100%2/2
A
A= $opts{"class"}
Aresult
11
00
1071  
1072 22 my $filename = File::Spec->catfile($build_dir, 'lib', split '::', $opts{class}) . '.pm';
1073 22 my $filedir = File::Basename::dirname($filename);
1074 22 $pack->log_verbose("Creating custom builder $filename in $filedir\n");
1075  
1076 22 File::Path::mkpath($filedir);
1077 22 ▶ die "Can't create directory $filedir: $!" unless -d $filedir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $filedir 0 22 22
1078  
1079 22 ▶ open(my $fh, '>', $filename) or die "Can't create $filename: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $filename or die "Can't create ${filename}: $!" 22 0 22
1080 22 print $fh <<EOF;
1081 package $opts{class};
1082 use $pack;
1083 our \@ISA = qw($pack);
1084 $opts{code}
1085 1;
1086 EOF
1087 22 close $fh;
1088  
1089 22 unshift @INC, File::Spec->catdir(File::Spec->rel2abs($build_dir), 'lib');
1090 22 eval "use $opts{class}";
1091 22 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 22 22
1092  
1093 22 return $opts{class};
1094 }
1095  
1096 5 ▶sub _guess_module_name {
Subroutine _guess_module_name: called CC=6 SCAR=21.2
1097 5 my $self = shift;
1098 5 my $p = $self->{properties};
1099 5 ▶ return if $p->{module_name};
Branch: 1 branch
BranchTrueFalseTotal
if $p->{"module_name"} 0 5 5
1100 5 ▶ if ( $p->{dist_version_from} && -e $p->{dist_version_from} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{'dist_version_from'} and -e $p->{'dist_version_from'}) { } 0 5 5
Condition33%1/3
$p->{"dist_version_from"} and -e $p->{"dist_version_from"}
!ll&&!rl&&r
500
MC/DC0%0/2
$p->{"dist_version_from"} and -e $p->{"dist_version_from"}
$p->{"dist_version_from"} -e $p->{"dist_version_from"}
Truth table33%1/3
A and B
A= $p->{"dist_version_from"}B= -e $p->{"dist_version_from"}
ABresult
0X0
100
111
1101 0 my $mi = Module::Metadata->new_from_file($self->dist_version_from);
1102 0 $p->{module_name} = $mi->name;
1103 }
1104 else {
1105 5 my $mod_path = my $mod_name = $p->{dist_name};
1106 5 $mod_name =~ s{-}{::}g;
1107 5 $mod_path =~ s{-}{/}g;
1108 5 $mod_path .= ".pm";
1109 5 ▶ if ( -e $mod_path || -e "lib/$mod_path" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $mod_path or -e "lib/$mod_path") { } 5 0 5
Condition33%1/3
-e $mod_path or -e "lib/$mod_path"
l!l&&r!l&&!r
050
MC/DC0%0/2
-e $mod_path or -e "lib/$mod_path"
-e $mod_path -e "lib/$mod_path"
Truth table33%1/3
A or B
A= -e $mod_pathB= -e "lib/$mod_path"
ABresult
1X1
011
000
1110 5 $p->{module_name} = $mod_name;
1111 }
1112 else {
1113 0 $self->log_warn( << 'END_WARN' );
1114 No 'module_name' was provided and it could not be inferred
1115 from other properties. This will prevent a packlist from
1116 being written for this file. Please set either 'module_name'
1117 or 'dist_version_from' in Build.PL.
1118 END_WARN
1119 }
1120 }
1121 }
1122  
1123 225 ▶sub dist_name {
Subroutine dist_name: called CC=3 SCAR=11.0
Pod undocumented
1124 225 my $self = shift;
1125 225 my $p = $self->{properties};
1126 225 my $me = 'dist_name';
1127 225 ▶ return $p->{$me} if defined $p->{$me};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->{$me} 162 63 225
1128  
1129 63 ▶ die "Can't determine distribution name, must supply either 'dist_name' or 'module_name' parameter"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->module_name 0 63 63
1130 unless $self->module_name;
1131  
1132 63 ($p->{$me} = $self->module_name) =~ s/::/-/g;
1133  
1134 63 return $p->{$me};
1135 }
1136  
1137 141 ▶sub release_status {
Subroutine release_status: called CC=6 SCAR=19.7
Pod undocumented
1138 141 my ($self) = @_;
1139 141 my $me = 'release_status';
1140 141 my $p = $self->{properties};
1141  
1142 141 ▶ if ( ! defined $p->{$me} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $p->{$me}) 69 72 141
1143 69 ▶ $p->{$me} = $self->_is_dev_version ? 'testing' : 'stable';
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_dev_version ? : 0 69 69
1144 }
1145  
1146 141 ▶ unless ( $p->{$me} =~ qr/\A(?:stable|testing|unstable)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($p->{$me} =~ qr/\A(?:stable|testing|unstable)\z/) 0 141 141
1147 0 die "Illegal value '$p->{$me}' for $me\n";
1148 }
1149  
1150 141 ▶ if ( $p->{$me} eq 'stable' && $self->_is_dev_version ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{$me} eq "stable" and $self->_is_dev_version) 0 141 141
Condition66%2/3
$p->{$me} eq "stable" and $self->_is_dev_version
!ll&&!rl&&r
201210
MC/DC0%0/2
$p->{$me} eq "stable" and $self->_is_dev_version
$p->{$me} eq "stable" $self->_is_dev_version
Truth table66%2/3
A and B
A= $p->{$me} eq "stable"B= $self->_is_dev_version
ABresult
0X0
100
111
1151 0 my $version = $self->dist_version;
1152 0 die "Illegal value '$p->{$me}' with version '$version'\n";
1153 }
1154 141 return $p->{$me};
1155 }
1156  
1157 40 ▶sub dist_suffix {
Subroutine dist_suffix: called CC=4 SCAR=13.9
Pod undocumented
1158 40 my ($self) = @_;
1159 40 my $p = $self->{properties};
1160 40 my $me = 'dist_suffix';
1161  
1162 40 ▶ return $p->{$me} if defined $p->{$me};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->{$me} 18 22 40
1163  
1164 22 ▶ if ( $self->release_status eq 'stable' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->release_status eq 'stable') { } 13 9 22
1165 13 $p->{$me} = "";
1166 }
1167 else {
1168 # non-stable release but non-dev version number needs '-TRIAL' appended
1169 9 ▶ $p->{$me} = $self->_is_dev_version ? "" : "TRIAL" ;
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_dev_version ? : 0 9 9
1170 }
1171  
1172 22 return $p->{$me};
1173 }
1174  
1175 170 ▶sub dist_version_from {
Subroutine dist_version_from: called CC=4 SCAR=14.0
Pod undocumented
1176 170 my ($self) = @_;
1177 170 my $p = $self->{properties};
1178 170 my $me = 'dist_version_from';
1179  
1180 170 ▶ if ($self->module_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->module_name) 170 0 170
1181 170 ▶ $p->{$me} ||=
Condition100%2/2
$p->{$me} ||= join("/", "lib", split(/::/, $self->module_name, 0)) . '.pm'
l!l
10169
MC/DC100%1/1
$p->{$me} ||= join("/", "lib", split(/::/, $self->module_name, 0)) . '.pm'
$p->{$me}
Truth table100%2/2
A
A= $p->{$me}
Aresult
11
00
1182 join( '/', 'lib', split(/::/, $self->module_name) ) . '.pm';
1183 }
1184 170 ▶ return $p->{$me} || undef;
Condition50%1/2
$p->{$me} || undef
l!l
1700
MC/DC0%0/1
$p->{$me} || undef
$p->{$me}
Truth table50%1/2
A
A= $p->{$me}
Aresult
11
00
1185 }
1186  
1187 374 ▶sub dist_version {
Subroutine dist_version: called CC=6 SCAR=18.6
Pod undocumented
1188 374 my ($self) = @_;
1189 374 my $p = $self->{properties};
1190 374 my $me = 'dist_version';
1191  
1192 374 ▶ return $p->{$me} if defined $p->{$me};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->{$me} 311 63 374
1193  
1194 63 ▶ if ( my $dist_version_from = $self->dist_version_from ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dist_version_from = $self->dist_version_from) 63 0 63
1195 63 my $version_from = File::Spec->catfile( split( qr{/}, $dist_version_from ) );
1196 63 ▶ my $pm_info = Module::Metadata->new_from_file( $version_from )
Branch: 1 branch
BranchTrueFalseTotal
my $pm_info = "Module::Metadata"->new_from_file($version_from) or die "Can't find file $version_from to determine version" 63 0 63
1197 or die "Can't find file $version_from to determine version";
1198 #$p->{$me} is undef here
1199 63 $p->{$me} = $self->normalize_version( $pm_info->version() );
1200 63 ▶ unless (defined $p->{$me}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $p->{$me}) 0 63 63
1201 0 die "Can't determine distribution version from $version_from";
1202 }
1203 }
1204  
1205 die ("Can't determine distribution version, must supply either 'dist_version',\n".
1206 "'dist_version_from', or 'module_name' parameter")
1207 63 ▶ unless defined $p->{$me};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p->{$me} 0 63 63
1208  
1209 63 return $p->{$me};
1210 }
1211  
1212 199 ▶sub _is_dev_version {
Subroutine _is_dev_version: called CC=2 SCAR=6.9
1213 199 my ($self) = @_;
1214 199 my $dist_version = $self->dist_version;
1215 199 my $version_obj = eval { version->new( $dist_version ) };
1216 # assume it's normal if the version string is fatal -- in this case
1217 # the author might be doing something weird so should play along and
1218 # assume they'll specify all necessary behavior
1219 199 ▶ return $@ ? 0 : $version_obj->is_alpha;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 2 197 199
1220 }
1221  
1222 67 ▶sub dist_author { shift->_pod_parse('author') }
Subroutine dist_author: called CC=1 SCAR=0.0
Pod undocumented
1223 57 ▶sub dist_abstract { shift->_pod_parse('abstract') }
Subroutine dist_abstract: called CC=1 SCAR=0.0
Pod undocumented
1224  
1225 124 ▶sub _pod_parse {
Subroutine _pod_parse: called CC=4 SCAR=13.9
1226 124 my ($self, $part) = @_;
1227 124 my $p = $self->{properties};
1228 124 my $member = "dist_$part";
1229 124 ▶ return $p->{$member} if defined $p->{$member};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->{$member} 67 57 124
1230  
1231 57 ▶ my $docfile = $self->_main_docfile
Branch: 1 branch
BranchTrueFalseTotal
my $docfile = $self->_main_docfile or return 57 0 57
1232 or return;
1233 57 ▶ open(my $fh, '<', $docfile)
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $docfile or return 57 0 57
1234 or return;
1235  
1236 57 require Module::Build::PodParser;
1237 57 my $parser = Module::Build::PodParser->new(fh => $fh);
1238 57 my $method = "get_$part";
1239 57 return $p->{$member} = $parser->$method();
1240 }
1241  
1242 1 ▶sub version_from_file { # Method provided for backwards compatibility
Subroutine version_from_file: called CC=1 SCAR=0.0
Pod undocumented
1243 1 return Module::Metadata->new_from_file($_[1])->version();
1244 }
1245  
1246 0 ▶sub find_module_by_name { # Method provided for backwards compatibility
Subroutine find_module_by_name: not called CC=1 SCAR=6.9
Pod undocumented
1247 0 return Module::Metadata->find_module_by_name(@_[1,2]);
1248 }
1249  
1250 {
1251 # $unlink_list_for_pid{$$} = [ ... ]
1252 297 my %unlink_list_for_pid;
1253  
1254 0 ▶ sub _unlink_on_exit {
Subroutine _unlink_on_exit: not called CC=3 SCAR=24.8
1255 0 my $self = shift;
1256 0 for my $f ( @_ ) {
1257 0 ▶ push @{$unlink_list_for_pid{$$}}, $f if -f $f;
Branch: 1 branch
BranchTrueFalseTotal
if -f $f 0 0 0
1258 }
1259 0 return 1;
1260 }
1261  
1262 70 ▶ END {
Subroutine END: called CC=4 SCAR=15.6
1263 297 ▶ for my $f ( map glob($_), @{ $unlink_list_for_pid{$$} || [] } ) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Condition50%1/2
$unlink_list_for_pid{$$} || []
l!l
052
MC/DC0%0/1
$unlink_list_for_pid{$$} || []
$unlink_list_for_pid{$$}
Truth table50%1/2
A
A= $unlink_list_for_pid{$$}
Aresult
11
00
1264 18 ▶ next unless -e $f;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $f 0 0 0
1265 0 File::Path::rmtree($f, 0, 0);
1266 }
1267 }
1268 }
1269  
1270 297 ▶sub add_to_cleanup {
Subroutine add_to_cleanup: called CC=1 SCAR=0.0
Pod undocumented
1271 192 my $self = shift;
1272 192 my %files = map {$self->localize_file_path($_), 1} @_;
1273 192 $self->{phash}{cleanup}->write(\%files);
1274 }
1275  
1276 51 ▶sub cleanup {
Subroutine cleanup: called CC=2 SCAR=6.9
Pod undocumented
1277 51 my $self = shift;
1278 51 my $all = $self->{phash}{cleanup}->read;
1279 51 ▶ return wantarray ? sort keys %$all : keys %$all;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 50 1 51
1280 }
1281  
1282 497 ▶sub config_file {
Subroutine config_file: called CC=2 SCAR=7.1
Pod undocumented
1283 497 my $self = shift;
1284 497 ▶ return unless -d $self->config_dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $self->config_dir 0 497 497
1285 497 return File::Spec->catfile($self->config_dir, @_);
1286 }
1287  
1288 469 ▶sub read_config {
Subroutine read_config: called CC=4 SCAR=14.1
Pod undocumented
1289 469 my ($self) = @_;
1290  
1291 469 ▶ my $file = $self->config_file('build_params')
Branch: 1 branch
BranchTrueFalseTotal
my $file = $self->config_file("build_params") or die q[Can't find 'build_params' in ] . $self->config_dir 469 0 469
1292 or die "Can't find 'build_params' in " . $self->config_dir;
1293 469 ▶ open(my $fh, '<', $file) or die "Can't read '$file': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or die "Can't read '${file}': $!" 469 0 469
1294 469 my $ref = eval do {local $/; <$fh>};
1295 469 ▶ die if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 469 469
1296 469 close $fh;
1297 469 my $c;
1298 469 ($self->{args}, $c, $self->{properties}) = @$ref;
1299 469 $self->{config} = Module::Build::Config->new(values => $c);
1300 }
1301  
1302 62 ▶sub has_config_data {
Subroutine has_config_data: called CC=1 SCAR=0.0
Pod undocumented
1303 62 my $self = shift;
1304 62 return scalar grep $self->{phash}{$_}->has_data(), qw(config_data features auto_features);
1305 }
1306  
1307 18 ▶sub _write_data {
Subroutine _write_data: called CC=3 SCAR=11.0
1308 18 my ($self, $filename, $data) = @_;
1309  
1310 18 my $file = $self->config_file($filename);
1311 18 ▶ open(my $fh, '>', $file) or die "Can't create '$file': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $file or die "Can't create '${file}': $!" 18 0 18
1312 18 ▶ unless (ref($data)) { # e.g. magicnum
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $data) 6 12 18
1313 6 print $fh $data;
1314 6 return;
1315 }
1316  
1317 12 print {$fh} Module::Build::Dumper->_data_dump($data);
1318 12 close $fh;
1319 }
1320  
1321 6 ▶sub write_config {
Subroutine write_config: called CC=3 SCAR=11.0
Pod undocumented
1322 6 my ($self) = @_;
1323  
1324 6 File::Path::mkpath($self->{properties}{config_dir});
1325 6 ▶ -d $self->{properties}{config_dir} or die "Can't mkdir $self->{properties}{config_dir}: $!";
Branch: 1 branch
BranchTrueFalseTotal
-d $self->{"properties"}{"config_dir"} or die qq[Can't mkdir $self->{"properties"}{"config_dir"}: $!] 6 0 6
1326  
1327 6 my @items = @{ $self->prereq_action_types };
1328 6 $self->_write_data('prereqs', { map { $_, $self->$_() } @items });
1329 6 $self->_write_data('build_params', [$self->{args}, $self->{config}->values_set, $self->{properties}]);
1330  
1331 # Set a new magic number and write it to a file
1332 6 $self->_write_data('magicnum', $self->magic_number(int rand 1_000_000));
1333  
1334 6 $self->{phash}{$_}->write() foreach qw(notes cleanup features auto_features config_data runtime_params);
1335 }
1336  
1337 {
1338 # packfile map -- keys are guts of regular expressions; If they match,
1339 # values are module names corresponding to the packlist
1340 297 my %packlist_map = (
1341 '^File::Spec' => 'Cwd',
1342 '^Devel::AssertOS' => 'Devel::CheckOS',
1343 );
1344  
1345 0 ▶ sub _find_packlist {
Subroutine _find_packlist: not called CC=5 SCAR=34.0
1346 0 my ($self, $inst, $mod) = @_;
1347 0 my $lookup = $mod;
1348 0 my $packlist = eval { $inst->packlist($lookup) };
1349 0 ▶ if ( ! $packlist ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($packlist) 0 0 0
1350 # try from packlist_map
1351 0 ▶ while ( my ($re, $new_mod) = each %packlist_map ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %packlist_map) 0 0 0
1352 0 ▶ if ( $mod =~ qr/$re/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mod =~ qr/$re/) 0 0 0
1353 0 $lookup = $new_mod;
1354 0 $packlist = eval { $inst->packlist($lookup) };
1355 0 last;
1356 }
1357 }
1358 }
1359 0 ▶ return $packlist ? $lookup : undef;
Branch: 1 branch
BranchTrueFalseTotal
$packlist ? : 0 0 0
1360 }
1361  
1362 69 ▶ sub set_bundle_inc {
Subroutine set_bundle_inc: called CC=6 SCAR=32.9
Pod undocumented
1363 69 my $self = shift;
1364  
1365 69 my $bundle_inc = $self->{properties}{bundle_inc};
1366 69 my $bundle_inc_preload = $self->{properties}{bundle_inc_preload};
1367 # We're in author mode if inc::latest is loaded, but not from cwd
1368 69 ▶ return unless inc::latest->can('loaded_modules');
Branch: 1 branch
BranchTrueFalseTotal
unless "inc::latest"->can("loaded_modules") 69 0 69
1369 0 require ExtUtils::Installed;
1370 # ExtUtils::Installed is buggy about finding additions to default @INC
1371 0 my $inst = eval { ExtUtils::Installed->new(extra_libs => [@INC]) };
1372 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1373 0 $self->log_warn( << "EUI_ERROR" );
1374 Bundling in inc/ is disabled because ExtUtils::Installed could not
1375 create a list of your installed modules. Here is the error:
1376 $@
1377 EUI_ERROR
1378 0 return;
1379 }
1380 0 my @bundle_list = map { [ $_, 0 ] } inc::latest->loaded_modules;
1381  
1382 # XXX TODO: Need to get ordering of prerequisites correct so they are
1383 # are loaded in the right order. Use an actual tree?!
1384  
1385 0 ▶ while( @bundle_list ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@bundle_list) 0 0 0
1386 0 my ($mod, $prereq) = @{ shift @bundle_list };
1387  
1388 # XXX TODO: Append prereqs to list
1389 # skip if core or already in bundle or preload lists
1390 # push @bundle_list, [$_, 1] for prereqs()
1391  
1392 # Locate packlist for bundling
1393 0 my $lookup = $self->_find_packlist($inst,$mod);
1394 0 ▶ if ( ! $lookup ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $lookup) { } 0 0 0
1395 # XXX Really needs a more helpful error message here
1396 0 die << "NO_PACKLIST";
1397 Could not find a packlist for '$mod'. If it's a core module, try
1398 force installing it from CPAN.
1399 NO_PACKLIST
1400 }
1401 else {
1402 0 ▶ push @{ $prereq ? $bundle_inc_preload : $bundle_inc }, $lookup;
Branch: 1 branch
BranchTrueFalseTotal
$prereq ? : 0 0 0
1403 }
1404 }
1405 } # sub check_bundling
1406 }
1407  
1408 297 ▶sub check_autofeatures {
Subroutine check_autofeatures: called CC=4 SCAR=26.0
Pod undocumented
1409 80 my ($self) = @_;
1410 80 my $features = $self->auto_features;
1411  
1412 80 ▶ return 1 unless %$features;
Branch: 1 branch
BranchTrueFalseTotal
unless %$features 80 0 80
1413  
1414 # TODO refactor into ::Util
1415 0 ▶ my $longest = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1416 0 ▶ my @str = @_ or croak("no strings given");
Branch: 1 branch
BranchTrueFalseTotal
my(@str) = or croak("no strings given") 0 0 0
1417  
1418 0 my @len = map({length($_)} @str);
1419 0 my $max = 0;
1420 0 my $longest;
1421 0 for my $i (0..$#len) {
1422 0 ▶ ($max, $longest) = ($len[$i], $str[$i]) if($len[$i] > $max);
Branch: 1 branch
BranchTrueFalseTotal
if $len[$i] > $max 0 0 0
1423 }
1424 0 return($longest);
1425 0 };
1426 0 my $max_name_len = length($longest->(keys %$features));
1427  
1428 0 my ($num_disabled, $log_text) = (0, "\nChecking optional features...\n");
1429 0 for my $name ( sort keys %$features ) {
1430 0 $log_text .= $self->_feature_deps_msg($name, $max_name_len);
1431 }
1432  
1433 0 $num_disabled = () = $log_text =~ /disabled/g;
1434  
1435 # warn user if features disabled
1436 0 ▶ if ( $num_disabled ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num_disabled) { } 0 0 0
1437 0 $self->log_warn( $log_text );
1438 0 return 0;
1439 }
1440 else {
1441 0 $self->log_verbose( $log_text );
1442 0 return 1;
1443 }
1444 }
1445  
1446 0 ▶sub _feature_deps_msg {
Subroutine _feature_deps_msg: not called CC=12 SCAR=50.5
1447 0 my ($self, $name, $max_name_len) = @_;
1448 0 ▶ $max_name_len ||= length $name;
Condition0%0/3
$max_name_len ||= length $name
l!l&&r!l&&!r
000
MC/DC0%0/2
$max_name_len ||= length $name
$max_name_len length $name
Truth table0%0/3
A ||= B
A= $max_name_lenB= length $name
ABresult
1X1
011
000
1449 0 my $features = $self->auto_features;
1450 0 my $info = $features->{$name};
1451 0 my $feature_text = "$name" . '.' x ($max_name_len - length($name) + 4);
1452  
1453 0 my ($log_text, $disabled) = ('','');
1454 0 ▶ if ( my $failures = $self->prereq_failures($info) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $failures = $self->prereq_failures($info)) { } 0 0 0
1455 0 ▶ $disabled = grep( /^(?:\w+_)?(?:requires|conflicts)$/,
Branch: 1 branch
BranchTrueFalseTotal
grep(/^(?:\w+_)?(?:requires|conflicts)$/, keys %$failures) ? : 0 0 0
1456 keys %$failures ) ? 1 : 0;
1457 0 ▶ $feature_text .= $disabled ? "disabled\n" : "enabled\n";
Branch: 1 branch
BranchTrueFalseTotal
$disabled ? : 0 0 0
1458  
1459 0 for my $type ( @{ $self->prereq_action_types } ) {
1460 0 ▶ next unless exists $failures->{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $failures->{$type} 0 0 0
1461 0 $feature_text .= " $type:\n";
1462 0 my $prereqs = $failures->{$type};
1463 0 for my $module ( sort keys %$prereqs ) {
1464 0 my $status = $prereqs->{$module};
1465 0 ▶ my $required =
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /^(?:\w+_)?(?:requires|conflicts)$/ ? : 0 0 0
1466 ($type =~ /^(?:\w+_)?(?:requires|conflicts)$/) ? 1 : 0;
1467 0 ▶ my $prefix = ($required) ? '!' : '*';
Branch: 1 branch
BranchTrueFalseTotal
$required ? : 0 0 0
1468 0 $feature_text .= " $prefix $status->{message}\n";
1469 }
1470 }
1471 } else {
1472 0 $feature_text .= "enabled\n";
1473 }
1474 0 ▶ $log_text .= $feature_text if $disabled || $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $disabled or $self->verbose 0 0 0
Condition0%0/3
$disabled or $self->verbose
l!l&&r!l&&!r
000
MC/DC0%0/2
$disabled or $self->verbose
$disabled $self->verbose
Truth table0%0/3
A or B
A= $disabledB= $self->verbose
ABresult
1X1
011
000
1475 0 return $log_text;
1476 }
1477  
1478 # Automatically detect configure_requires prereqs
1479 11 ▶sub auto_config_requires {
Subroutine auto_config_requires: called CC=7 SCAR=21.3
Pod undocumented
1480 11 my ($self) = @_;
1481 11 my $p = $self->{properties};
1482  
1483 # add current Module::Build to configure_requires if there
1484 # isn't one already specified (but not ourself, so we're not circular)
1485 11 ▶ if ( $self->dist_name ne 'Module-Build'
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dist_name ne "Module-Build" and $self->auto_configure_requires and not exists $p->{"configure_requires"}{"Module::Build"}) 7 4 11
Condition83%5/6
$self->dist_name ne "Module-Build" and $self->auto_configure_requires and not exists $p->{"configure_requires"}{"Module::Build"}
!ll&&!rl&&r
317
$self->dist_name ne "Module-Build" and $self->auto_configure_requires
!ll&&!rl&&r
038
MC/DC66%2/3
$self->dist_name ne "Module-Build" and $self->auto_configure_requires and not exists $p->{"configure_requires"}{"Module::Build"}
$self->dist_name ne "Module-Build" $self->auto_configure_requires not exists $p->{"configure_requires"}{"Module::Build"}
Truth table75%3/4
A and B and not(C)
A= $self->dist_name ne "Module-Build"B= $self->auto_configure_requiresC= not exists $p->{"configure_requires"}{"Module::Build"}
ABCresult
0XX0
10X0
1100
1111
1486 && $self->auto_configure_requires
1487 && ! exists $p->{configure_requires}{'Module::Build'}
1488 ) {
1489 7 (my $ver = $VERSION) =~ s/^(\d+\.\d\d).*$/$1/; # last major release only
1490 7 $self->log_warn(<<EOM);
1491 Module::Build was not found in configure_requires! Adding it now
1492 automatically as: configure_requires => { 'Module::Build' => $ver }
1493 EOM
1494 7 $self->_add_prereq('configure_requires', 'Module::Build', $ver);
1495 }
1496  
1497 # if we're in author mode, add inc::latest modules to
1498 # configure_requires if not already set. If we're not in author mode
1499 # then configure_requires will have been satisfied, or we'll just
1500 # live with what we've bundled
1501 11 ▶ if ( inc::latest->can('loaded_module') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("inc::latest"->can("loaded_module")) 0 11 11
1502 0 for my $mod ( inc::latest->loaded_modules ) {
1503 0 ▶ next if exists $p->{configure_requires}{$mod};
Branch: 1 branch
BranchTrueFalseTotal
if exists $p->{"configure_requires"}{$mod} 0 0 0
1504 0 $self->_add_prereq('configure_requires', $mod, $mod->VERSION);
1505 }
1506 }
1507  
1508 11 return;
1509 }
1510  
1511 # Automatically detect and add prerequisites based on configuration
1512 80 ▶sub auto_require {
Subroutine auto_require: called CC=10 SCAR=33.4
Pod undocumented
1513 80 my ($self) = @_;
1514 80 my $p = $self->{properties};
1515  
1516 # If needs_compiler is not explicitly set, automatically set it
1517 # If set, we need ExtUtils::CBuilder (and a compiler)
1518 80 my $xs_files = $self->find_xs_files;
1519 80 ▶ if ( ! defined $p->{needs_compiler} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $p->{"needs_compiler"}) 80 0 80
1520 80 ▶ if ( $self->pureperl_only && $self->allow_pureperl ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->pureperl_only and $self->allow_pureperl) { } 0 80 80
Condition33%1/3
$self->pureperl_only and $self->allow_pureperl
!ll&&!rl&&r
8000
MC/DC0%0/2
$self->pureperl_only and $self->allow_pureperl
$self->pureperl_only $self->allow_pureperl
Truth table33%1/3
A and B
A= $self->pureperl_onlyB= $self->allow_pureperl
ABresult
0X0
100
111
1521 0 $self->needs_compiler( 0 );
1522 } else {
1523 $self->needs_compiler( keys %$xs_files ||
1524 ( defined $self->c_source &&
1525 0 ▶ ( ref($self->c_source) ne 'ARRAY' || @{$self->c_source} )
Condition22%2/9
keys %$xs_files || defined $self->c_source && (ref $self->c_source ne 'ARRAY' || @{$self->c_source;})
l!l&&r!l&&!r
0080
defined $self->c_source and ref $self->c_source ne "ARRAY" || @{$self->c_source;}
!ll&&!rl&&r
8000
ref $self->c_source ne "ARRAY" or @{$self->c_source;}
l!l&&r!l&&!r
000
MC/DC0%0/4
keys %$xs_files || defined $self->c_source && (ref $self->c_source ne 'ARRAY' || @{$self->c_source;})
keys %$xs_files defined $self->c_source ref $self->c_source ne "ARRAY" @{$self->c_source;}
Truth table20%1/5
A || B and C or D
A= keys %$xs_filesB= defined $self->c_sourceC= ref $self->c_source ne "ARRAY"D= @{$self->c_source;}
ABCDresult
1XXX1
011X1
01011
00XX0
01000
1526 )
1527 );
1528 }
1529 }
1530 80 ▶ if ($self->needs_compiler) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->needs_compiler) 0 80 80
1531 0 $self->_add_prereq('build_requires', 'ExtUtils::CBuilder', 0);
1532 0 ▶ if ( ! $self->have_c_compiler ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->have_c_compiler) 0 0 0
1533 0 $self->log_warn(<<'EOM');
1534 Warning: ExtUtils::CBuilder not installed or no compiler detected
1535 Proceeding with configuration, but compilation may fail during Build
1536  
1537 EOM
1538 }
1539 }
1540  
1541 # If using share_dir, require File::ShareDir
1542 80 ▶ if ( $self->share_dir ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->share_dir) 0 80 80
1543 0 $self->_add_prereq( 'requires', 'File::ShareDir', '1.00' );
1544 }
1545  
1546 80 return;
1547 }
1548  
1549 7 ▶sub _add_prereq {
Subroutine _add_prereq: called CC=4 SCAR=15.5
1550 7 my ($self, $type, $module, $version) = @_;
1551 7 my $p = $self->{properties};
1552 7 ▶ $version = 0 unless defined $version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version 0 7 7
1553 7 ▶ if ( exists $p->{$type}{$module} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $p->{$type}{$module}) 0 7 7
1554 0 ▶ return if $self->compare_versions( $version, '<=', $p->{$type}{$module} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->compare_versions($version, "<=", $p->{$type}{$module}) 0 0 0
1555 }
1556 7 $self->log_verbose("Adding to $type\: $module => $version\n");
1557 7 $p->{$type}{$module} = $version;
1558 7 return 1;
1559 }
1560  
1561 107 ▶sub prereq_failures {
Subroutine prereq_failures: called CC=11 SCAR=24.7
Pod undocumented
1562 107 my ($self, $info) = @_;
1563  
1564 107 my @types = @{ $self->prereq_action_types };
1565 107 ▶ $info ||= {map {$_, $self->$_()} @types};
Condition100%2/2
$info ||= {map({$_, $self->$_;} @types)}
l!l
8225
MC/DC100%1/1
$info ||= {map({$_, $self->$_;} @types)}
$info
Truth table100%2/2
A
A= $info
Aresult
11
00
1566  
1567 107 my $out;
1568  
1569 107 foreach my $type (@types) {
1570 535 my $prereqs = $info->{$type};
1571 535 for my $modname ( keys %$prereqs ) {
1572 45 my $spec = $prereqs->{$modname};
1573 45 my $status = $self->check_installed_status($modname, $spec);
1574  
1575 45 ▶ if ($type =~ /^(?:\w+_)?conflicts$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type =~ /^(?:\w+_)?conflicts$/) { } 1 44 45
elsif ($type =~ /^(?:\w+_)?recommends$/) { } 5 39 44
1576 1 ▶ next if !$status->{ok};
Branch: 1 branch
BranchTrueFalseTotal
unless $status->{"ok"} 1 0 1
1577 0 $status->{conflicts} = delete $status->{need};
1578 0 $status->{message} = "$modname ($status->{have}) conflicts with this distribution";
1579  
1580 } elsif ($type =~ /^(?:\w+_)?recommends$/) {
1581 5 ▶ next if $status->{ok};
Branch: 1 branch
BranchTrueFalseTotal
if $status->{"ok"} 0 5 5
1582 5 ▶ $status->{message} = (!ref($status->{have}) && $status->{have} eq '<none>'
Branch: 1 branch
BranchTrueFalseTotal
!ref($status->{'have'}) && $status->{'have'} eq '<none>' ? : 5 0 5
Condition33%1/3
not ref $status->{"have"} and $status->{"have"} eq "<none>"
!ll&&!rl&&r
005
MC/DC0%0/2
not ref $status->{"have"} and $status->{"have"} eq "<none>"
not ref $status->{"have"} $status->{"have"} eq "<none>"
Truth table33%1/3
not(A) and B
A= not ref $status->{"have"}B= $status->{"have"} eq "<none>"
ABresult
0X0
100
111
1583 ? "$modname is not installed"
1584 : "$modname ($status->{have}) is installed, but we prefer to have $spec");
1585 } else {
1586 39 ▶ next if $status->{ok};
Branch: 1 branch
BranchTrueFalseTotal
if $status->{"ok"} 10 29 39
1587 }
1588  
1589 34 $out->{$type}{$modname} = $status;
1590 }
1591 }
1592  
1593 107 return $out;
1594 }
1595  
1596 # returns a hash of defined prerequisites; i.e. only prereq types with values
1597 82 ▶sub _enum_prereqs {
Subroutine _enum_prereqs: called CC=5 SCAR=16.2
1598 82 my $self = shift;
1599 82 my %prereqs;
1600 82 foreach my $type ( @{ $self->prereq_action_types } ) {
1601 410 ▶ if ( $self->can( $type ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($type)) 410 0 410
1602 410 ▶ my $prereq = $self->$type() || {};
Condition50%1/2
$self->$type || {}
l!l
4100
MC/DC0%0/1
$self->$type || {}
$self->$type
Truth table50%1/2
A
A= $self->$type
Aresult
11
00
1603 410 ▶ $prereqs{$type} = $prereq if %$prereq;
Branch: 1 branch
BranchTrueFalseTotal
if %$prereq 20 390 410
1604 }
1605 }
1606 82 return \%prereqs;
1607 }
1608  
1609 80 ▶sub check_prereq {
Subroutine check_prereq: called CC=7 SCAR=19.5
Pod undocumented
1610 80 my $self = shift;
1611  
1612 # Check to see if there are any prereqs to check
1613 80 my $info = $self->_enum_prereqs;
1614 80 ▶ return 1 unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 80 80
1615  
1616 80 my $log_text = "Checking prerequisites...\n";
1617  
1618 80 my $failures = $self->prereq_failures($info);
1619  
1620 80 ▶ if ( $failures ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($failures) { } 10 70 80
1621 10 $self->log_warn($log_text);
1622 10 for my $type ( @{ $self->prereq_action_types } ) {
1623 50 my $prereqs = $failures->{$type};
1624 50 ▶ $self->log_warn(" ${type}:\n") if keys %$prereqs;
Branch: 1 branch
BranchTrueFalseTotal
if keys %$prereqs 10 40 50
1625 50 for my $module ( sort keys %$prereqs ) {
1626 10 my $status = $prereqs->{$module};
1627 10 ▶ my $prefix = ($type =~ /^(?:\w+_)?recommends$/) ? "* " : "! ";
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /^(?:\w+_)?recommends$/ ? : 5 5 10
1628 10 $self->log_warn(" $prefix $status->{message}\n");
1629 }
1630 }
1631 10 return 0;
1632 } else {
1633 70 $self->log_verbose($log_text . "Looks good\n\n");
1634 70 return 1;
1635 }
1636 }
1637  
1638 7 ▶sub perl_version {
Subroutine perl_version: called CC=2 SCAR=7.2
Pod undocumented
1639 7 my ($self) = @_;
1640 # Check the current perl interpreter
1641 # It's much more convenient to use $] here than $^V, but 'man
1642 # perlvar' says I'm not supposed to. Bloody tyrant.
1643 7 ▶ return $^V ? $self->perl_version_to_float(sprintf "%vd", $^V) : $];
Branch: 1 branch
BranchTrueFalseTotal
$^V ? : 7 0 7
1644 }
1645  
1646 7 ▶sub perl_version_to_float {
Subroutine perl_version_to_float: called CC=2 SCAR=10.9
Pod undocumented
1647 7 my ($self, $version) = @_;
1648 7 ▶ return $version if grep( /\./, $version ) < 2;
Branch: 1 branch
BranchTrueFalseTotal
if grep(/\./, $version) < 2 7 0 7
1649 0 $version =~ s/\./../;
1650 0 $version =~ s/\.(\d+)/sprintf '%03d', $1/eg;
1651 0 return $version;
1652 }
1653  
1654 148 ▶sub _parse_conditions {
Subroutine _parse_conditions: called CC=3 SCAR=11.0
1655 148 my ($self, $spec) = @_;
1656  
1657 148 ▶ return ">= 0" if not defined $spec;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $spec 0 148 148
1658 148 ▶ if ($spec =~ /^\s*([\w.]+)\s*$/) { # A plain number, maybe with dots, letters, and underscores
Branch: 1 branch
BranchTrueFalseTotal
if ($spec =~ /^\s*([\w.]+)\s*$/) { } 143 5 148
1659 143 return (">= $spec");
1660 } else {
1661 5 return split /\s*,\s*/, $spec;
1662 }
1663 }
1664  
1665 21 ▶sub try_require {
Subroutine try_require: called CC=5 SCAR=18.7
Pod undocumented
1666 21 my ($self, $modname, $spec) = @_;
1667 21 ▶ my $status = $self->check_installed_status($modname, defined($spec) ? $spec : 0);
Branch: 1 branch
BranchTrueFalseTotal
defined $spec ? : 21 0 21
1668 21 ▶ return unless $status->{ok};
Branch: 1 branch
BranchTrueFalseTotal
unless $status->{"ok"} 0 21 21
1669 21 my $path = $modname;
1670 21 $path =~ s{::}{/}g;
1671 21 $path .= ".pm";
1672 21 ▶ if ( defined $INC{$path} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $INC{$path}) { } 21 0 21
elsif (exists $INC{$path}) { } 0 0 0
1673 21 return 1;
1674 }
1675 elsif ( exists $INC{$path} ) { # failed before, don't try again
1676 0 return;
1677 }
1678 else {
1679 0 return eval "require $modname";
1680 }
1681 }
1682  
1683 154 ▶sub check_installed_status {
Subroutine check_installed_status: called CC=12 SCAR=25.3
Pod undocumented
1684 154 my ($self, $modname, $spec) = @_;
1685 154 my %status = (need => $spec);
1686  
1687 154 ▶ if ($modname eq 'perl') {
Branch: 2 branches
BranchTrueFalseTotal
if ($modname eq 'perl') { } 0 154 154
elsif (eval { do { no strict; $status{'have'} = ${"${modname}::VERSION";} } }) { } 77 77 154
1688 0 $status{have} = $self->perl_version;
1689  
1690 297 ▶ } elsif (eval { no strict; $status{have} = ${"${modname}::VERSION"} }) {
Subroutine BEGIN: called CC=1 SCAR=0.0
1691 # Don't try to load if it's already loaded
1692  
1693 } else {
1694 77 my $pm_info = Module::Metadata->new_from_module( $modname );
1695 77 ▶ unless (defined( $pm_info )) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pm_info) 6 71 77
1696 6 @status{ qw(have message) } = ('<none>', "$modname is not installed");
1697 6 return \%status;
1698 }
1699  
1700 71 $status{have} = eval { $pm_info->version() };
1701 71 ▶ if ($spec and !defined($status{have})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec and not defined $status{"have"}) 0 71 71
Condition66%2/3
$spec and not defined $status{"have"}
!ll&&!rl&&r
44270
MC/DC0%0/2
$spec and not defined $status{"have"}
$spec not defined $status{"have"}
Truth table66%2/3
A and not(B)
A= $specB= not defined $status{"have"}
ABresult
0X0
100
111
1702 0 @status{ qw(have message) } = (undef, "Couldn't find a \$VERSION in prerequisite $modname");
1703 0 return \%status;
1704 }
1705 }
1706  
1707 148 my @conditions = $self->_parse_conditions($spec);
1708  
1709 148 foreach (@conditions) {
1710 148 ▶ my ($op, $version) = /^\s* (<=?|>=?|==|!=) \s* ([\w.]+) \s*$/x
Branch: 1 branch
BranchTrueFalseTotal
() = /^\s* (<=?|>=?|==|!=) \s* ([\w.]+) \s*$/x or die "Invalid prerequisite condition '${_}' for $modname" 148 0 148
1711 or die "Invalid prerequisite condition '$_' for $modname";
1712  
1713 148 ▶ $version = $self->perl_version_to_float($version)
Branch: 1 branch
BranchTrueFalseTotal
if $modname eq "perl" 0 148 148
1714 if $modname eq 'perl';
1715  
1716 148 ▶ next if $op eq '>=' and !$version; # Module doesn't have to actually define a $VERSION
Branch: 1 branch
BranchTrueFalseTotal
if $op eq ">=" and not $version 88 60 148
Condition100%3/3
$op eq ">=" and not $version
!ll&&!rl&&r
55588
MC/DC100%2/2
$op eq ">=" and not $version
$op eq ">=" not $version
Truth table100%3/3
A and not(B)
A= $op eq ">="B= not $version
ABresult
0X0
100
111
1717  
1718 60 ▶ unless ($self->compare_versions( $status{have}, $op, $version )) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->compare_versions($status{"have"}, $op, $version)) 29 31 60
1719 29 $status{message} = "$modname ($status{have}) is installed, but we need version $op $version";
1720 29 return \%status;
1721 }
1722 }
1723  
1724 119 $status{ok} = 1;
1725 119 return \%status;
1726 }
1727  
1728 61 ▶sub compare_versions {
Subroutine compare_versions: called CC=3 SCAR=11.0
Pod undocumented
1729 61 my $self = shift;
1730 61 my ($v1, $op, $v2) = @_;
1731 $v1 = version->new($v1)
1732 61 ▶ unless eval { $v1->isa('version') };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { $v1->isa("version") } } 34 27 61
1733  
1734 61 my $eval_str = "\$v1 $op \$v2";
1735 61 my $result = eval $eval_str;
1736 61 ▶ $self->log_warn("error comparing versions: '$eval_str' $@") if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 61 61
1737  
1738 61 return $result;
1739 }
1740  
1741 # I wish I could set $! to a string, but I can't, so I use $@
1742 0 ▶sub check_installed_version {
Subroutine check_installed_version: not called CC=4 SCAR=30.0
Pod undocumented
1743 0 my ($self, $modname, $spec) = @_;
1744  
1745 0 my $status = $self->check_installed_status($modname, $spec);
1746  
1747 0 ▶ if ($status->{ok}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status->{"ok"}) 0 0 0
1748 0 ▶ return $status->{have} if $status->{have} and "$status->{have}" ne '<none>';
Branch: 1 branch
BranchTrueFalseTotal
if $status->{"have"} and qq[$status->{"have"}] ne "<none>" 0 0 0
Condition0%0/3
$status->{"have"} and qq[$status->{"have"}] ne "<none>"
!ll&&!rl&&r
000
MC/DC0%0/2
$status->{"have"} and qq[$status->{"have"}] ne "<none>"
$status->{"have"} qq[$status->{"have"}] ne "<none>"
Truth table0%0/3
A and B
A= $status->{"have"}B= qq[$status->{"have"}] ne "<none>"
ABresult
0X0
100
111
1749 0 return '0 but true';
1750 }
1751  
1752 0 $@ = $status->{message};
1753 0 return 0;
1754 }
1755  
1756 15 ▶sub make_executable {
Subroutine make_executable: called CC=2 SCAR=6.9
Pod undocumented
1757 # Perl's chmod() is mapped to useful things on various non-Unix
1758 # platforms, so we use it in the base class even though it looks
1759 # Unixish.
1760  
1761 15 my $self = shift;
1762 15 foreach (@_) {
1763 15 my $current_mode = (stat $_)[2];
1764 15 chmod $current_mode | oct(111), $_;
1765 }
1766 }
1767  
1768 0 ▶sub is_executable {
Subroutine is_executable: not called CC=1 SCAR=6.9
Pod undocumented
1769 # We assume this does the right thing on generic platforms, though
1770 # we do some other more specific stuff on Unixish platforms.
1771 0 my ($self, $file) = @_;
1772 0 return -x $file;
1773 }
1774  
1775 0 ▶sub _startperl { shift()->config('startperl') }
Subroutine _startperl: not called CC=1 SCAR=6.9
1776  
1777 # Return any directories in @INC which are not in the default @INC for
1778 # this perl. For example, stuff passed in with -I or loaded with "use lib".
1779 4289 ▶sub _added_to_INC {
Subroutine _added_to_INC: called CC=2 SCAR=6.9
1780 4289 my $self = shift;
1781  
1782 4289 my %seen;
1783 4289 $seen{$_}++ foreach $self->_default_INC;
1784 4242 return grep !$seen{$_}++, @INC;
1785 }
1786  
1787 # Determine the default @INC for this Perl
1788 {
1789 297 my @default_inc; # Memoize
1790 4754 ▶ sub _default_INC {
Subroutine _default_INC: called CC=3 SCAR=11.0
1791 4754 my $self = shift;
1792 4754 ▶ return @default_inc if @default_inc;
Branch: 1 branch
BranchTrueFalseTotal
if @default_inc 4509 245 4754
1793  
1794 245 local $ENV{PERL5LIB}; # this is not considered part of the default.
1795  
1796 245 ▶ my $perl = ref($self) ? $self->perl : $self->find_perl_interpreter;
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 43 202 245
1797  
1798 245 my @inc = $self->_backticks($perl, '-le', 'print for @INC');
1799 198 chomp @inc;
1800  
1801 198 return @default_inc = @inc;
1802 }
1803 }
1804  
1805 297 ▶sub print_build_script {
Subroutine print_build_script: called CC=8 SCAR=22.9
Pod undocumented
1806 6 my ($self, $fh) = @_;
1807  
1808 6 my $build_package = $self->build_class;
1809  
1810 6 my $closedata="";
1811  
1812 6 my $config_requires;
1813 6 ▶ if ( -f $self->metafile ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $self->metafile) 0 6 6
1814 0 my $meta = eval { $self->read_metafile( $self->metafile ) };
1815 0 ▶ $config_requires = $meta && $meta->{prereqs}{configure}{requires}{'Module::Build'};
Condition0%0/3
$meta && $meta->{'prereqs'}{'configure'}{'requires'}{'Module::Build'}
!ll&&!rl&&r
000
MC/DC0%0/2
$meta && $meta->{'prereqs'}{'configure'}{'requires'}{'Module::Build'}
$meta $meta->{'prereqs'}{'configure'}{'requires'}{'Module::Build'}
Truth table0%0/3
A && B
A= $metaB= $meta->{'prereqs'}{'configure'}{'requires'}{'Module::Build'}
ABresult
0X0
100
111
1816 }
1817 6 ▶ $config_requires ||= 0;
Condition50%1/2
$config_requires ||= 0
l!l
06
MC/DC0%0/1
$config_requires ||= 0
$config_requires
Truth table50%1/2
A
A= $config_requires
Aresult
11
00
1818  
1819 6 my %q = map {$_, $self->$_()} qw(config_dir base_dir);
1820  
1821 6 ▶ $q{base_dir} = Win32::GetShortPathName($q{base_dir}) if $self->is_windowsish;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_windowsish 0 6 6
1822  
1823 6 $q{magic_numfile} = $self->config_file('magicnum');
1824  
1825 6 my @myINC = $self->_added_to_INC;
1826 6 for (@myINC, values %q) {
1827 51 ▶ $_ = File::Spec->canonpath( $_ ) unless $self->is_vmsish;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_vmsish 51 0 51
1828 51 s/([\\\'])/\\$1/g;
1829 }
1830  
1831 6 my $quoted_INC = join ",\n", map " '$_'", @myINC;
1832 6 my $shebang = $self->_startperl;
1833 6 my $magic_number = $self->magic_number;
1834  
1835 6 ▶my $dot_in_inc_code = $INC[-1] eq '.' ? <<'END' : '';
Branch: 1 branch
BranchTrueFalseTotal
$INC[-1] eq '.' ? : 6 0 6
1836 if ($INC[-1] ne '.') {
1837 push @INC, '.';
1838 }
1839 END
1840 6 print $fh <<EOF;
1841 $shebang
1842  
1843 use strict;
1844 use Cwd;
1845 use File::Basename;
1846 use File::Spec;
1847  
1848 sub magic_number_matches {
1849 return 0 unless -e '$q{magic_numfile}';
1850 my \$FH;
1851 open \$FH, '<','$q{magic_numfile}' or return 0;
1852 my \$filenum = <\$FH>;
1853 close \$FH;
1854 return \$filenum == $magic_number;
1855 }
1856  
1857 my \$progname;
1858 my \$orig_dir;
1859 BEGIN {
1860 \$^W = 1; # Use warnings
1861 \$progname = basename(\$0);
1862 \$orig_dir = Cwd::cwd();
1863 my \$base_dir = '$q{base_dir}';
1864 if (!magic_number_matches()) {
1865 unless (chdir(\$base_dir)) {
1866 die ("Couldn't chdir(\$base_dir), aborting\\n");
1867 }
1868 unless (magic_number_matches()) {
1869 die ("Configuration seems to be out of date, please re-run 'perl Build.PL' again.\\n");
1870 }
1871 }
1872 unshift \@INC,
1873 (
1874 $quoted_INC
1875 );
1876 $dot_in_inc_code
1877 }
1878  
1879 close(*DATA) unless eof(*DATA); # ensure no open handles to this script
1880  
1881 use $build_package;
1882 Module::Build->VERSION(q{$config_requires});
1883  
1884 # Some platforms have problems setting \$^X in shebang contexts, fix it up here
1885 \$^X = Module::Build->find_perl_interpreter;
1886  
1887 if (-e 'Build.PL' and not $build_package->up_to_date('Build.PL', \$progname)) {
1888 warn "Warning: Build.PL has been altered. You may need to run 'perl Build.PL' again.\\n";
1889 }
1890  
1891 # This should have just enough arguments to be able to bootstrap the rest.
1892 my \$build = $build_package->resume (
1893 properties => {
1894 config_dir => '$q{config_dir}',
1895 orig_dir => \$orig_dir,
1896 },
1897 );
1898  
1899 \$build->dispatch;
1900 EOF
1901 }
1902  
1903 6 ▶sub create_mymeta {
Subroutine create_mymeta: called CC=9 SCAR=26.0
Pod undocumented
1904 6 my ($self) = @_;
1905  
1906 6 my ($meta_obj, $mymeta);
1907 6 my @metafiles = ( $self->metafile2, $self->metafile, );
1908 6 my @mymetafiles = ( $self->mymetafile2, $self->mymetafile, );
1909  
1910 # cleanup old MYMETA
1911 6 for my $f ( @mymetafiles ) {
1912 12 ▶ if ( $self->delete_filetree($f) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->delete_filetree($f)) 12 0 12
1913 12 $self->log_verbose("Removed previous '$f'\n");
1914 }
1915 }
1916  
1917 # Try loading META.json or META.yml
1918 6 ▶ if ( $self->try_require("CPAN::Meta", "2.142060") ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->try_require("CPAN::Meta", "2.142060")) 6 0 6
1919 6 for my $file ( @metafiles ) {
1920 12 ▶ next unless -f $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $file 12 0 12
1921 0 $meta_obj = eval { CPAN::Meta->load_file($file, { lazy_validation => 0 }) };
1922 0 ▶ last if $meta_obj;
Branch: 1 branch
BranchTrueFalseTotal
if $meta_obj 0 0 0
1923 }
1924 }
1925  
1926 # maybe get a copy in spec v2 format (regardless of original source)
1927  
1928 6 my $mymeta_obj;
1929 6 ▶ if ($meta_obj) {
Branch: 1 branch
BranchTrueFalseTotal
if ($meta_obj) { } 0 6 6
1930 # if we have metadata, just update it
1931 my %updated = (
1932 0 %{ $meta_obj->as_struct({ version => 2.0 }) },
1933 prereqs => $self->_normalize_prereqs,
1934 dynamic_config => 0,
1935 generated_by => "Module::Build version $Module::Build::VERSION",
1936 );
1937 0 $mymeta_obj = CPAN::Meta->new( \%updated, { lazy_validation => 0 } );
1938 }
1939 else {
1940 6 $mymeta_obj = $self->_get_meta_object(quiet => 0, dynamic => 0, fatal => 1, auto => 0);
1941 }
1942  
1943 6 my @created = $self->_write_meta_files( $mymeta_obj, 'MYMETA' );
1944  
1945 6 ▶ $self->log_warn("Could not create MYMETA files\n")
Branch: 1 branch
BranchTrueFalseTotal
unless @created 0 6 6
1946 unless @created;
1947  
1948 6 return 1;
1949 }
1950  
1951 6 ▶sub create_build_script {
Subroutine create_build_script: called CC=3 SCAR=11.0
Pod undocumented
1952 6 my ($self) = @_;
1953  
1954 6 $self->write_config;
1955 6 $self->create_mymeta;
1956  
1957 # Create Build
1958 6 my ($build_script, $dist_name, $dist_version)
1959 = map $self->$_(), qw(build_script dist_name dist_version);
1960  
1961 6 ▶ if ( $self->delete_filetree($build_script) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->delete_filetree($build_script)) 6 0 6
1962 6 $self->log_verbose("Removed previous script '$build_script'\n");
1963 }
1964  
1965 6 $self->log_info("Creating new '$build_script' script for ",
1966 "'$dist_name' version '$dist_version'\n");
1967 6 ▶ open(my $fh, '>', $build_script) or die "Can't create '$build_script': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $build_script or die "Can't create '${build_script}': $!" 6 0 6
1968 6 $self->print_build_script($fh);
1969 6 close $fh;
1970  
1971 6 $self->make_executable($build_script);
1972  
1973 6 return 1;
1974 }
1975  
1976 80 ▶sub check_manifest {
Subroutine check_manifest: called CC=3 SCAR=11.1
Pod undocumented
1977 80 my $self = shift;
1978 80 ▶ return unless -e 'MANIFEST';
Branch: 1 branch
BranchTrueFalseTotal
unless -e "MANIFEST" 2 78 80
1979  
1980 # Stolen nearly verbatim from MakeMaker. But ExtUtils::Manifest
1981 # could easily be re-written into a modern Perl dialect.
1982  
1983 78 require ExtUtils::Manifest; # ExtUtils::Manifest is not warnings clean.
1984 78 local ($^W, $ExtUtils::Manifest::Quiet) = (0,1);
1985  
1986 78 $self->log_verbose("Checking whether your kit is complete...\n");
1987 78 ▶ if (my @missed = ExtUtils::Manifest::manicheck()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@missed) = ExtUtils::Manifest::manicheck()) { } 0 78 78
1988 0 $self->log_warn("WARNING: the following files are missing in your kit:\n",
1989 "\t", join("\n\t", @missed), "\n",
1990 "Please inform the author.\n\n");
1991 } else {
1992 78 $self->log_verbose("Looks good\n\n");
1993 }
1994 }
1995  
1996 131 ▶sub dispatch {
Subroutine dispatch: called CC=4 SCAR=13.9
Pod undocumented
1997 131 my $self = shift;
1998 131 local $self->{_completed_actions} = {};
1999  
2000 131 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 130 1 131
2001 130 my ($action, %p) = @_;
2002 130 ▶ my $args = $p{args} ? delete($p{args}) : {};
Branch: 1 branch
BranchTrueFalseTotal
$p{'args'} ? : 2 128 130
2003  
2004 130 local $self->{invoked_action} = $action;
2005 130 local $self->{args} = {%{$self->{args}}, %$args};
2006 130 local $self->{properties} = {%{$self->{properties}}, %p};
2007 130 return $self->_call_action($action);
2008 }
2009  
2010 1 ▶ die "No build action specified" unless $self->{action};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"action"} 0 1 1
2011 1 local $self->{invoked_action} = $self->{action};
2012 1 $self->_call_action($self->{action});
2013 }
2014  
2015 485 ▶sub _call_action {
Subroutine _call_action: called CC=3 SCAR=11.0
2016 485 my ($self, $action) = @_;
2017  
2018 485 ▶ return if $self->{_completed_actions}{$action}++;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_completed_actions"}{$action}++ 84 401 485
2019  
2020 401 local $self->{action} = $action;
2021 401 my $method = $self->can_action( $action );
2022 401 ▶ die "No action '$action' defined, try running the 'help' action.\n" unless $method;
Branch: 1 branch
BranchTrueFalseTotal
unless $method 0 401 401
2023 401 $self->log_debug("Starting ACTION_$action\n");
2024 401 my $rc = $self->$method();
2025 395 $self->log_debug("Finished ACTION_$action\n");
2026 395 return $rc;
2027 }
2028  
2029 401 ▶sub can_action {
Subroutine can_action: called CC=1 SCAR=0.0
Pod undocumented
2030 401 my ($self, $action) = @_;
2031 401 return $self->can( "ACTION_$action" );
2032 }
2033  
2034 # cuts the user-specified options out of the command-line args
2035 562 ▶sub cull_options {
Subroutine cull_options: called CC=10 SCAR=23.2
Pod undocumented
2036 562 my $self = shift;
2037 562 my (@argv) = @_;
2038  
2039 # XXX is it even valid to call this as a class method?
2040 562 ▶ return({}, @argv) unless(ref($self)); # no object
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 114 448 562
2041  
2042 448 my $specs = $self->get_options;
2043 448 ▶ return({}, @argv) unless($specs and %$specs); # no user options
Branch: 1 branch
BranchTrueFalseTotal
unless $specs and %$specs 438 10 448
Condition66%2/3
$specs and %$specs
!ll&&!rl&&r
043810
MC/DC50%1/2
$specs and %$specs
$specs %$specs
Truth table66%2/3
A and B
A= $specsB= %$specs
ABresult
0X0
100
111
2044  
2045 10 require Getopt::Long;
2046 # XXX Should we let Getopt::Long handle M::B's options? That would
2047 # be easy-ish to add to @specs right here, but wouldn't handle options
2048 # passed without "--" as M::B currently allows. We might be able to
2049 # get around this by setting the "prefix_pattern" Configure option.
2050 10 my @specs;
2051 10 my $args = {};
2052 # Construct the specifications for GetOptions.
2053 10 foreach my $k (sort keys %$specs) {
2054 40 my $v = $specs->{$k};
2055 # Throw an error if specs conflict with our own.
2056 40 ▶ die "Option specification '$k' conflicts with a " . ref $self
Branch: 1 branch
BranchTrueFalseTotal
if $self->valid_property($k) 0 40 40
2057 . " option of the same name"
2058 if $self->valid_property($k);
2059 40 ▶ push @specs, $k . (defined $v->{type} ? $v->{type} : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $v->{'type'} ? : 30 10 40
2060 40 ▶ push @specs, $v->{store} if exists $v->{store};
Branch: 1 branch
BranchTrueFalseTotal
if exists $v->{"store"} 0 40 40
2061 40 ▶ $args->{$k} = $v->{default} if exists $v->{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $v->{"default"} 10 30 40
2062 }
2063  
2064 10 local @ARGV = @argv; # No other way to dupe Getopt::Long
2065  
2066 # Get the options values and return them.
2067 # XXX Add option to allow users to set options?
2068 10 ▶ if ( @specs ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@specs) 10 0 10
2069 10 Getopt::Long::Configure('pass_through');
2070 10 Getopt::Long::GetOptions($args, @specs);
2071 }
2072  
2073 10 return $args, @ARGV;
2074 }
2075  
2076 538 ▶sub unparse_args {
Subroutine unparse_args: called CC=4 SCAR=13.9
Pod undocumented
2077 538 my ($self, $args) = @_;
2078 538 my @out;
2079 538 foreach my $k (sort keys %$args) {
2080 599 my $v = $args->{$k};
2081 277 ▶ push @out, (ref $v eq 'HASH' ? map {+"--$k", "$_=$v->{$_}"} sort keys %$v :
Branch: 1 branch
BranchTrueFalseTotal
ref $v eq 'ARRAY' ? : 57 457 514
2082 0 ▶ ref $v eq 'ARRAY' ? map {+"--$k", $_} @$v :
Branch: 1 branch
BranchTrueFalseTotal
ref $v eq 'HASH' ? : 85 514 599
2083 ("--$k", $v));
2084 }
2085 538 return @out;
2086 }
2087  
2088 56 ▶sub args {
Subroutine args: called CC=4 SCAR=13.9
Pod undocumented
2089 56 my $self = shift;
2090 56 ▶ return wantarray ? %{ $self->{args} } : $self->{args} unless @_;
Branch: 2 branches
BranchTrueFalseTotal
unless @_ 8 48 56
wantarray ? : 4 4 8
2091 48 my $key = shift;
2092 48 ▶ $self->{args}{$key} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 48 48
2093 48 return $self->{args}{$key};
2094 }
2095  
2096 # allows select parameters (with underscores) to be spoken with dashes
2097 # when used as command-line options
2098 697 ▶sub _translate_option {
Subroutine _translate_option: called CC=2 SCAR=6.9
2099 697 my $self = shift;
2100 697 my $opt = shift;
2101  
2102 697 (my $tr_opt = $opt) =~ tr/-/_/;
2103  
2104 697 ▶ return $tr_opt if grep $tr_opt =~ /^(?:no_?)?$_$/, qw(
Branch: 1 branch
BranchTrueFalseTotal
if grep(($tr_opt =~ /^(?:no_?)?$_$/), ("create_license", "create_makefile_pl", "create_readme", "extra_compiler_flags", "extra_linker_flags", "install_base", "install_path", "meta_add", "meta_merge", "test_files", "use_rcfile", "use_tap_harness", "tap_harness_args", "cpan_client", "pureperl_only", "allow_pureperl")) 2 695 697
2105 create_license
2106 create_makefile_pl
2107 create_readme
2108 extra_compiler_flags
2109 extra_linker_flags
2110 install_base
2111 install_path
2112 meta_add
2113 meta_merge
2114 test_files
2115 use_rcfile
2116 use_tap_harness
2117 tap_harness_args
2118 cpan_client
2119 pureperl_only
2120 allow_pureperl
2121 ); # normalize only selected option names
2122  
2123 695 return $opt;
2124 }
2125  
2126 297 my %singular_argument = map { ($_ => 1) } qw/install_base prefix destdir installdirs verbose quiet uninst debug sign/;
2127  
2128 407 ▶sub _read_arg {
Subroutine _read_arg: called CC=4 SCAR=14.0
2129 407 my ($self, $args, $key, $val) = @_;
2130  
2131 407 $key = $self->_translate_option($key);
2132  
2133 407 ▶ if ( exists $args->{$key} and not $singular_argument{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{$key} and not $singular_argument{$key}) { } 58 349 407
Condition66%2/3
exists $args->{$key} and not $singular_argument{$key}
!ll&&!rl&&r
349058
MC/DC50%1/2
exists $args->{$key} and not $singular_argument{$key}
exists $args->{$key} not $singular_argument{$key}
Truth table66%2/3
A and not(B)
A= exists $args->{$key}B= not $singular_argument{$key}
ABresult
0X0
100
111
2134 58 ▶ $args->{$key} = [ $args->{$key} ] unless ref $args->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args->{$key} 58 0 58
2135 58 push @{$args->{$key}}, $val;
2136 } else {
2137 349 $args->{$key} = $val;
2138 }
2139 }
2140  
2141 # decide whether or not an option requires/has an operand
2142 290 ▶sub _optional_arg {
Subroutine _optional_arg: called CC=5 SCAR=17.2
2143 290 my $self = shift;
2144 290 my $opt = shift;
2145 290 my $argv = shift;
2146  
2147 290 $opt = $self->_translate_option($opt);
2148  
2149 290 my @bool_opts = qw(
2150 build_bat
2151 create_license
2152 create_readme
2153 pollute
2154 quiet
2155 uninst
2156 use_rcfile
2157 verbose
2158 debug
2159 sign
2160 use_tap_harness
2161 pureperl_only
2162 allow_pureperl
2163 );
2164  
2165 # inverted boolean options; eg --noverbose or --no-verbose
2166 # converted to proper name & returned with false value (verbose, 0)
2167 290 ▶ if ( grep $opt =~ /^no[-_]?$_$/, @bool_opts ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep(($opt =~ /^no[-_]?$_$/), @bool_opts)) 0 290 290
2168 0 $opt =~ s/^no-?//;
2169 0 return ($opt, 0);
2170 }
2171  
2172 # non-boolean option; return option unchanged along with its argument
2173 290 ▶ return ($opt, shift(@$argv)) unless grep $_ eq $opt, @bool_opts;
Branch: 1 branch
BranchTrueFalseTotal
unless grep(($_ eq $opt), @bool_opts) 289 1 290
2174  
2175 # we're punting a bit here, if an option appears followed by a digit
2176 # we take the digit as the argument for the option. If there is
2177 # nothing that looks like a digit, we pretend the option is a flag
2178 # that is being set and has no argument.
2179 1 my $arg = 1;
2180 1 ▶ $arg = shift(@$argv) if @$argv && $argv->[0] =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
if @$argv and $argv->[0] =~ /^\d+$/ 0 1 1
Condition33%1/3
@$argv and $argv->[0] =~ /^\d+$/
!ll&&!rl&&r
010
MC/DC0%0/2
@$argv and $argv->[0] =~ /^\d+$/
@$argv $argv->[0] =~ /^\d+$/
Truth table33%1/3
A and B
A= @$argvB= $argv->[0] =~ /^\d+$/
ABresult
0X0
100
111
2181  
2182 1 return ($opt, $arg);
2183 }
2184  
2185 562 ▶sub read_args {
Subroutine read_args: called CC=25 SCAR=38.7
Pod undocumented
2186 562 my $self = shift;
2187  
2188 562 (my $args, @_) = $self->cull_options(@_);
2189 562 my %args = %$args;
2190  
2191 562 my $opt_re = qr/[\w\-]+/;
2192  
2193 562 my ($action, @argv);
2194 562 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 408 562 970
2195 408 local $_ = shift;
2196 408 ▶ if ( /^(?:--)?($opt_re)=(.*)$/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if (/^(?:--)?($opt_re)=(.*)$/) { } 117 291 408
elsif (/^--($opt_re)$/) { } 290 1 291
elsif (/^($opt_re)$/ and not defined $action) { } 1 0 1
2197 117 $self->_read_arg(\%args, $1, $2);
2198 } elsif ( /^--($opt_re)$/ ) {
2199 290 my($opt, $arg) = $self->_optional_arg($1, \@_);
2200 290 $self->_read_arg(\%args, $opt, $arg);
2201 ▶ } elsif ( /^($opt_re)$/ and !defined($action)) {
Condition33%1/3
/^($opt_re)$/ and not defined $action
!ll&&!rl&&r
001
MC/DC0%0/2
/^($opt_re)$/ and not defined $action
/^($opt_re)$/ not defined $action
Truth table33%1/3
A and not(B)
A= /^($opt_re)$/B= not defined $action
ABresult
0X0
100
111
2202 1 $action = $1;
2203 } else {
2204 0 push @argv, $_;
2205 }
2206 }
2207 562 $args{ARGV} = \@argv;
2208  
2209 562 for ('extra_compiler_flags', 'extra_linker_flags') {
2210 1124 ▶ $args{$_} = [ $self->split_like_shell($args{$_}) ] if exists $args{$_};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{$_} 2 1122 1124
2211 }
2212  
2213 # Convert to arrays
2214 562 for ('include_dirs') {
2215 562 ▶ $args{$_} = [ $args{$_} ] if exists $args{$_} && !ref $args{$_}
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{$_} and not ref $args{$_} 0 562 562
Condition33%1/3
exists $args{$_} and not ref $args{$_}
!ll&&!rl&&r
56200
MC/DC0%0/2
exists $args{$_} and not ref $args{$_}
exists $args{$_} not ref $args{$_}
Truth table33%1/3
A and not(B)
A= exists $args{$_}B= not ref $args{$_}
ABresult
0X0
100
111
2216 }
2217  
2218 # Hashify these parameters
2219 562 for ($self->hash_properties, 'config') {
2220 8997 ▶ next unless exists $args{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{$_} 8938 59 8997
2221 59 my %hash;
2222 59 ▶ $args{$_} ||= [];
Condition50%1/2
$args{$_} ||= []
l!l
590
MC/DC0%0/1
$args{$_} ||= []
$args{$_}
Truth table50%1/2
A
A= $args{$_}
Aresult
11
00
2223 59 ▶ $args{$_} = [ $args{$_} ] unless ref $args{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{$_} 1 58 59
2224 59 foreach my $arg ( @{$args{$_}} ) {
2225 117 ▶ $arg =~ /($opt_re)=(.*)/
Branch: 1 branch
BranchTrueFalseTotal
$arg =~ /($opt_re)=(.*)/ or die "Malformed '${_}' argument: '${arg}' should be something like 'foo=bar'" 117 0 117
2226 or die "Malformed '$_' argument: '$arg' should be something like 'foo=bar'";
2227 117 $hash{$1} = $2;
2228 }
2229 59 $args{$_} = \%hash;
2230 }
2231  
2232 # De-tilde-ify any path parameters
2233 562 for my $key (qw(prefix install_base destdir)) {
2234 1686 ▶ next if !defined $args{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{$key} 1686 0 1686
2235 0 $args{$key} = $self->_detildefy($args{$key});
2236 }
2237  
2238 562 for my $key (qw(install_path)) {
2239 562 ▶ next if !defined $args{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{$key} 562 0 562
2240  
2241 0 for my $subkey (keys %{$args{$key}}) {
2242 0 ▶ next if !defined $args{$key}{$subkey};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{$key}{$subkey} 0 0 0
2243 0 my $subkey_ext = $self->_detildefy($args{$key}{$subkey});
2244 0 ▶ if ( $subkey eq 'html' ) { # translate for compatibility
Branch: 1 branch
BranchTrueFalseTotal
if ($subkey eq 'html') { } 0 0 0
2245 0 $args{$key}{binhtml} = $subkey_ext;
2246 0 $args{$key}{libhtml} = $subkey_ext;
2247 } else {
2248 0 $args{$key}{$subkey} = $subkey_ext;
2249 }
2250 }
2251 }
2252  
2253 562 ▶ if ($args{makefile_env_macros}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"makefile_env_macros"}) 0 562 562
2254 0 require Module::Build::Compat;
2255 0 %args = (%args, Module::Build::Compat->makefile_to_build_macros);
2256 }
2257  
2258 562 return \%args, $action;
2259 }
2260  
2261 # Default: do nothing. Overridden for Unix & Windows.
2262 0 ▶sub _detildefy {}
Subroutine _detildefy: not called CC=1 SCAR=0.0
2263  
2264  
2265 # merge Module::Build argument lists that have already been parsed
2266 # by read_args(). Takes two references to option hashes and merges
2267 # the contents, giving priority to the first.
2268 813 ▶sub _merge_arglist {
Subroutine _merge_arglist: called CC=8 SCAR=26.0
2269 813 my( $self, $opts1, $opts2 ) = @_;
2270  
2271 813 ▶ $opts1 ||= {};
Condition100%2/2
$opts1 ||= {}
l!l
80211
MC/DC100%1/1
$opts1 ||= {}
$opts1
Truth table100%2/2
A
A= $opts1
Aresult
11
00
2272 813 ▶ $opts2 ||= {};
Condition50%1/2
$opts2 ||= {}
l!l
8130
MC/DC0%0/1
$opts2 ||= {}
$opts2
Truth table50%1/2
A
A= $opts2
Aresult
11
00
2273 813 my %new_opts = %$opts1;
2274 813 ▶ while (my ($key, $val) = each %$opts2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$opts2) 1665 813 2478
2275 1665 ▶ if ( exists( $opts1->{$key} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opts1->{$key}) { } 0 1665 1665
2276 0 ▶ if ( ref( $val ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val eq "HASH") 0 0 0
2277 0 ▶ while (my ($k, $v) = each %$val) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$val) 0 0 0
2278 0 ▶ $new_opts{$key}{$k} = $v unless exists( $opts1->{$key}{$k} );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts1->{$key}{$k} 0 0 0
2279 }
2280 }
2281 } else {
2282 1665 $new_opts{$key} = $val
2283 }
2284 }
2285  
2286 813 return %new_opts;
2287 }
2288  
2289 # Look for a home directory on various systems.
2290 444 ▶sub _home_dir {
Subroutine _home_dir: called CC=5 SCAR=17.5
2291 444 my @home_dirs;
2292 444 ▶ push( @home_dirs, $ENV{HOME} ) if $ENV{HOME};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"HOME"} 444 0 444
2293  
2294 push( @home_dirs, File::Spec->catpath($ENV{HOMEDRIVE}, $ENV{HOMEPATH}, '') )
2295 444 ▶ if $ENV{HOMEDRIVE} && $ENV{HOMEPATH};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"HOMEDRIVE"} and $ENV{"HOMEPATH"} 0 444 444
Condition33%1/3
$ENV{"HOMEDRIVE"} and $ENV{"HOMEPATH"}
!ll&&!rl&&r
44400
MC/DC0%0/2
$ENV{"HOMEDRIVE"} and $ENV{"HOMEPATH"}
$ENV{"HOMEDRIVE"} $ENV{"HOMEPATH"}
Truth table33%1/3
A and B
A= $ENV{"HOMEDRIVE"}B= $ENV{"HOMEPATH"}
ABresult
0X0
100
111
2296  
2297 444 my @other_home_envs = qw( USERPROFILE APPDATA WINDIR SYS$LOGIN );
2298 444 push( @home_dirs, map $ENV{$_}, grep $ENV{$_}, @other_home_envs );
2299  
2300 444 my @real_home_dirs = grep -d, @home_dirs;
2301  
2302 444 ▶ return wantarray ? @real_home_dirs : shift( @real_home_dirs );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 444 0 444
2303 }
2304  
2305 444 ▶sub _find_user_config {
Subroutine _find_user_config: called CC=3 SCAR=11.0
2306 444 my $self = shift;
2307 444 my $file = shift;
2308 444 foreach my $dir ( $self->_home_dir ) {
2309 437 my $path = File::Spec->catfile( $dir, $file );
2310 437 ▶ return $path if -e $path;
Branch: 1 branch
BranchTrueFalseTotal
if -e $path 0 437 437
2311 }
2312 444 return undef;
2313 }
2314  
2315 # read ~/.modulebuildrc returning global options '*' and
2316 # options specific to the currently executing $action.
2317 448 ▶sub read_modulebuildrc {
Subroutine read_modulebuildrc: called CC=18 SCAR=52.0
Pod undocumented
2318 448 my( $self, $action ) = @_;
2319  
2320 448 ▶ return () unless $self->use_rcfile;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->use_rcfile 4 444 448
2321  
2322 444 my $modulebuildrc;
2323 444 ▶ if ( exists($ENV{MODULEBUILDRC}) && $ENV{MODULEBUILDRC} eq 'NONE' ) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $ENV{'MODULEBUILDRC'} and $ENV{'MODULEBUILDRC'} eq 'NONE') { } 0 444 444
elsif (exists $ENV{'MODULEBUILDRC'} and -e $ENV{'MODULEBUILDRC'}) { } 0 444 444
elsif (exists $ENV{'MODULEBUILDRC'}) { } 0 444 444
Condition33%1/3
exists $ENV{"MODULEBUILDRC"} and $ENV{"MODULEBUILDRC"} eq "NONE"
!ll&&!rl&&r
44400
MC/DC0%0/2
exists $ENV{"MODULEBUILDRC"} and $ENV{"MODULEBUILDRC"} eq "NONE"
exists $ENV{"MODULEBUILDRC"} $ENV{"MODULEBUILDRC"} eq "NONE"
Truth table33%1/3
A and B
A= exists $ENV{"MODULEBUILDRC"}B= $ENV{"MODULEBUILDRC"} eq "NONE"
ABresult
0X0
100
111
2324 0 return ();
2325 ▶ } elsif ( exists($ENV{MODULEBUILDRC}) && -e $ENV{MODULEBUILDRC} ) {
Condition33%1/3
exists $ENV{"MODULEBUILDRC"} and -e $ENV{"MODULEBUILDRC"}
!ll&&!rl&&r
44400
MC/DC0%0/2
exists $ENV{"MODULEBUILDRC"} and -e $ENV{"MODULEBUILDRC"}
exists $ENV{"MODULEBUILDRC"} -e $ENV{"MODULEBUILDRC"}
Truth table33%1/3
A and B
A= exists $ENV{"MODULEBUILDRC"}B= -e $ENV{"MODULEBUILDRC"}
ABresult
0X0
100
111
2326 0 $modulebuildrc = $ENV{MODULEBUILDRC};
2327 } elsif ( exists($ENV{MODULEBUILDRC}) ) {
2328 0 $self->log_warn("WARNING: Can't find resource file " .
2329 "'$ENV{MODULEBUILDRC}' defined in environment.\n" .
2330 "No options loaded\n");
2331 0 return ();
2332 } else {
2333 444 $modulebuildrc = $self->_find_user_config( '.modulebuildrc' );
2334 444 ▶ return () unless $modulebuildrc;
Branch: 1 branch
BranchTrueFalseTotal
unless $modulebuildrc 444 0 444
2335 }
2336  
2337 0 ▶ open(my $fh, '<', $modulebuildrc )
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $modulebuildrc or die "Can't open ${modulebuildrc}: $!" 0 0 0
2338 or die "Can't open $modulebuildrc: $!";
2339  
2340 0 my %options; my $buffer = '';
2341 0 ▶ while (defined( my $line = <$fh> )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 0 0 0
2342 0 chomp( $line );
2343 0 $line =~ s/#.*$//;
2344 0 ▶ next unless length( $line );
Branch: 1 branch
BranchTrueFalseTotal
unless length $line 0 0 0
2345  
2346 0 ▶ if ( $line =~ /^\S/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\S/) { } 0 0 0
2347 0 ▶ if ( $buffer ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer) 0 0 0
2348 0 my( $action, $options ) = split( /\s+/, $buffer, 2 );
2349 0 $options{$action} .= $options . ' ';
2350 0 $buffer = '';
2351 }
2352 0 $buffer = $line;
2353 } else {
2354 0 $buffer .= $line;
2355 }
2356 }
2357  
2358 0 ▶ if ( $buffer ) { # anything left in $buffer ?
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer) 0 0 0
2359 0 my( $action, $options ) = split( /\s+/, $buffer, 2 );
2360 0 $options{$action} .= $options . ' '; # merge if more than one line
2361 }
2362  
2363 my ($global_opts) =
2364 0 ▶ $self->read_args( $self->split_like_shell( $options{'*'} || '' ) );
Condition0%0/2
$options{'*'} || ''
l!l
00
MC/DC0%0/1
$options{'*'} || ''
$options{'*'}
Truth table0%0/2
A
A= $options{'*'}
Aresult
11
00
2365  
2366 # let fakeinstall act like install if not provided
2367 0 ▶ if ( $action eq 'fakeinstall' && ! exists $options{fakeinstall} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "fakeinstall" and not exists $options{"fakeinstall"}) 0 0 0
Condition0%0/3
$action eq "fakeinstall" and not exists $options{"fakeinstall"}
!ll&&!rl&&r
000
MC/DC0%0/2
$action eq "fakeinstall" and not exists $options{"fakeinstall"}
$action eq "fakeinstall" not exists $options{"fakeinstall"}
Truth table0%0/3
A and not(B)
A= $action eq "fakeinstall"B= not exists $options{"fakeinstall"}
ABresult
0X0
100
111
2368 0 $action = 'install';
2369 }
2370 my ($action_opts) =
2371 0 ▶ $self->read_args( $self->split_like_shell( $options{$action} || '' ) );
Condition0%0/2
$options{$action} || ''
l!l
00
MC/DC0%0/1
$options{$action} || ''
$options{$action}
Truth table0%0/2
A
A= $options{$action}
Aresult
11
00
2372  
2373 # specific $action options take priority over global options '*'
2374 0 return $self->_merge_arglist( $action_opts, $global_opts );
2375 }
2376  
2377 # merge the relevant options in ~/.modulebuildrc into Module::Build's
2378 # option list where they do not conflict with commandline options.
2379 448 ▶sub merge_modulebuildrc {
Subroutine merge_modulebuildrc: called CC=3 SCAR=11.0
Pod undocumented
2380 448 my( $self, $action, %cmdline_opts ) = @_;
2381 448 ▶ my %rc_opts = $self->read_modulebuildrc( $action || $self->{action} || 'build' );
Condition100%5/5
$action || $self->{'action'} || 'build'
l!l
81367
$action or $self->{"action"}
l!l&&r!l&&!r
180367
MC/DC100%2/2
$action || $self->{'action'} || 'build'
$action $self->{"action"}
Truth table100%3/3
A or B
A= $actionB= $self->{"action"}
ABresult
1X1
011
000
2382 448 my %new_opts = $self->_merge_arglist( \%cmdline_opts, \%rc_opts );
2383 448 $self->merge_args( $action, %new_opts );
2384 }
2385  
2386 896 ▶sub merge_args {
Subroutine merge_args: called CC=10 SCAR=23.0
Pod undocumented
2387 896 my ($self, $action, %args) = @_;
2388 896 ▶ $self->{action} = $action if defined $action;
Branch: 1 branch
BranchTrueFalseTotal
if defined $action 2 894 896
2389  
2390 896 my %additive = map { $_ => 1 } $self->hash_properties;
2391  
2392 # Extract our 'properties' from $cmd_args, the rest are put in 'args'.
2393 896 ▶ while (my ($key, $val) = each %args) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 930 896 1826
2394 930 ▶ $self->{phash}{runtime_params}->access( $key => $val )
Branch: 1 branch
BranchTrueFalseTotal
if $self->valid_property($key) 14 916 930
2395 if $self->valid_property($key);
2396  
2397 930 ▶ if ($key eq 'config') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq 'config') { } 2 928 930
2398 2 $self->config($_ => $val->{$_}) foreach keys %$val;
2399 } else {
2400 my $add_to = $additive{$key} ? $self->{properties}{$key} :
2401 $self->valid_property($key) ? $self->{properties} :
2402 928 ▶ $self->{args} ;
Branch: 2 branches
BranchTrueFalseTotal
$additive{$key} ? : 2 926 928
$self->valid_property($key) ? : 10 916 926
2403  
2404 928 ▶ if ($additive{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($additive{$key}) { } 2 926 928
2405 2 $add_to->{$_} = $val->{$_} foreach keys %$val;
2406 } else {
2407 926 $add_to->{$key} = $val;
2408 }
2409 }
2410 }
2411 }
2412  
2413 448 ▶sub cull_args {
Subroutine cull_args: called CC=2 SCAR=6.9
Pod undocumented
2414 448 my $self = shift;
2415 448 my @arg_list = @_;
2416 unshift @arg_list, $self->split_like_shell($ENV{PERL_MB_OPT})
2417 448 ▶ if $ENV{PERL_MB_OPT};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PERL_MB_OPT"} 1 447 448
2418 448 my ($args, $action) = $self->read_args(@arg_list);
2419 448 $self->merge_args($action, %$args);
2420 448 $self->merge_modulebuildrc( $action, %$args );
2421 }
2422  
2423 181 ▶sub super_classes {
Subroutine super_classes: called CC=4 SCAR=13.9
Pod undocumented
2424 181 my ($self, $class, $seen) = @_;
2425 181 ▶ $class ||= ref($self) || $self;
Condition66%4/6
$class ||= ref $self || $self
l!l&&r!l&&!r
141400
ref $self || $self
l!l&&r!l&&!r
28120
MC/DC0%0/3
$class ||= ref $self || $self
$class ref $self $self
Truth table0%0/4
A ||= B || C
A= $classB= ref $selfC= $self
ABCresult
1XX1
01X1
0011
0000
2426 181 ▶ $seen ||= {};
Condition100%2/2
$seen ||= {}
l!l
14140
MC/DC100%1/1
$seen ||= {}
$seen
Truth table100%2/2
A
A= $seen
Aresult
11
00
2427  
2428 297 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
2429 181 my @super = grep {not $seen->{$_}++} $class, @{ $class . '::ISA' };
2430 181 return @super, map {$self->super_classes($_,$seen)} @super;
2431 }
2432  
2433 27 ▶sub known_actions {
Subroutine known_actions: called CC=5 SCAR=16.1
Pod undocumented
2434 27 my ($self) = @_;
2435  
2436 27 my %actions;
2437 297 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
2438  
2439 27 foreach my $class ($self->super_classes) {
2440 92 foreach ( keys %{ $class . '::' } ) {
2441 12635 ▶ $actions{$1}++ if /^ACTION_(\w+)/;
Branch: 1 branch
BranchTrueFalseTotal
if /^ACTION_(\w+)/ 1097 11538 12635
2442 }
2443 }
2444  
2445 27 ▶ return wantarray ? sort keys %actions : \%actions;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 12 15 27
2446 }
2447  
2448 15 ▶sub get_action_docs {
Subroutine get_action_docs: called CC=21 SCAR=30.9
Pod undocumented
2449 15 my ($self, $action) = @_;
2450 15 my $actions = $self->known_actions;
2451 15 ▶ die "No known action '$action'" unless $actions->{$action};
Branch: 1 branch
BranchTrueFalseTotal
unless $actions->{$action} 2 13 15
2452  
2453 13 my ($files_found, @docs) = (0);
2454 13 foreach my $class ($self->super_classes) {
2455 49 (my $file = $class) =~ s{::}{/}g;
2456 # NOTE: silently skipping relative paths if any chdir() happened
2457 49 ▶ $file = $INC{$file . '.pm'} or next;
Branch: 1 branch
BranchTrueFalseTotal
$file = $INC{$file . '.pm'} or next 49 0 49
2458 49 ▶ open(my $fh, '<', $file) or next;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or next 49 0 49
2459 49 $files_found++;
2460  
2461 # Code below modified from /usr/bin/perldoc
2462  
2463 # Skip to ACTIONS section
2464 49 local $_;
2465 49 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 77491 28 77519
2466 77491 ▶ last if /^=head1 ACTIONS\s/;
Branch: 1 branch
BranchTrueFalseTotal
if /^=head1 ACTIONS\s/ 21 77470 77491
2467 }
2468  
2469 # Look for our action and determine the style
2470 49 my $style;
2471 49 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 5671 28 5699
2472 5671 ▶ last if /^=head1 /;
Branch: 1 branch
BranchTrueFalseTotal
if /^=head1 / 10 5661 5671
2473  
2474 # only item and head2 are allowed (3&4 are not in 5.005)
2475 5661 ▶ if(/^=(item|head2)\s+\Q$action\E\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^=(item|head2)\s+\Q$action\E\b/) 11 5650 5661
2476 11 $style = $1;
2477 11 push @docs, $_;
2478 11 last;
2479 }
2480 }
2481 49 ▶ $style or next; # not here
Branch: 1 branch
BranchTrueFalseTotal
$style or next 11 38 49
2482  
2483 # and the content
2484 11 ▶ if($style eq 'item') {
Branch: 1 branch
BranchTrueFalseTotal
if ($style eq 'item') { } 8 3 11
2485 8 my ($found, $inlist) = (0, 0);
2486 8 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 64 0 64
2487 64 ▶ if (/^=(item|back)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^=(item|back)/) 8 56 64
2488 8 ▶ last unless $inlist;
Branch: 1 branch
BranchTrueFalseTotal
unless $inlist 8 0 8
2489 }
2490 56 push @docs, $_;
2491 56 ▶ ++$inlist if /^=over/;
Branch: 1 branch
BranchTrueFalseTotal
if /^=over/ 0 56 56
2492 56 ▶ --$inlist if /^=back/;
Branch: 1 branch
BranchTrueFalseTotal
if /^=back/ 0 56 56
2493 }
2494 }
2495 else { # head2 style
2496 # stop at anything equal or greater than the found level
2497 3 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 18 0 18
2498 18 ▶ last if(/^=(?:head[12]|cut)/);
Branch: 1 branch
BranchTrueFalseTotal
if /^=(?:head[12]|cut)/ 3 15 18
2499 15 push @docs, $_;
2500 }
2501 }
2502 # TODO maybe disallow overriding just pod for an action
2503 # TODO and possibly: @docs and last;
2504 }
2505  
2506 13 ▶ unless ($files_found) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($files_found) 0 13 13
2507 0 $@ = "Couldn't find any documentation to search";
2508 0 return;
2509 }
2510 13 ▶ unless (@docs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@docs) 3 10 13
2511 3 $@ = "Couldn't find any docs for action '$action'";
2512 3 return;
2513 }
2514  
2515 10 return join '', @docs;
2516 }
2517  
2518 0 ▶sub ACTION_prereq_report {
Subroutine ACTION_prereq_report: not called CC=1 SCAR=6.9
Pod undocumented
2519 0 my $self = shift;
2520 0 $self->log_info( $self->prereq_report );
2521 }
2522  
2523 0 ▶sub ACTION_prereq_data {
Subroutine ACTION_prereq_data: not called CC=1 SCAR=6.9
Pod undocumented
2524 0 my $self = shift;
2525 0 $self->log_info( Module::Build::Dumper->_data_dump( $self->prereq_data ) );
2526 }
2527  
2528 0 ▶sub prereq_data {
Subroutine prereq_data: not called CC=1 SCAR=6.9
Pod undocumented
2529 0 my $self = shift;
2530 0 my @types = ('configure_requires', @{ $self->prereq_action_types } );
2531 0 my $info = { map { $_ => $self->$_() } grep { %{$self->$_()} } @types };
2532 0 return $info;
2533 }
2534  
2535 0 ▶sub prereq_report {
Subroutine prereq_report: not called CC=12 SCAR=50.5
Pod undocumented
2536 0 my $self = shift;
2537 0 my $info = $self->prereq_data;
2538  
2539 0 my $output = '';
2540 0 foreach my $type (sort keys %$info) {
2541 0 my $prereqs = $info->{$type};
2542 0 $output .= "\n$type:\n";
2543 0 my $mod_len = 2;
2544 0 my $ver_len = 4;
2545 0 my %mods;
2546 0 foreach my $modname (sort keys %$prereqs) {
2547 0 my $spec = $prereqs->{$modname};
2548 0 my $len = length $modname;
2549 0 ▶ $mod_len = $len if $len > $mod_len;
Branch: 1 branch
BranchTrueFalseTotal
if $len > $mod_len 0 0 0
2550 0 ▶ $spec ||= '0';
Condition0%0/2
$spec ||= 0
l!l
00
MC/DC0%0/1
$spec ||= 0
$spec
Truth table0%0/2
A
A= $spec
Aresult
11
00
2551 0 $len = length $spec;
2552 0 ▶ $ver_len = $len if $len > $ver_len;
Branch: 1 branch
BranchTrueFalseTotal
if $len > $ver_len 0 0 0
2553  
2554 0 my $mod = $self->check_installed_status($modname, $spec);
2555 0 $mod->{name} = $modname;
2556 0 ▶ $mod->{ok} ||= 0;
Condition0%0/2
$mod->{"ok"} ||= 0
l!l
00
MC/DC0%0/1
$mod->{"ok"} ||= 0
$mod->{"ok"}
Truth table0%0/2
A
A= $mod->{"ok"}
Aresult
11
00
2557 0 ▶ $mod->{ok} = ! $mod->{ok} if $type =~ /^(\w+_)?conflicts$/;
Branch: 1 branch
BranchTrueFalseTotal
if $type =~ /^(\w+_)?conflicts$/ 0 0 0
2558  
2559 0 $mods{lc $modname} = $mod;
2560 }
2561  
2562 0 my $space = q{ } x ($mod_len - 3);
2563 0 my $vspace = q{ } x ($ver_len - 3);
2564 0 my $sline = q{-} x ($mod_len - 3);
2565 0 my $vline = q{-} x ($ver_len - 3);
2566 0 ▶ my $disposition = ($type =~ /^(\w+_)?conflicts$/) ?
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /^(\w+_)?conflicts$/ ? : 0 0 0
2567 'Clash' : 'Need';
2568 0 $output .=
2569 " Module $space $disposition $vspace Have\n".
2570 " ------$sline+------$vline-+----------\n";
2571  
2572  
2573 0 for my $k (sort keys %mods) {
2574 0 my $mod = $mods{$k};
2575 0 my $space = q{ } x ($mod_len - length $k);
2576 0 my $vspace = q{ } x ($ver_len - length $mod->{need});
2577 0 ▶ my $f = $mod->{ok} ? ' ' : '!';
Branch: 1 branch
BranchTrueFalseTotal
$mod->{'ok'} ? : 0 0 0
2578 $output .=
2579 " $f $mod->{name} $space $mod->{need} $vspace ".
2580 0 ▶ (defined($mod->{have}) ? $mod->{have} : "")."\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $mod->{'have'} ? : 0 0 0
2581 }
2582 }
2583 0 return $output;
2584 }
2585  
2586 0 ▶sub ACTION_help {
Subroutine ACTION_help: not called CC=3 SCAR=24.8
Pod undocumented
2587 0 my ($self) = @_;
2588 0 my $actions = $self->known_actions;
2589  
2590 0 ▶ if (@{$self->{args}{ARGV}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"args"}{"ARGV"};}) 0 0 0
2591 0 my $msg = eval {$self->get_action_docs($self->{args}{ARGV}[0], $actions)};
2592 0 ▶ print $@ ? "$@\n" : $msg;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 0 0
2593 0 return;
2594 }
2595  
2596 0 print <<EOF;
2597  
2598 Usage: $0 <action> --arg1=value --arg2=value ...
2599 Example: $0 test --verbose=1
2600  
2601 Actions defined:
2602 EOF
2603  
2604 0 print $self->_action_listing($actions);
2605  
2606 0 print "\nRun `Build help <action>` for details on an individual action.\n";
2607 0 print "See `perldoc Module::Build` for complete documentation.\n";
2608 }
2609  
2610 0 ▶sub _action_listing {
Subroutine _action_listing: not called CC=3 SCAR=24.8
2611 0 my ($self, $actions) = @_;
2612  
2613 # Flow down columns, not across rows
2614 0 my @actions = sort keys %$actions;
2615 0 @actions = map $actions[($_ + ($_ % 2) * @actions) / 2], 0..$#actions;
2616  
2617 0 my $out = '';
2618 0 ▶ while (my ($one, $two) = splice @actions, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@actions, 0, 2)) 0 0 0
2619 0 ▶ $out .= sprintf(" %-12s %-12s\n", $one, $two||'');
Condition0%0/2
$two || ''
l!l
00
MC/DC0%0/1
$two || ''
$two
Truth table0%0/2
A
A= $two
Aresult
11
00
2620 }
2621 0 $out =~ s{\s*$}{}mg; # remove trailing spaces
2622 0 return $out;
2623 }
2624  
2625 0 ▶sub ACTION_retest {
Subroutine ACTION_retest: not called CC=3 SCAR=24.8
Pod undocumented
2626 0 my ($self) = @_;
2627  
2628 # Protect others against our @INC changes
2629 0 local @INC = @INC;
2630  
2631 # Filter out nonsensical @INC entries - some versions of
2632 # Test::Harness will really explode the number of entries here
2633 0 ▶ @INC = grep {ref() || -d} @INC if @INC > 100;
Branch: 1 branch
BranchTrueFalseTotal
if @INC > 100 0 0 0
Condition0%0/3
ref $_ || -d $_
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_ || -d $_
ref $_ -d $_
Truth table0%0/3
A || B
A= ref $_B= -d $_
ABresult
1X1
011
000
2634  
2635 0 $self->do_tests;
2636 }
2637  
2638 2 ▶sub ACTION_testall {
Subroutine ACTION_testall: called CC=2 SCAR=6.9
Pod undocumented
2639 2 my ($self) = @_;
2640  
2641 2 my @types;
2642 2 for my $action (grep { $_ ne 'all' } $self->get_test_types) {
2643 # XXX We can't just dispatch because we get multiple summaries but
2644 # we'll need to dispatch to support custom setup/teardown in the
2645 # action. To support that, we'll need to call something besides
2646 # Harness::runtests() because we'll need to collect the results in
2647 # parts, then run the summary.
2648 4 push(@types, $action);
2649 #$self->_call_action( "test$action" );
2650 }
2651 2 $self->generic_test(types => ['default', @types]);
2652 }
2653  
2654 2 ▶sub get_test_types {
Subroutine get_test_types: called CC=3 SCAR=11.7
Pod undocumented
2655 2 my ($self) = @_;
2656  
2657 2 my $t = $self->{properties}->{test_types};
2658 2 ▶ return ( defined $t ? ( wantarray ? sort keys %$t : keys %$t ) : () );
Branch: 2 branches
BranchTrueFalseTotal
defined $t ? : 2 0 2
wantarray ? : 2 0 2
2659 }
2660  
2661  
2662 24 ▶sub ACTION_test {
Subroutine ACTION_test: called CC=1 SCAR=0.0
Pod undocumented
2663 24 my ($self) = @_;
2664 24 $self->generic_test(type => 'default');
2665 }
2666  
2667 33 ▶sub generic_test {
Subroutine generic_test: called CC=11 SCAR=25.0
Pod undocumented
2668 33 my $self = shift;
2669 33 ▶ (@_ % 2) and croak('Odd number of elements in argument hash');
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 and croak("Odd number of elements in argument hash") 0 33 33
2670 33 my %args = @_;
2671  
2672 33 my $p = $self->{properties};
2673  
2674 my @types = (
2675 (exists($args{type}) ? $args{type} : ()),
2676 33 ▶ (exists($args{types}) ? @{$args{types}} : ()),
Branch: 2 branches
BranchTrueFalseTotal
exists $args{'type'} ? : 31 2 33
exists $args{'types'} ? : 2 31 33
2677 );
2678 33 ▶ @types or croak "need some types of tests to check";
Branch: 1 branch
BranchTrueFalseTotal
@types or croak("need some types of tests to check") 33 0 33
2679  
2680 my %test_types = (
2681 default => $p->{test_file_exts},
2682 33 ▶ (defined($p->{test_types}) ? %{$p->{test_types}} : ()),
Branch: 1 branch
BranchTrueFalseTotal
defined $p->{'test_types'} ? : 9 24 33
2683 );
2684  
2685 33 for my $type (@types) {
2686 croak "$type not defined in test_types!"
2687 37 ▶ unless defined $test_types{ $type };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $test_types{$type} 0 37 37
2688 }
2689  
2690 # we use local here because it ends up two method calls deep
2691 33 ▶ local $p->{test_file_exts} = [ map { ref $_ ? @$_ : $_ } @test_types{@types} ];
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 26 11 37
2692 33 $self->depends_on('code');
2693  
2694 # Protect others against our @INC changes
2695 33 local @INC = @INC;
2696  
2697 # Make sure we test the module in blib/
2698 unshift @INC, (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'),
2699 33 File::Spec->catdir($p->{base_dir}, $self->blib, 'arch'));
2700  
2701 # Filter out nonsensical @INC entries - some versions of
2702 # Test::Harness will really explode the number of entries here
2703 0 ▶ @INC = grep {ref() || -d} @INC if @INC > 100;
Branch: 1 branch
BranchTrueFalseTotal
if @INC > 100 0 33 33
Condition0%0/3
ref $_ || -d $_
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_ || -d $_
ref $_ -d $_
Truth table0%0/3
A || B
A= ref $_B= -d $_
ABresult
1X1
011
000
2704  
2705 33 $self->do_tests;
2706 }
2707  
2708 # Test::Harness dies on failure but TAP::Harness does not, so we must
2709 # die if running under TAP::Harness
2710 33 ▶sub do_tests {
Subroutine do_tests: called CC=6 SCAR=19.3
Pod undocumented
2711 33 my $self = shift;
2712  
2713 33 my $tests = $self->find_test_files;
2714  
2715 33 local $ENV{PERL_DL_NONLAZY} = 1;
2716  
2717 33 ▶ if(@$tests) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$tests) { } 33 0 33
2718 33 my $args = $self->tap_harness_args;
2719 33 ▶ if($self->use_tap_harness or ($args and %$args)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->use_tap_harness or $args and %$args) { } 5 28 33
Condition50%3/6
$self->use_tap_harness or $args and %$args
l!l&&r!l&&!r
5028
$args and %$args
!ll&&!rl&&r
0280
MC/DC33%1/3
$self->use_tap_harness or $args and %$args
$self->use_tap_harness $args %$args
Truth table50%2/4
A or B and C
A= $self->use_tap_harnessB= $argsC= %$args
ABCresult
1XX1
0111
00X0
0100
2720 5 my $aggregate = $self->run_tap_harness($tests);
2721 5 ▶ if ( $aggregate->has_errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aggregate->has_errors) 0 5 5
2722 0 die "Errors in testing. Cannot continue.\n";
2723 }
2724 }
2725 else {
2726 28 $self->run_test_harness($tests);
2727 }
2728 }
2729 else {
2730 0 $self->log_info("No tests defined.\n");
2731 }
2732  
2733 33 $self->run_visual_script;
2734 }
2735  
2736 5 ▶sub run_tap_harness {
Subroutine run_tap_harness: called CC=1 SCAR=0.0
Pod undocumented
2737 5 my ($self, $tests) = @_;
2738  
2739 5 require TAP::Harness::Env;
2740  
2741 # TODO allow the test @INC to be set via our API?
2742  
2743 my $aggregate = TAP::Harness::Env->create({
2744 lib => [@INC],
2745 verbosity => $self->{properties}{verbose},
2746 switches => [ $self->harness_switches ],
2747 5 %{ $self->tap_harness_args },
2748 })->runtests(@$tests);
2749  
2750 5 return $aggregate;
2751 }
2752  
2753 30 ▶sub run_test_harness {
Subroutine run_test_harness: called CC=2 SCAR=6.9
Pod undocumented
2754 30 my ($self, $tests) = @_;
2755 30 require Test::Harness;
2756  
2757 30 ▶ local $Test::Harness::verbose = $self->verbose || 0;
Condition100%2/2
$self->verbose || 0
l!l
1416
MC/DC100%1/1
$self->verbose || 0
$self->verbose
Truth table100%2/2
A
A= $self->verbose
Aresult
11
00
2758 30 local $Test::Harness::switches = join ' ', $self->harness_switches;
2759  
2760 30 Test::Harness::runtests(@$tests);
2761 }
2762  
2763 33 ▶sub run_visual_script {
Subroutine run_visual_script: called CC=2 SCAR=7.2
Pod undocumented
2764 33 my $self = shift;
2765 # This will get run and the user will see the output. It doesn't
2766 # emit Test::Harness-style output.
2767 33 ▶ $self->run_perl_script('visual.pl', '-Mblib='.$self->blib)
Branch: 1 branch
BranchTrueFalseTotal
if -e "visual.pl" 0 33 33
2768 if -e 'visual.pl';
2769 }
2770  
2771 33 ▶sub harness_switches {
Subroutine harness_switches: called CC=3 SCAR=11.3
Pod undocumented
2772 33 my $self = shift;
2773 33 my @res;
2774 33 ▶ push @res, qw(-w -d) if $self->{properties}{debugger};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"properties"}{"debugger"} 0 33 33
2775 33 ▶ push @res, '-MDevel::Cover' if $self->{properties}{cover};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"properties"}{"cover"} 0 33 33
2776 33 return @res;
2777 }
2778  
2779 4 ▶sub test_files {
Subroutine test_files: called CC=3 SCAR=11.0
Pod undocumented
2780 4 my $self = shift;
2781 4 my $p = $self->{properties};
2782 4 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 2 4
2783 2 ▶ return $p->{test_files} = (@_ == 1 ? shift : [@_]);
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 1 1 2
2784 }
2785 2 return $self->find_test_files;
2786 }
2787  
2788 34 ▶sub expand_test_dir {
Subroutine expand_test_dir: called CC=2 SCAR=6.9
Pod undocumented
2789 34 my ($self, $dir) = @_;
2790 34 my $exts = $self->{properties}{test_file_exts};
2791  
2792 34 ▶ return sort map { @{$self->rscan_dir($dir, qr{^[^.].*\Q$_\E$})} } @$exts
Branch: 1 branch
BranchTrueFalseTotal
if $self->recursive_test_files 4 30 34
2793 if $self->recursive_test_files;
2794  
2795 30 return sort map { glob File::Spec->catfile($dir, "*$_") } @$exts;
2796 }
2797  
2798 0 ▶sub ACTION_testdb {
Subroutine ACTION_testdb: not called CC=1 SCAR=6.9
Pod undocumented
2799 0 my ($self) = @_;
2800 0 local $self->{properties}{debugger} = 1;
2801 0 $self->depends_on('test');
2802 }
2803  
2804 0 ▶sub ACTION_testcover {
Subroutine ACTION_testcover: not called CC=5 SCAR=34.0
Pod undocumented
2805 0 my ($self) = @_;
2806  
2807 0 ▶ unless (Module::Metadata->find_module_by_name('Devel::Cover')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("Module::Metadata"->find_module_by_name("Devel::Cover")) 0 0 0
2808 0 warn("Cannot run testcover action unless Devel::Cover is installed.\n");
2809 0 return;
2810 }
2811  
2812 0 $self->add_to_cleanup('coverage', 'cover_db');
2813 0 $self->depends_on('code');
2814  
2815 # See whether any of the *.pm files have changed since last time
2816 # testcover was run. If so, start over.
2817 0 ▶ if (-e 'cover_db') {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "cover_db") 0 0 0
2818 0 my $pm_files = $self->rscan_dir
2819 (File::Spec->catdir($self->blib, 'lib'), $self->file_qr('\.pm$') );
2820 0 ▶ my $cover_files = $self->rscan_dir('cover_db', sub {-f $_ and not /\.html$/});
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
-f $_ and not /\.html$/ 0 0 0
2821  
2822 0 ▶ $self->do_system(qw(cover -delete))
Branch: 1 branch
BranchTrueFalseTotal
unless $self->up_to_date($pm_files, $cover_files) and $self->up_to_date($self->test_files, $cover_files) 0 0 0
Condition0%0/3
$self->up_to_date($pm_files, $cover_files) and $self->up_to_date($self->test_files, $cover_files)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->up_to_date($pm_files, $cover_files) and $self->up_to_date($self->test_files, $cover_files)
$self->up_to_date($pm_files, $cover_files) $self->up_to_date($self->test_files, $cover_files)
Truth table0%0/3
A and B
A= $self->up_to_date($pm_files, $cover_files)B= $self->up_to_date($self->test_files, $cover_files)
ABresult
0X0
100
111
2823 unless $self->up_to_date($pm_files, $cover_files)
2824 && $self->up_to_date($self->test_files, $cover_files);
2825 }
2826  
2827 0 local $self->{properties}{cover} = 1;
2828 0 $self->depends_on('test');
2829 0 $self->do_system('cover');
2830 }
2831  
2832 65 ▶sub ACTION_code {
Subroutine ACTION_code: called CC=6 SCAR=18.6
Pod undocumented
2833 65 my ($self) = @_;
2834  
2835 # All installable stuff gets created in blib/ .
2836 # Create blib/arch to keep blib.pm happy
2837 65 my $blib = $self->blib;
2838 65 $self->add_to_cleanup($blib);
2839 65 File::Path::mkpath( File::Spec->catdir($blib, 'arch') );
2840  
2841 65 ▶ if (my $split = $self->autosplit) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $split = $self->autosplit) 0 65 65
2842 0 ▶ $self->autosplit_file($_, $blib) for ref($split) ? @$split : ($split);
Branch: 1 branch
BranchTrueFalseTotal
ref $split ? : 0 0 0
2843 }
2844  
2845 65 foreach my $element (@{$self->build_elements}) {
2846 447 my $method = "process_${element}_files";
2847 447 ▶ $method = "process_files_by_extension" unless $self->can($method);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can($method) 1 446 447
2848 447 $self->$method($element);
2849 }
2850  
2851 62 $self->depends_on('config_data');
2852 }
2853  
2854 30 ▶sub ACTION_build {
Subroutine ACTION_build: called CC=1 SCAR=0.0
Pod undocumented
2855 30 my $self = shift;
2856 30 $self->log_info("Building " . $self->dist_name . "\n");
2857 30 $self->depends_on('code');
2858 27 $self->depends_on('docs');
2859 }
2860  
2861 128 ▶sub process_files_by_extension {
Subroutine process_files_by_extension: called CC=3 SCAR=11.0
Pod undocumented
2862 128 my ($self, $ext) = @_;
2863  
2864 128 my $method = "find_${ext}_files";
2865 128 ▶ my $files = $self->can($method) ? $self->$method() : $self->_find_file_by_type($ext, 'lib');
Branch: 1 branch
BranchTrueFalseTotal
$self->can($method) ? : 127 1 128
2866  
2867 128 foreach my $file (sort keys %$files) {
2868 96 $self->copy_if_modified(from => $file, to => File::Spec->catfile($self->blib, $files->{$file}) );
2869 }
2870 }
2871  
2872 65 ▶sub process_support_files {
Subroutine process_support_files: called CC=7 SCAR=36.3
Pod undocumented
2873 65 my $self = shift;
2874 65 my $p = $self->{properties};
2875 65 ▶ return unless $p->{c_source};
Branch: 1 branch
BranchTrueFalseTotal
unless $p->{"c_source"} 65 0 65
2876 0 ▶ return if $self->pureperl_only && $self->allow_pureperl;
Branch: 1 branch
BranchTrueFalseTotal
if $self->pureperl_only and $self->allow_pureperl 0 0 0
Condition0%0/3
$self->pureperl_only and $self->allow_pureperl
!ll&&!rl&&r
000
MC/DC0%0/2
$self->pureperl_only and $self->allow_pureperl
$self->pureperl_only $self->allow_pureperl
Truth table0%0/3
A and B
A= $self->pureperl_onlyB= $self->allow_pureperl
ABresult
0X0
100
111
2877  
2878 0 my $files;
2879 0 ▶ if (ref($p->{c_source}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $p->{'c_source'} eq 'ARRAY') { } 0 0 0
2880 0 push @{$p->{include_dirs}}, @{$p->{c_source}};
2881 0 for my $path (@{$p->{c_source}}) {
2882 0 push @$files, @{ $self->rscan_dir($path, $self->file_qr('\.c(c|p|pp|xx|\+\+)?$')) };
2883 }
2884 } else {
2885 0 push @{$p->{include_dirs}}, $p->{c_source};
2886 0 $files = $self->rscan_dir($p->{c_source}, $self->file_qr('\.c(c|p|pp|xx|\+\+)?$'));
2887 }
2888  
2889 0 foreach my $file (@$files) {
2890 0 push @{$p->{objects}}, $self->compile_c($file);
2891 }
2892 }
2893  
2894 62 ▶sub process_share_dir_files {
Subroutine process_share_dir_files: called CC=3 SCAR=11.0
Pod undocumented
2895 62 my $self = shift;
2896 62 my $files = $self->_find_share_dir_files;
2897 62 ▶ return unless $files;
Branch: 1 branch
BranchTrueFalseTotal
unless $files 60 2 62
2898  
2899 # root for all File::ShareDir paths
2900 2 my $share_prefix = File::Spec->catdir($self->blib, qw/lib auto share/);
2901  
2902 # copy all share files to blib
2903 2 foreach my $file (sort keys %$files) {
2904 $self->copy_if_modified(
2905 8 from => $file, to => File::Spec->catfile( $share_prefix, $files->{$file} )
2906 );
2907 }
2908 }
2909  
2910 63 ▶sub _find_share_dir_files {
Subroutine _find_share_dir_files: called CC=5 SCAR=16.1
2911 63 my $self = shift;
2912 63 my $share_dir = $self->share_dir;
2913 63 ▶ return unless $share_dir;
Branch: 1 branch
BranchTrueFalseTotal
unless $share_dir 60 3 63
2914  
2915 3 my @file_map;
2916 3 ▶ if ( $share_dir->{dist} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($share_dir->{"dist"}) 3 0 3
2917 3 my $prefix = "dist/".$self->dist_name;
2918 3 push @file_map, $self->_share_dir_map( $prefix, $share_dir->{dist} );
2919 }
2920  
2921 3 ▶ if ( $share_dir->{module} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($share_dir->{"module"}) 3 0 3
2922 3 for my $mod ( sort keys %{ $share_dir->{module} } ) {
2923 3 (my $altmod = $mod) =~ s{::}{-}g;
2924 3 my $prefix = "module/$altmod";
2925 3 push @file_map, $self->_share_dir_map($prefix, $share_dir->{module}{$mod});
2926 }
2927 }
2928  
2929 3 return { @file_map };
2930 }
2931  
2932 6 ▶sub _share_dir_map {
Subroutine _share_dir_map: called CC=3 SCAR=11.0
2933 6 my ($self, $prefix, $list) = @_;
2934 6 my %files;
2935 6 for my $dir ( @$list ) {
2936 6 ▶ for my $f ( @{ $self->rscan_dir( $dir, sub {-f} )} ) {
Subroutine __ANON__: called CC=1 SCAR=0.0
2937 12 $f =~ s{\A.*?\Q$dir\E/}{};
2938 12 $files{"$dir/$f"} = "$prefix/$f";
2939 }
2940 }
2941 6 return %files;
2942 }
2943  
2944 65 ▶sub process_PL_files {
Subroutine process_PL_files: called CC=4 SCAR=14.1
Pod undocumented
2945 65 my ($self) = @_;
2946 65 my $files = $self->find_PL_files;
2947  
2948 65 foreach my $file (sort keys %$files) {
2949 6 my $to = $files->{$file};
2950 6 ▶ unless ($self->up_to_date( $file, $to )) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->up_to_date($file, $to)) 6 0 6
2951 6 ▶ $self->run_perl_script($file, [], [@$to]) or die "$file failed";
Branch: 1 branch
BranchTrueFalseTotal
$self->run_perl_script($file, [], [@$to]) or die "$file failed" 6 0 6
2952 6 $self->add_to_cleanup(@$to);
2953 }
2954 }
2955 }
2956  
2957 65 ▶sub process_xs_files {
Subroutine process_xs_files: called CC=7 SCAR=19.5
Pod undocumented
2958 65 my $self = shift;
2959 65 ▶ return if $self->pureperl_only && $self->allow_pureperl;
Branch: 1 branch
BranchTrueFalseTotal
if $self->pureperl_only and $self->allow_pureperl 2 63 65
Condition100%3/3
$self->pureperl_only and $self->allow_pureperl
!ll&&!rl&&r
6122
MC/DC100%2/2
$self->pureperl_only and $self->allow_pureperl
$self->pureperl_only $self->allow_pureperl
Truth table100%3/3
A and B
A= $self->pureperl_onlyB= $self->allow_pureperl
ABresult
0X0
100
111
2960 63 my $files = $self->find_xs_files;
2961 63 ▶ croak 'Can\'t build xs files under --pureperl-only' if %$files && $self->pureperl_only;
Branch: 1 branch
BranchTrueFalseTotal
if %$files and $self->pureperl_only 2 61 63
Condition100%3/3
%$files and $self->pureperl_only
!ll&&!rl&&r
42192
MC/DC100%2/2
%$files and $self->pureperl_only
%$files $self->pureperl_only
Truth table100%3/3
A and B
A= %$filesB= $self->pureperl_only
ABresult
0X0
100
111
2962 61 foreach my $from (sort keys %$files) {
2963 19 my $to = $files->{$from};
2964 19 ▶ unless ($from eq $to) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($from eq $to) 2 17 19
2965 2 $self->add_to_cleanup($to);
2966 2 $self->copy_if_modified( from => $from, to => $to );
2967 }
2968 19 $self->process_xs($to);
2969 }
2970 }
2971  
2972 62 ▶sub process_pod_files { shift()->process_files_by_extension(shift()) }
Subroutine process_pod_files: called CC=1 SCAR=0.0
Pod undocumented
2973 65 ▶sub process_pm_files { shift()->process_files_by_extension(shift()) }
Subroutine process_pm_files: called CC=1 SCAR=0.0
Pod undocumented
2974  
2975 62 ▶sub process_script_files {
Subroutine process_script_files: called CC=5 SCAR=16.1
Pod undocumented
2976 62 my $self = shift;
2977 62 my $files = $self->find_script_files;
2978 62 ▶ return unless keys %$files;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$files 47 15 62
2979  
2980 15 my $script_dir = File::Spec->catdir($self->blib, 'script');
2981 15 File::Path::mkpath( $script_dir );
2982  
2983 15 foreach my $file (sort keys %$files) {
2984 18 ▶ my $result = $self->copy_if_modified($file, $script_dir, 'flatten') or next;
Branch: 1 branch
BranchTrueFalseTotal
my $result = $self->copy_if_modified($file, $script_dir, "flatten") or next 9 9 18
2985 9 ▶ $self->fix_shebang_line($result) unless $self->is_vmsish;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_vmsish 9 0 9
2986 9 $self->make_executable($result);
2987 }
2988 }
2989  
2990 65 ▶sub find_PL_files {
Subroutine find_PL_files: called CC=7 SCAR=19.9
Pod undocumented
2991 65 my $self = shift;
2992 65 ▶ if (my $files = $self->{properties}{PL_files}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $files = $self->{"properties"}{"PL_files"}) 3 62 65
2993 # 'PL_files' is given as a Unix file spec, so we localize_file_path().
2994  
2995 3 ▶ if (ref $files eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $files eq 'ARRAY') { } 0 3 3
elsif (ref $files eq 'HASH') { } 3 0 3
2996 0 return { map {$_, [/^(.*)\.PL$/]}
2997 map $self->localize_file_path($_),
2998 @$files };
2999  
3000 } elsif (ref $files eq 'HASH') {
3001 3 my %out;
3002 3 ▶ while (my ($file, $to) = each %$files) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$files) 5 3 8
3003 5 ▶ $out{ $self->localize_file_path($file) } = [ map $self->localize_file_path($_),
Branch: 1 branch
BranchTrueFalseTotal
ref $to ? : 1 4 5
3004 ref $to ? @$to : ($to) ];
3005 }
3006 3 return \%out;
3007  
3008 } else {
3009 0 die "'PL_files' must be a hash reference or array reference";
3010 }
3011 }
3012  
3013 62 ▶ return unless -d 'lib';
Branch: 1 branch
BranchTrueFalseTotal
unless -d "lib" 1 61 62
3014 return {
3015 1 map {$_, [/^(.*)\.PL$/i ]}
3016 61 @{ $self->rscan_dir('lib', $self->file_qr('\.PL$')) }
3017 };
3018 }
3019  
3020 84 ▶sub find_pm_files { shift->_find_file_by_type('pm', 'lib') }
Subroutine find_pm_files: called CC=1 SCAR=0.0
Pod undocumented
3021 62 ▶sub find_pod_files { shift->_find_file_by_type('pod', 'lib') }
Subroutine find_pod_files: called CC=1 SCAR=0.0
Pod undocumented
3022 148 ▶sub find_xs_files { shift->_find_file_by_type('xs', 'lib') }
Subroutine find_xs_files: called CC=1 SCAR=0.0
Pod undocumented
3023  
3024 62 ▶sub find_script_files {
Subroutine find_script_files: called CC=2 SCAR=7.4
Pod undocumented
3025 62 my $self = shift;
3026 62 ▶ if (my $files = $self->script_files) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $files = $self->script_files) 62 0 62
3027 # Always given as a Unix file spec. Values in the hash are
3028 # meaningless, but we preserve if present.
3029 62 return { map {$self->localize_file_path($_), $files->{$_}} keys %$files };
3030 }
3031  
3032 # No default location for script files
3033 0 return {};
3034 }
3035  
3036 35 ▶sub find_test_files {
Subroutine find_test_files: called CC=7 SCAR=20.1
Pod undocumented
3037 35 my $self = shift;
3038 35 my $p = $self->{properties};
3039  
3040 35 ▶ if (my $files = $p->{test_files}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $files = $p->{'test_files'}) { } 2 33 35
3041 2 ▶ $files = [sort keys %$files] if ref $files eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $files eq "HASH" 0 2 2
3042 2 ▶ $files = [map { -d $_ ? $self->expand_test_dir($_) : $_ }
Branch: 1 branch
BranchTrueFalseTotal
-d $_ ? : 1 3 4
3043 map glob,
3044 $self->split_like_shell($files)];
3045  
3046 # Always given as a Unix file spec.
3047 2 return [ map $self->localize_file_path($_), @$files ];
3048  
3049 } else {
3050 # Find all possible tests in t/ or test.pl
3051 33 my @tests;
3052 33 ▶ push @tests, 'test.pl' if -e 'test.pl';
Branch: 1 branch
BranchTrueFalseTotal
if -e "test.pl" 0 33 33
3053 33 ▶ push @tests, $self->expand_test_dir('t') if -e 't' and -d _;
Branch: 1 branch
BranchTrueFalseTotal
if -e "t" and -d _ 33 0 33
Condition33%1/3
-e "t" and -d _
!ll&&!rl&&r
0033
MC/DC0%0/2
-e "t" and -d _
-e "t" -d _
Truth table33%1/3
A and B
A= -e "t"B= -d _
ABresult
0X0
100
111
3054 33 return \@tests;
3055 }
3056 }
3057  
3058 298 ▶sub _find_file_by_type {
Subroutine _find_file_by_type: called CC=3 SCAR=11.0
3059 298 my ($self, $type, $dir) = @_;
3060  
3061 298 ▶ if (my $files = $self->{properties}{"${type}_files"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $files = $self->{"properties"}{"${type}_files"}) 5 293 298
3062 # Always given as a Unix file spec
3063 5 return { map $self->localize_file_path($_), %$files };
3064 }
3065  
3066 293 ▶ return {} unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 4 289 293
3067 136 return { map {$_, $_}
3068 map $self->localize_file_path($_),
3069 grep !/\.\#/,
3070 289 @{ $self->rscan_dir($dir, $self->file_qr("\\.$type\$")) } };
3071 }
3072  
3073 707 ▶sub localize_file_path {
Subroutine localize_file_path: called CC=1 SCAR=0.0
Pod undocumented
3074 707 my ($self, $path) = @_;
3075 707 return File::Spec->catfile( split m{/}, $path );
3076 }
3077  
3078 88 ▶sub localize_dir_path {
Subroutine localize_dir_path: called CC=1 SCAR=0.0
Pod undocumented
3079 88 my ($self, $path) = @_;
3080 88 return File::Spec->catdir( split m{/}, $path );
3081 }
3082  
3083 9 ▶sub fix_shebang_line { # Adapted from fixin() in ExtUtils::MM_Unix 1.35
Subroutine fix_shebang_line: called CC=12 SCAR=25.8
Pod undocumented
3084 9 my ($self, @files) = @_;
3085 9 ▶ my $c = ref($self) ? $self->{config} : 'Module::Build::Config';
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 9 0 9
3086  
3087 9 my ($does_shbang) = $c->get('sharpbang') =~ /^\s*\#\!/;
3088 9 for my $file (@files) {
3089 9 ▶ open(my $FIXIN, '<', $file) or die "Can't process '$file': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $FIXIN, "<", $file or die "Can't process '${file}': $!" 9 0 9
3090 9 local $/ = "\n";
3091 9 chomp(my $line = <$FIXIN>);
3092 9 ▶ next unless $line =~ s/^\s*\#!\s*//; # Not a shebang file.
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ s/^\s*\#!\s*// 2 7 9
3093  
3094 7 my ($cmd, $arg) = (split(' ', $line, 2), '');
3095 7 ▶ next unless $cmd =~ /perl/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmd =~ /perl/i 0 7 7
3096 7 my $interpreter = $self->{properties}{perl};
3097  
3098 7 $self->log_verbose("Changing sharpbang in $file to $interpreter\n");
3099 7 my $shb = '';
3100 7 ▶ $shb .= $c->get('sharpbang')."$interpreter $arg\n" if $does_shbang;
Branch: 1 branch
BranchTrueFalseTotal
if $does_shbang 7 0 7
3101  
3102 7 ▶ open(my $FIXOUT, '>', "$file.new")
Branch: 1 branch
BranchTrueFalseTotal
open my $FIXOUT, ">", "$file.new" or die "Can't create new ${file}: $!\n" 7 0 7
3103 or die "Can't create new $file: $!\n";
3104  
3105 # Print out the new #! line (or equivalent).
3106 7 local $\;
3107 7 undef $/; # Was localized above
3108 7 print $FIXOUT $shb, <$FIXIN>;
3109 7 close $FIXIN;
3110 7 close $FIXOUT;
3111  
3112 7 ▶ rename($file, "$file.bak")
Branch: 1 branch
BranchTrueFalseTotal
rename $file, "$file.bak" or die "Can't rename $file to $file.bak: $!" 7 0 7
3113 or die "Can't rename $file to $file.bak: $!";
3114  
3115 7 ▶ rename("$file.new", $file)
Branch: 1 branch
BranchTrueFalseTotal
rename "$file.new", $file or die "Can't rename $file.new to ${file}: $!" 7 0 7
3116 or die "Can't rename $file.new to $file: $!";
3117  
3118 7 ▶ $self->delete_filetree("$file.bak")
Branch: 1 branch
BranchTrueFalseTotal
$self->delete_filetree("$file.bak") or $self->log_warn("Couldn't clean up $file.bak, leaving it there") 7 0 7
3119 or $self->log_warn("Couldn't clean up $file.bak, leaving it there");
3120  
3121 7 ▶ $self->do_system($c->get('eunicefix'), $file) if $c->get('eunicefix') ne ':';
Branch: 1 branch
BranchTrueFalseTotal
if $c->get("eunicefix") ne ":" 0 7 7
3122 }
3123 }
3124  
3125  
3126 0 ▶sub ACTION_testpod {
Subroutine ACTION_testpod: not called CC=4 SCAR=30.0
Pod undocumented
3127 0 my $self = shift;
3128 0 $self->depends_on('docs');
3129  
3130 0 ▶ eval q{use Test::Pod 0.95; 1}
Branch: 1 branch
BranchTrueFalseTotal
eval "use Test::Pod 0.95; 1" or die "The 'testpod' action requires Test::Pod version 0.95" 0 0 0
3131 or die "The 'testpod' action requires Test::Pod version 0.95";
3132  
3133 0 my @files = sort keys %{$self->_find_pods($self->libdoc_dirs)},
3134 0 ▶ keys %{$self->_find_pods
Branch: 1 branch
BranchTrueFalseTotal
my(@files) = sort(keys %{$self->_find_pods($self->libdoc_dirs);}, keys %{$self->_find_pods($self->bindoc_dirs, "exclude", [$self->file_qr("\\.bat\$")]);}) or die "Couldn't find any POD files to test\n" 0 0 0
3135 ($self->bindoc_dirs,
3136 exclude => [ $self->file_qr('\.bat$') ])}
3137 or die "Couldn't find any POD files to test\n";
3138  
3139 0 { package # hide from PAUSE
3140 Module::Build::PodTester; # Don't want to pollute the main namespace
3141 0 Test::Pod->import( tests => scalar @files );
3142 0 pod_file_ok($_) foreach @files;
3143 }
3144 }
3145  
3146 0 ▶sub ACTION_testpodcoverage {
Subroutine ACTION_testpodcoverage: not called CC=2 SCAR=17.9
Pod undocumented
3147 0 my $self = shift;
3148  
3149 0 $self->depends_on('docs');
3150  
3151 0 ▶ eval q{use Test::Pod::Coverage 1.00; 1}
Branch: 1 branch
BranchTrueFalseTotal
eval "use Test::Pod::Coverage 1.00; 1" or die "The 'testpodcoverage' action requires ", "Test::Pod::Coverage version 1.00" 0 0 0
3152 or die "The 'testpodcoverage' action requires ",
3153 "Test::Pod::Coverage version 1.00";
3154  
3155 # TODO this needs test coverage!
3156  
3157 # XXX work-around a bug in Test::Pod::Coverage previous to v1.09
3158 # Make sure we test the module in blib/
3159 0 local @INC = @INC;
3160 0 my $p = $self->{properties};
3161 unshift(@INC,
3162 # XXX any reason to include arch?
3163 0 File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'),
3164 #File::Spec->catdir($p->{base_dir}, $self->blib, 'arch')
3165 );
3166  
3167 0 all_pod_coverage_ok();
3168 }
3169  
3170 28 ▶sub ACTION_docs {
Subroutine ACTION_docs: called CC=1 SCAR=0.0
Pod undocumented
3171 28 my $self = shift;
3172  
3173 28 $self->depends_on('code');
3174 28 $self->depends_on('manpages', 'html');
3175 }
3176  
3177 # Given a file type, will return true if the file type would normally
3178 # be installed when neither install-base nor prefix has been set.
3179 # I.e. it will be true only if the path is set from Config.pm or
3180 # set explicitly by the user via install-path.
3181 112 ▶sub _is_default_installable {
Subroutine _is_default_installable: called CC=4 SCAR=13.9
3182 112 my $self = shift;
3183 112 my $type = shift;
3184 return ( $self->install_destination($type) &&
3185 ( $self->install_path($type) ||
3186 112 ▶ $self->install_sets($self->installdirs)->{$type} )
Branch: 1 branch
BranchTrueFalseTotal
$self->install_destination($type) && ($self->install_path($type) || $self->install_sets($self->installdirs)->{$type}) ? : 28 84 112
Condition83%5/6
$self->install_destination($type) and $self->install_path($type) || $self->install_sets($self->installdirs)->{$type}
!ll&&!rl&&r
622228
$self->install_path($type) or $self->install_sets($self->installdirs)->{$type}
l!l&&r!l&&!r
02822
MC/DC66%2/3
$self->install_destination($type) and $self->install_path($type) || $self->install_sets($self->installdirs)->{$type}
$self->install_destination($type) $self->install_path($type) $self->install_sets($self->installdirs)->{$type}
Truth table75%3/4
A and B or C
A= $self->install_destination($type)B= $self->install_path($type)C= $self->install_sets($self->installdirs)->{$type}
ABCresult
0XX0
1000
11X1
1011
3187 ) ? 1 : 0;
3188 }
3189  
3190 29 ▶sub _is_ActivePerl {
Subroutine _is_ActivePerl: called CC=3 SCAR=11.0
3191 # return 0;
3192 29 my $self = shift;
3193 29 ▶ unless (exists($self->{_is_ActivePerl})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_is_ActivePerl"}) 8 21 29
3194 8 ▶ $self->{_is_ActivePerl} = (eval { require ActivePerl::DocTools; } || 0);
Condition50%1/2
eval { do { require ActivePerl::DocTools } } || 0
l!l
08
MC/DC0%0/1
eval { do { require ActivePerl::DocTools } } || 0
eval { do { require ActivePerl::DocTools } }
Truth table50%1/2
A
A= eval { do { require ActivePerl::DocTools } }
Aresult
11
00
3195 }
3196 29 return $self->{_is_ActivePerl};
3197 }
3198  
3199 9 ▶sub _is_ActivePPM {
Subroutine _is_ActivePPM: called CC=3 SCAR=11.0
3200 # return 0;
3201 9 my $self = shift;
3202 9 ▶ unless (exists($self->{_is_ActivePPM})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_is_ActivePPM"}) 5 4 9
3203 5 ▶ $self->{_is_ActivePPM} = (eval { require ActivePerl::PPM; } || 0);
Condition50%1/2
eval { do { require ActivePerl::PPM } } || 0
l!l
05
MC/DC0%0/1
eval { do { require ActivePerl::PPM } } || 0
eval { do { require ActivePerl::PPM } }
Truth table50%1/2
A
A= eval { do { require ActivePerl::PPM } }
Aresult
11
00
3204 }
3205 9 return $self->{_is_ActivePPM};
3206 }
3207  
3208 28 ▶sub ACTION_manpages {
Subroutine ACTION_manpages: called CC=8 SCAR=20.9
Pod undocumented
3209 28 my $self = shift;
3210  
3211 28 ▶ return unless $self->_mb_feature('manpage_support');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_mb_feature("manpage_support") 0 28 28
3212  
3213 28 $self->depends_on('code');
3214  
3215 28 ▶ my %extra_manify_args = $self->{properties}{'extra_manify_args'} ? %{ $self->{properties}{'extra_manify_args'} } : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->{'properties'}{'extra_manify_args'} ? : 1 27 28
3216  
3217 28 foreach my $type ( qw(bin lib) ) {
3218 56 ▶ next unless ( $self->invoked_action eq 'manpages' || $self->_is_default_installable("${type}doc"));
Branch: 1 branch
BranchTrueFalseTotal
unless $self->invoked_action eq "manpages" or $self->_is_default_installable("${type}doc") 32 24 56
Condition66%2/3
$self->invoked_action eq "manpages" or $self->_is_default_installable("${type}doc")
l!l&&r!l&&!r
02432
MC/DC50%1/2
$self->invoked_action eq "manpages" or $self->_is_default_installable("${type}doc")
$self->invoked_action eq "manpages" $self->_is_default_installable("${type}doc")
Truth table66%2/3
A or B
A= $self->invoked_action eq "manpages"B= $self->_is_default_installable("${type}doc")
ABresult
1X1
011
000
3219 24 my $files = $self->_find_pods( $self->{properties}{"${type}doc_dirs"},
3220 exclude => [ $self->file_qr('\.bat$') ] );
3221 24 ▶ next unless %$files;
Branch: 1 branch
BranchTrueFalseTotal
unless %$files 6 18 24
3222  
3223 18 my $sub = $self->can("manify_${type}_pods");
3224 18 ▶ $self->$sub( %extra_manify_args ) if defined( $sub );
Branch: 1 branch
BranchTrueFalseTotal
if defined $sub 18 0 18
3225 }
3226 }
3227  
3228 6 ▶sub manify_bin_pods {
Subroutine manify_bin_pods: called CC=5 SCAR=16.1
Pod undocumented
3229 6 my $self = shift;
3230 6 my $section = $self->config('man1ext');
3231 6 my %podman_args = (section => $section, @_);
3232  
3233 my $files = $self->_find_pods( $self->{properties}{bindoc_dirs},
3234 6 exclude => [ $self->file_qr('\.bat$') ] );
3235 6 ▶ return unless keys %$files;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$files 0 6 6
3236  
3237 6 my $mandir = File::Spec->catdir( $self->blib, 'bindoc' );
3238 6 File::Path::mkpath( $mandir, 0, oct(777) );
3239  
3240 6 require Pod::Man;
3241 6 foreach my $file (sort keys %$files) {
3242 # Pod::Simple based parsers only support one document per instance.
3243 # This is expected to change in a future version (Pod::Simple > 3.03).
3244 18 my $parser = Pod::Man->new( %podman_args );
3245 18 my $manpage = $self->man1page_name( $file ) . '.' .
3246 $self->config( 'man1ext' );
3247 18 my $outfile = File::Spec->catfile($mandir, $manpage);
3248 18 ▶ next if $self->up_to_date( $file, $outfile );
Branch: 1 branch
BranchTrueFalseTotal
if $self->up_to_date($file, $outfile) 10 8 18
3249 8 $self->log_verbose("Manifying $file -> $outfile\n");
3250 8 ▶ eval { $parser->parse_from_file( $file, $outfile ); 1 }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $parser->parse_from_file($file, $outfile); 1 } } or $self->log_warn("Error creating '${outfile}': $@\n") 8 0 8
3251 or $self->log_warn("Error creating '$outfile': $@\n");
3252 8 $files->{$file} = $outfile;
3253 }
3254 }
3255  
3256 12 ▶sub manify_lib_pods {
Subroutine manify_lib_pods: called CC=5 SCAR=16.1
Pod undocumented
3257 12 my $self = shift;
3258 12 my $section = $self->config('man3ext');
3259 12 my %podman_args = (section => $section, @_);
3260  
3261 12 my $files = $self->_find_pods($self->{properties}{libdoc_dirs});
3262 12 ▶ return unless keys %$files;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$files 0 12 12
3263  
3264 12 my $mandir = File::Spec->catdir( $self->blib, 'libdoc' );
3265 12 File::Path::mkpath( $mandir, 0, oct(777) );
3266  
3267 12 require Pod::Man;
3268 12 foreach my $file (sort keys %$files) {
3269 # Pod::Simple based parsers only support one document per instance.
3270 # This is expected to change in a future version (Pod::Simple > 3.03).
3271 17 my $parser = Pod::Man->new( %podman_args );
3272 17 my $manpage = $self->man3page_name( $files->{$file} ) . '.' .
3273 $self->config( 'man3ext' );
3274 17 my $outfile = File::Spec->catfile( $mandir, $manpage);
3275 17 ▶ next if $self->up_to_date( $file, $outfile );
Branch: 1 branch
BranchTrueFalseTotal
if $self->up_to_date($file, $outfile) 8 9 17
3276 9 $self->log_verbose("Manifying $file -> $outfile\n");
3277 9 ▶ eval { $parser->parse_from_file( $file, $outfile ); 1 }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $parser->parse_from_file($file, $outfile); 1 } } or $self->log_warn("Error creating '${outfile}': $@\n") 9 0 9
3278 or $self->log_warn("Error creating '$outfile': $@\n");
3279 9 $files->{$file} = $outfile;
3280 }
3281 }
3282  
3283 52 ▶sub _find_pods {
Subroutine _find_pods: called CC=7 SCAR=19.5
3284 52 my ($self, $dirs, %args) = @_;
3285 52 my %files;
3286 52 foreach my $spec (@$dirs) {
3287 87 my $dir = $self->localize_dir_path($spec);
3288 87 ▶ next unless -e $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir 1 86 87
3289  
3290 86 FILE: foreach my $file ( @{ $self->rscan_dir( $dir ) } ) {
3291 237 foreach my $regexp ( @{ $args{exclude} } ) {
3292 176 ▶ next FILE if $file =~ $regexp;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ /$regexp/ 0 176 176
3293 }
3294 237 $file = $self->localize_file_path($file);
3295 237 ▶ $files{$file} = File::Spec->abs2rel($file, $dir) if $self->contains_pod( $file )
Branch: 1 branch
BranchTrueFalseTotal
if $self->contains_pod($file) 80 157 237
3296 }
3297 }
3298 52 return \%files;
3299 }
3300  
3301 246 ▶sub contains_pod {
Subroutine contains_pod: called CC=5 SCAR=16.1
Pod undocumented
3302 246 my ($self, $file) = @_;
3303 246 ▶ return '' unless -T $file; # Only look at text files
Branch: 1 branch
BranchTrueFalseTotal
unless -T $file 129 117 246
3304  
3305 117 ▶ open(my $fh, '<', $file ) or die "Can't open $file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or die "Can't open ${file}: $!" 117 0 117
3306 117 ▶ while (my $line = <$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 757 30 787
3307 757 ▶ return 1 if $line =~ /^\=(?:head|pod|item)/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\=(?:head|pod|item)/ 87 670 757
3308 }
3309  
3310 30 return '';
3311 }
3312  
3313 28 ▶sub ACTION_html {
Subroutine ACTION_html: called CC=5 SCAR=16.3
Pod undocumented
3314 28 my $self = shift;
3315  
3316 28 ▶ return unless $self->_mb_feature('HTML_support');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_mb_feature("HTML_support") 0 28 28
3317  
3318 28 $self->depends_on('code');
3319  
3320 28 foreach my $type ( qw(bin lib) ) {
3321 56 ▶ next unless ( $self->invoked_action eq 'html' || $self->_is_default_installable("${type}html"));
Branch: 1 branch
BranchTrueFalseTotal
unless $self->invoked_action eq "html" or $self->_is_default_installable("${type}html") 52 4 56
Condition66%2/3
$self->invoked_action eq "html" or $self->_is_default_installable("${type}html")
l!l&&r!l&&!r
0452
MC/DC50%1/2
$self->invoked_action eq "html" or $self->_is_default_installable("${type}html")
$self->invoked_action eq "html" $self->_is_default_installable("${type}html")
Truth table66%2/3
A or B
A= $self->invoked_action eq "html"B= $self->_is_default_installable("${type}html")
ABresult
1X1
011
000
3322 4 $self->htmlify_pods( $type );
3323 }
3324 }
3325  
3326 # 1) If it's an ActiveState perl install, we need to run
3327 # ActivePerl::DocTools->UpdateTOC;
3328 # 2) Links to other modules are not being generated
3329 10 ▶sub htmlify_pods {
Subroutine htmlify_pods: called CC=36 SCAR=47.7
Pod undocumented
3330 10 my $self = shift;
3331 10 my $type = shift;
3332 10 ▶ my $htmldir = shift || File::Spec->catdir($self->blib, "${type}html");
Condition66%2/3
shift() || 'File::Spec'->catdir($self->blib, "${type}html")
l!l&&r!l&&!r
640
MC/DC0%0/2
shift() || 'File::Spec'->catdir($self->blib, "${type}html")
shift() 'File::Spec'->catdir($self->blib, "${type}html")
Truth table66%2/3
A || B
A= shift()B= 'File::Spec'->catdir($self->blib, "${type}html")
ABresult
1X1
011
000
3333  
3334 10 $self->add_to_cleanup('pod2htm*');
3335  
3336 10 my $pods = $self->_find_pods( $self->{properties}{"${type}doc_dirs"},
3337 exclude => [ $self->file_qr('\.(?:bat|com|html)$') ] );
3338 10 ▶ return unless %$pods; # nothing to do
Branch: 1 branch
BranchTrueFalseTotal
unless %$pods 0 10 10
3339  
3340 10 ▶ unless ( -d $htmldir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $htmldir) 7 3 10
3341 7 ▶ File::Path::mkpath($htmldir, 0, oct(755))
Branch: 1 branch
BranchTrueFalseTotal
File::Path::mkpath($htmldir, 0, 493) or die "Couldn't mkdir ${htmldir}: $!" 7 0 7
3342 or die "Couldn't mkdir $htmldir: $!";
3343 }
3344  
3345 10 ▶ my @rootdirs = ($type eq 'bin') ? qw(bin) :
Branch: 2 branches
BranchTrueFalseTotal
$type eq 'bin' ? : 5 5 10
$self->installdirs eq 'core' ? : 0 5 5
3346 $self->installdirs eq 'core' ? qw(lib) : qw(site lib);
3347 my $podroot = $ENV{PERL_CORE}
3348 ? File::Basename::dirname($ENV{PERL_CORE})
3349 10 ▶ : $self->original_prefix('core');
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERL_CORE'} ? : 0 10 10
3350  
3351 10 my $htmlroot = $self->install_sets('core')->{libhtml};
3352 10 my $podpath;
3353 10 ▶ unless (defined $self->args('html_links') and !$self->args('html_links')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->args("html_links") and not $self->args("html_links")) 0 10 10
Condition33%1/3
defined $self->args("html_links") and not $self->args("html_links")
!ll&&!rl&&r
0010
MC/DC0%0/2
defined $self->args("html_links") and not $self->args("html_links")
defined $self->args("html_links") not $self->args("html_links")
Truth table33%1/3
A and not(B)
A= defined $self->args("html_links")B= not $self->args("html_links")
ABresult
0X0
100
111
3354 0 my @podpath = ( (map { File::Spec->abs2rel($_ ,$podroot) } grep { -d }
3355 ( $self->install_sets('core', 'lib'), # lib
3356 $self->install_sets('core', 'bin'), # bin
3357 $self->install_sets('site', 'lib'), # site/lib
3358 ) ), File::Spec->rel2abs($self->blib) );
3359  
3360 $podpath = $ENV{PERL_CORE}
3361 ? File::Spec->catdir($podroot, 'lib')
3362 0 ▶ : join(":", map { tr,:\\,|/,; $_ } @podpath);
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERL_CORE'} ? : 0 0 0
3363 }
3364  
3365 10 my $blibdir = join('/', File::Spec->splitdir(
3366 (File::Spec->splitpath(File::Spec->rel2abs($htmldir),1))[1]),''
3367 );
3368  
3369 10 my ($with_ActiveState, $htmltool);
3370  
3371 10 ▶ if ( $with_ActiveState = $self->_is_ActivePerl
Branch: 1 branch
BranchTrueFalseTotal
if ($with_ActiveState = $self->_is_ActivePerl && eval { do { require ActivePerl::DocTools::Pod; 1 } }) { } 0 10 10
Condition33%1/3
$self->_is_ActivePerl && eval { do { require ActivePerl::DocTools::Pod; 1 } }
!ll&&!rl&&r
1000
MC/DC0%0/2
$self->_is_ActivePerl && eval { do { require ActivePerl::DocTools::Pod; 1 } }
$self->_is_ActivePerl eval { do { require ActivePerl::DocTools::Pod; 1 } }
Truth table33%1/3
A && B
A= $self->_is_ActivePerlB= eval { do { require ActivePerl::DocTools::Pod; 1 } }
ABresult
0X0
100
111
3372 0 && eval { require ActivePerl::DocTools::Pod; 1 }
3373 ) {
3374 0 my $tool_v = ActiveState::DocTools::Pod->VERSION;
3375 0 $htmltool = "ActiveState::DocTools::Pod";
3376 0 ▶ $htmltool .= " $tool_v" if $tool_v && length $tool_v;
Branch: 1 branch
BranchTrueFalseTotal
if $tool_v and length $tool_v 0 0 0
Condition0%0/3
$tool_v and length $tool_v
!ll&&!rl&&r
000
MC/DC0%0/2
$tool_v and length $tool_v
$tool_v length $tool_v
Truth table0%0/3
A and B
A= $tool_vB= length $tool_v
ABresult
0X0
100
111
3377 }
3378 else {
3379 10 require Module::Build::PodParser;
3380 10 require Pod::Html;
3381 10 $htmltool = "Pod::Html " . Pod::Html->VERSION;
3382 }
3383 10 $self->log_verbose("Converting Pod to HTML with $htmltool\n");
3384  
3385 10 my $errors = 0;
3386  
3387 POD:
3388 10 foreach my $pod ( sort keys %$pods ) {
3389  
3390 10 my ($name, $path) = File::Basename::fileparse($pods->{$pod},
3391 $self->file_qr('\.(?:pm|plx?|pod)$')
3392 );
3393 10 my @dirs = File::Spec->splitdir( File::Spec->canonpath( $path ) );
3394 10 ▶ pop( @dirs ) if scalar(@dirs) && $dirs[-1] eq File::Spec->curdir;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @dirs and $dirs[-1] eq "File::Spec"->curdir 10 0 10
Condition33%1/3
scalar @dirs and $dirs[-1] eq "File::Spec"->curdir
!ll&&!rl&&r
0010
MC/DC0%0/2
scalar @dirs and $dirs[-1] eq "File::Spec"->curdir
scalar @dirs $dirs[-1] eq "File::Spec"->curdir
Truth table33%1/3
A and B
A= scalar @dirsB= $dirs[-1] eq "File::Spec"->curdir
ABresult
0X0
100
111
3395  
3396 10 my $fulldir = File::Spec->catdir($htmldir, @rootdirs, @dirs);
3397 10 my $tmpfile = File::Spec->catfile($fulldir, "${name}.tmp");
3398 10 my $outfile = File::Spec->catfile($fulldir, "${name}.html");
3399 10 my $infile = File::Spec->abs2rel($pod);
3400  
3401 10 ▶ next if $self->up_to_date($infile, $outfile);
Branch: 1 branch
BranchTrueFalseTotal
if $self->up_to_date($infile, $outfile) 0 10 10
3402  
3403 10 ▶ unless ( -d $fulldir ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $fulldir) 10 0 10
3404 10 ▶ File::Path::mkpath($fulldir, 0, oct(755))
Branch: 1 branch
BranchTrueFalseTotal
File::Path::mkpath($fulldir, 0, 493) or die "Couldn't mkdir ${fulldir}: $!" 10 0 10
3405 or die "Couldn't mkdir $fulldir: $!";
3406 }
3407  
3408 10 $self->log_verbose("HTMLifying $infile -> $outfile\n");
3409 10 ▶ if ( $with_ActiveState ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($with_ActiveState) { } 0 10 10
3410 0 my $depth = @rootdirs + @dirs;
3411 0 ▶ my %opts = ( infile => $infile,
Branch: 1 branch
BranchTrueFalseTotal
defined $podpath ? : 0 0 0
3412 outfile => $tmpfile,
3413 ( defined($podpath) ? (podpath => $podpath) : ()),
3414 podroot => $podroot,
3415 index => 1,
3416 depth => $depth,
3417 );
3418 eval {
3419 0 ActivePerl::DocTools::Pod::pod2html(map { ($_, $opts{$_}) } sort keys %opts);
3420 0 1;
3421 } or $self->log_warn("[$htmltool] pod2html (" .
3422 0 ▶ join(", ", map { "q{$_} => q{$opts{$_}}" } (sort keys %opts)) . ") failed: $@");
Branch: 1 branch
BranchTrueFalseTotal
eval { do { ActivePerl::DocTools::Pod::pod2html(map({$_, $opts{$_};} sort(keys %opts))); 1 } } or $self->log_warn("[$htmltool] pod2html (" . join(", ", map({"q{$_} => q{$opts{$_}}";} sort(keys %opts))) . ") failed: $@") 0 0 0
3423 } else {
3424 10 my $path2root = File::Spec->catdir((File::Spec->updir) x @dirs);
3425 10 ▶ open(my $fh, '<', $infile) or die "Can't read $infile: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $infile or die "Can't read ${infile}: $!" 10 0 10
3426 10 my $abstract = Module::Build::PodParser->new(fh => $fh)->get_abstract();
3427  
3428 10 my $title = join( '::', (@dirs, $name) );
3429 10 ▶ $title .= " - $abstract" if $abstract;
Branch: 1 branch
BranchTrueFalseTotal
if $abstract 5 5 10
3430  
3431 10 ▶ my @opts = (
Branch: 2 branches
BranchTrueFalseTotal
defined $podpath ? : 0 10 10
$path2root ? : 0 10 10
3432 "--title=$title",
3433 ( defined($podpath) ? "--podpath=$podpath" : ()),
3434 "--infile=$infile",
3435 "--outfile=$tmpfile",
3436 "--podroot=$podroot",
3437 ($path2root ? "--htmlroot=$path2root" : ()),
3438 );
3439  
3440 10 ▶ unless ( eval{Pod::Html->VERSION(1.12)} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { "Pod::Html"->VERSION("1.12") } }) 0 10 10
3441 0 push( @opts, ('--flush') ); # caching removed in 1.12
3442 }
3443  
3444 10 ▶ if ( eval{Pod::Html->VERSION(1.12)} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { 'Pod::Html'->VERSION(1.12) } }) { } 10 0 10
elsif (eval { do { 'Pod::Html'->VERSION(1.03) } }) { } 0 0 0
3445 10 push( @opts, ('--header', '--backlink') );
3446 0 } elsif ( eval{Pod::Html->VERSION(1.03)} ) {
3447 0 push( @opts, ('--header', '--backlink=Back to Top') );
3448 }
3449  
3450 10 $self->log_verbose("P::H::pod2html @opts\n");
3451 {
3452 10 my $orig = Cwd::getcwd();
3453 10 eval { Pod::Html::pod2html(@opts); 1 }
3454 or $self->log_warn("[$htmltool] pod2html( " .
3455 0 ▶ join(", ", map { "q{$_}" } @opts) . ") failed: $@");
Branch: 1 branch
BranchTrueFalseTotal
eval { do { Pod::Html::pod2html(@opts); 1 } } or $self->log_warn("[$htmltool] pod2html( " . join(", ", map({"q{$_}";} @opts)) . ") failed: $@") 10 0 10
3456 10 chdir($orig);
3457 }
3458 }
3459 # We now have to cleanup the resulting html file
3460 10 ▶ if ( ! -r $tmpfile ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-r $tmpfile) 0 10 10
3461 0 $errors++;
3462 0 next POD;
3463 }
3464 10 ▶ open(my $fh, '<', $tmpfile) or die "Can't read $tmpfile: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $tmpfile or die "Can't read ${tmpfile}: $!" 10 0 10
3465 10 my $html = join('',<$fh>);
3466 10 close $fh;
3467 10 ▶ if (!$self->_is_ActivePerl) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_is_ActivePerl) 10 0 10
3468 # These fixups are already done by AP::DT:P:pod2html
3469 # The output from pod2html is NOT XHTML!
3470 # IE6+ will display content that is not valid for DOCTYPE
3471 10 $html =~ s#^<!DOCTYPE .*?>#<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">#im;
3472 10 $html =~ s#<html xmlns="http://www.w3.org/1999/xhtml">#<html>#i;
3473  
3474 # IE6+ will not display local HTML files with strict
3475 # security without this comment
3476 10 $html =~ s#<head>#<head>\n<!-- saved from url=(0017)http://localhost/ -->#i;
3477 }
3478 # Fixup links that point to our temp blib
3479 10 $html =~ s/\Q$blibdir\E//g;
3480  
3481 10 ▶ open($fh, '>', $outfile) or die "Can't write $outfile: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">", $outfile or die "Can't write ${outfile}: $!" 10 0 10
3482 10 print $fh $html;
3483 10 close $fh;
3484 10 unlink($tmpfile);
3485 }
3486  
3487 10 return ! $errors;
3488  
3489 }
3490  
3491 # Adapted from ExtUtils::MM_Unix
3492 18 ▶sub man1page_name {
Subroutine man1page_name: called CC=1 SCAR=0.0
Pod undocumented
3493 18 my $self = shift;
3494 18 return File::Basename::basename( shift );
3495 }
3496  
3497 # Adapted from ExtUtils::MM_Unix and Pod::Man
3498 # Depending on M::B's dependency policy, it might make more sense to refactor
3499 # Pod::Man::begin_pod() to extract a name() methods, and use them...
3500 # -spurkis
3501 17 ▶sub man3page_name {
Subroutine man3page_name: called CC=1 SCAR=0.0
Pod undocumented
3502 17 my $self = shift;
3503 17 my ($vol, $dirs, $file) = File::Spec->splitpath( shift );
3504 17 my @dirs = File::Spec->splitdir( File::Spec->canonpath($dirs) );
3505  
3506 # Remove known exts from the base name
3507 17 $file =~ s/\.p(?:od|m|l)\z//i;
3508  
3509 17 return join( $self->manpage_separator, @dirs, $file );
3510 }
3511  
3512 19 ▶sub manpage_separator {
Subroutine manpage_separator: called CC=1 SCAR=0.0
Pod undocumented
3513 19 return '::';
3514 }
3515  
3516 # For systems that don't have 'diff' executable, should use Algorithm::Diff
3517 0 ▶sub ACTION_diff {
Subroutine ACTION_diff: not called CC=9 SCAR=45.0
Pod undocumented
3518 0 my $self = shift;
3519 0 $self->depends_on('build');
3520 0 my $local_lib = File::Spec->rel2abs('lib');
3521 0 my @myINC = grep {$_ ne $local_lib} @INC;
3522  
3523 # The actual install destination might not be in @INC, so check there too.
3524 0 push @myINC, map $self->install_destination($_), qw(lib arch);
3525  
3526 0 my @flags = @{$self->{args}{ARGV}};
3527 0 ▶ @flags = $self->split_like_shell($self->{args}{flags} || '') unless @flags;
Branch: 1 branch
BranchTrueFalseTotal
unless @flags 0 0 0
Condition0%0/2
$self->{'args'}{'flags'} || ''
l!l
00
MC/DC0%0/1
$self->{'args'}{'flags'} || ''
$self->{'args'}{'flags'}
Truth table0%0/2
A
A= $self->{'args'}{'flags'}
Aresult
11
00
3528  
3529 0 my $installmap = $self->install_map;
3530 0 delete $installmap->{read};
3531 0 delete $installmap->{write};
3532  
3533 0 my $text_suffix = $self->file_qr('\.(pm|pod)$');
3534  
3535 0 foreach my $localdir (sort keys %$installmap) {
3536 0 my @localparts = File::Spec->splitdir($localdir);
3537 0 ▶ my $files = $self->rscan_dir($localdir, sub {-f});
Subroutine __ANON__: not called CC=1 SCAR=6.9
3538  
3539 0 foreach my $file (@$files) {
3540 0 my @parts = File::Spec->splitdir($file);
3541 0 @parts = @parts[@localparts .. $#parts]; # Get rid of blib/lib or similar
3542  
3543 0 my $installed = Module::Metadata->find_module_by_name(
3544 join('::', @parts), \@myINC );
3545 0 ▶ if (not $installed) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($installed) 0 0 0
3546 0 print "Only in lib: $file\n";
3547 0 next;
3548 }
3549  
3550 0 my $status = File::Compare::compare($installed, $file);
3551 0 ▶ next if $status == 0; # Files are the same
Branch: 1 branch
BranchTrueFalseTotal
if $status == 0 0 0 0
3552 0 ▶ die "Can't compare $installed and $file: $!" if $status == -1;
Branch: 1 branch
BranchTrueFalseTotal
if $status == -1 0 0 0
3553  
3554 0 ▶ if ($file =~ $text_suffix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /$text_suffix/) { } 0 0 0
3555 0 $self->do_system('diff', @flags, $installed, $file);
3556 } else {
3557 0 print "Binary files $file and $installed differ\n";
3558 }
3559 }
3560 }
3561 }
3562  
3563 0 ▶sub ACTION_pure_install {
Subroutine ACTION_pure_install: not called CC=1 SCAR=6.9
Pod undocumented
3564 0 shift()->depends_on('install');
3565 }
3566  
3567 9 ▶sub ACTION_install {
Subroutine ACTION_install: called CC=6 SCAR=27.2
Pod undocumented
3568 9 my ($self) = @_;
3569 9 require ExtUtils::Install;
3570 9 $self->depends_on('build');
3571 # RT#63003 suggest that odd circumstances that we might wind up
3572 # in a different directory than we started, so wrap with _do_in_dir to
3573 # ensure we get back to where we started; hope this fixes it!
3574 9 ▶ $self->_do_in_dir( ".", sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
3575 ExtUtils::Install::install(
3576 9 ▶ $self->install_map, $self->verbose, 0, $self->{args}{uninst}||0
Condition50%1/2
$self->{'args'}{'uninst'} || 0
l!l
09
MC/DC0%0/1
$self->{'args'}{'uninst'} || 0
$self->{'args'}{'uninst'}
Truth table50%1/2
A
A= $self->{'args'}{'uninst'}
Aresult
11
00
3577 );
3578 9 });
3579 9 ▶ if ($self->_is_ActivePerl && $self->{_completed_actions}{html}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_ActivePerl and $self->{"_completed_actions"}{"html"}) 0 9 9
Condition33%1/3
$self->_is_ActivePerl and $self->{"_completed_actions"}{"html"}
!ll&&!rl&&r
900
MC/DC0%0/2
$self->_is_ActivePerl and $self->{"_completed_actions"}{"html"}
$self->_is_ActivePerl $self->{"_completed_actions"}{"html"}
Truth table33%1/3
A and B
A= $self->_is_ActivePerlB= $self->{"_completed_actions"}{"html"}
ABresult
0X0
100
111
3580 0 $self->log_info("Building ActivePerl Table of Contents\n");
3581 0 ▶ eval { ActivePerl::DocTools::WriteTOC(verbose => $self->verbose ? 1 : 0); 1; }
Branch: 2 branches
BranchTrueFalseTotal
eval { do { ActivePerl::DocTools::WriteTOC("verbose", $self->verbose ? 1 : 0); 1 } } or $self->log_warn("AP::DT:: WriteTOC() failed: $@") 0 0 0
$self->verbose ? : 0 0 0
3582 or $self->log_warn("AP::DT:: WriteTOC() failed: $@");
3583 }
3584 9 ▶ if ($self->_is_ActivePPM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_ActivePPM) 0 9 9
3585 # We touch 'lib/perllocal.pod'. There is an existing logic in subroutine _init_db()
3586 # of 'ActivePerl/PPM/InstallArea.pm' that says that if 'lib/perllocal.pod' has a 'date-last-touched'
3587 # greater than that of the PPM SQLite databases ('etc/ppm-perl-area.db' and/or
3588 # 'site/etc/ppm-site-area.db') then the PPM SQLite databases are rebuilt from scratch.
3589  
3590 # in the following line, 'perllocal.pod' this is *always* 'lib/perllocal.pod', never 'site/lib/perllocal.pod'
3591 0 my $F_perllocal = File::Spec->catfile($self->install_sets('core', 'lib'), 'perllocal.pod');
3592 0 my $dt_stamp = time;
3593  
3594 0 $self->log_info("For ActivePerl's PPM: touch '$F_perllocal'\n");
3595  
3596 0 open my $perllocal, ">>", $F_perllocal;
3597 0 close $perllocal;
3598 0 utime($dt_stamp, $dt_stamp, $F_perllocal);
3599 }
3600 }
3601  
3602 0 ▶sub ACTION_fakeinstall {
Subroutine ACTION_fakeinstall: not called CC=3 SCAR=24.8
Pod undocumented
3603 0 my ($self) = @_;
3604 0 require ExtUtils::Install;
3605 0 my $eui_version = ExtUtils::Install->VERSION;
3606 0 ▶ if ( $eui_version < 1.32 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eui_version < "1.32") 0 0 0
3607 0 $self->log_warn(
3608 "The 'fakeinstall' action requires Extutils::Install 1.32 or later.\n"
3609 . "(You only have version $eui_version)."
3610 );
3611 0 return;
3612 }
3613 0 $self->depends_on('build');
3614 0 ▶ ExtUtils::Install::install($self->install_map, !$self->quiet, 1, $self->{args}{uninst}||0);
Condition0%0/2
$self->{'args'}{'uninst'} || 0
l!l
00
MC/DC0%0/1
$self->{'args'}{'uninst'} || 0
$self->{'args'}{'uninst'}
Truth table0%0/2
A
A= $self->{'args'}{'uninst'}
Aresult
11
00
3615 }
3616  
3617 0 ▶sub ACTION_versioninstall {
Subroutine ACTION_versioninstall: not called CC=3 SCAR=24.8
Pod undocumented
3618 0 my ($self) = @_;
3619  
3620 die "You must have only.pm 0.25 or greater installed for this operation: $@\n"
3621 0 ▶ unless eval { require only; 'only'->VERSION(0.25); 1 };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { require only; "only"->VERSION("0.25"); 1 } } 0 0 0
3622  
3623 0 $self->depends_on('build');
3624  
3625 0 ▶ my %onlyargs = map {exists($self->{args}{$_}) ? ($_ => $self->{args}{$_}) : ()}
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'args'}{$_} ? : 0 0 0
3626 qw(version versionlib);
3627 0 only::install::install(%onlyargs);
3628 }
3629  
3630 2 ▶sub ACTION_installdeps {
Subroutine ACTION_installdeps: called CC=11 SCAR=28.0
Pod undocumented
3631 2 my ($self) = @_;
3632  
3633 # XXX include feature prerequisites as optional prereqs?
3634  
3635 2 my $info = $self->_enum_prereqs;
3636 2 ▶ if (! $info ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info) 0 2 2
3637 0 $self->log_info( "No prerequisites detected\n" );
3638 0 return;
3639 }
3640  
3641 2 my $failures = $self->prereq_failures($info);
3642 2 ▶ if ( ! $failures ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($failures) 0 2 2
3643 0 $self->log_info( "All prerequisites satisfied\n" );
3644 0 return;
3645 }
3646  
3647 2 my @install;
3648 2 foreach my $type (sort keys %$failures) {
3649 4 my $prereqs = $failures->{$type};
3650 4 ▶ if($type =~ m/^(?:\w+_)?requires$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /^(?:\w+_)?requires$/) 4 0 4
3651 4 push(@install, sort keys %$prereqs);
3652 4 next;
3653 }
3654 0 $self->log_info("Checking optional dependencies:\n");
3655 0 foreach my $module (sort keys %$prereqs) {
3656 0 ▶ push(@install, $module) if($self->y_n("Install $module?", 'y'));
Branch: 1 branch
BranchTrueFalseTotal
if $self->y_n("Install $module?", "y") 0 0 0
3657 }
3658 }
3659  
3660 2 ▶ return unless @install;
Branch: 1 branch
BranchTrueFalseTotal
unless @install 0 2 2
3661  
3662 2 my ($command, @opts) = $self->split_like_shell($self->cpan_client);
3663  
3664 # relative command should be relative to our active Perl
3665 # so we need to locate that command
3666 2 ▶ if ( ! File::Spec->file_name_is_absolute( $command ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("File::Spec"->file_name_is_absolute($command)) 1 1 2
3667 # prefer site to vendor to core
3668 1 my @loc = ( 'site', 'vendor', '' );
3669 1 my @bindirs = File::Basename::dirname($self->perl);
3670 push @bindirs,
3671 map {
3672 1 ($self->config->{"install${_}bin"}, $self->config->{"install${_}script"})
3673 } @loc;
3674 1 for my $d ( @bindirs ) {
3675 7 my $abs_cmd = $self->find_command(File::Spec->catfile( $d, $command ));
3676 7 ▶ if ( defined $abs_cmd ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $abs_cmd) 0 7 7
3677 0 $command = $abs_cmd;
3678 0 last;
3679 }
3680 }
3681 }
3682  
3683 2 $self->do_system($command, @opts, @install);
3684 }
3685  
3686 46 ▶sub ACTION_clean {
Subroutine ACTION_clean: called CC=2 SCAR=6.9
Pod undocumented
3687 46 my ($self) = @_;
3688 46 $self->log_info("Cleaning up build files\n");
3689 46 foreach my $item (map glob($_), $self->cleanup) {
3690 125 $self->delete_filetree($item);
3691 }
3692 }
3693  
3694 35 ▶sub ACTION_realclean {
Subroutine ACTION_realclean: called CC=1 SCAR=0.0
Pod undocumented
3695 35 my ($self) = @_;
3696 35 $self->depends_on('clean');
3697 35 $self->log_info("Cleaning up configuration files\n");
3698 35 $self->delete_filetree(
3699 $self->config_dir, $self->mymetafile, $self->mymetafile2, $self->build_script
3700 );
3701 }
3702  
3703 5 ▶sub ACTION_ppd {
Subroutine ACTION_ppd: called CC=1 SCAR=0.0
Pod undocumented
3704 5 my ($self) = @_;
3705  
3706 5 require Module::Build::PPMMaker;
3707 5 my $ppd = Module::Build::PPMMaker->new();
3708 5 my $file = $ppd->make_ppd(%{$self->{args}}, build => $self);
3709 5 $self->add_to_cleanup($file);
3710 }
3711  
3712 3 ▶sub ACTION_ppmdist {
Subroutine ACTION_ppmdist: called CC=9 SCAR=22.0
Pod undocumented
3713 3 my ($self) = @_;
3714  
3715 3 $self->depends_on( 'build' );
3716  
3717 3 my $ppm = $self->ppm_name;
3718 3 $self->delete_filetree( $ppm );
3719 3 $self->log_info( "Creating $ppm\n" );
3720 3 $self->add_to_cleanup( $ppm, "$ppm.tar.gz" );
3721  
3722 3 my %types = ( # translate types/dirs to those expected by ppm
3723 lib => 'lib',
3724 arch => 'arch',
3725 bin => 'bin',
3726 script => 'script',
3727 bindoc => 'man1',
3728 libdoc => 'man3',
3729 binhtml => undef,
3730 libhtml => undef,
3731 );
3732  
3733 3 foreach my $type ($self->install_types) {
3734 24 ▶ next if exists( $types{$type} ) && !defined( $types{$type} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $types{$type} and not defined $types{$type} 6 18 24
Condition66%2/3
exists $types{$type} and not defined $types{$type}
!ll&&!rl&&r
0186
MC/DC50%1/2
exists $types{$type} and not defined $types{$type}
exists $types{$type} not defined $types{$type}
Truth table66%2/3
A and not(B)
A= exists $types{$type}B= not defined $types{$type}
ABresult
0X0
100
111
3735  
3736 18 my $dir = File::Spec->catdir( $self->blib, $type );
3737 18 ▶ next unless -e $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $dir 3 15 18
3738  
3739 15 my $files = $self->rscan_dir( $dir );
3740 15 foreach my $file ( @$files ) {
3741 39 ▶ next unless -f $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $file 21 18 39
3742 18 my $rel_file =
3743 File::Spec->abs2rel( File::Spec->rel2abs( $file ),
3744 File::Spec->rel2abs( $dir ) );
3745 my $to_file =
3746 File::Spec->catfile( $ppm, 'blib',
3747 18 ▶ exists( $types{$type} ) ? $types{$type} : $type,
Branch: 1 branch
BranchTrueFalseTotal
exists $types{$type} ? : 18 0 18
3748 $rel_file );
3749 18 $self->copy_if_modified( from => $file, to => $to_file );
3750 }
3751 }
3752  
3753 3 foreach my $type ( qw(bin lib) ) {
3754 6 $self->htmlify_pods( $type, File::Spec->catdir($ppm, 'blib', 'html') );
3755 }
3756  
3757 # create a tarball;
3758 # the directory tar'ed must be blib so we need to do a chdir first
3759 3 my $target = File::Spec->catfile( File::Spec->updir, $ppm );
3760 3 ▶ $self->_do_in_dir( $ppm, sub { $self->make_tarball( 'blib', $target ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
3761  
3762 3 $self->depends_on( 'ppd' );
3763  
3764 3 $self->delete_filetree( $ppm );
3765 }
3766  
3767 0 ▶sub ACTION_pardist {
Subroutine ACTION_pardist: not called CC=2 SCAR=17.9
Pod undocumented
3768 0 my ($self) = @_;
3769  
3770 # Need PAR::Dist
3771 0 ▶ if ( not eval { require PAR::Dist; PAR::Dist->VERSION(0.17) } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require PAR::Dist; "PAR::Dist"->VERSION("0.17") } }) 0 0 0
3772 0 $self->log_warn(
3773 "In order to create .par distributions, you need to\n"
3774 . "install PAR::Dist first."
3775 );
3776 0 return();
3777 }
3778  
3779 0 $self->depends_on( 'build' );
3780  
3781 0 return PAR::Dist::blib_to_par(
3782 name => $self->dist_name,
3783 version => $self->dist_version,
3784 );
3785 }
3786  
3787 1 ▶sub ACTION_dist {
Subroutine ACTION_dist: called CC=1 SCAR=0.0
Pod undocumented
3788 1 my ($self) = @_;
3789  
3790 # MUST dispatch() and not depends_ok() so we generate a clean distdir
3791 1 $self->dispatch('distdir');
3792  
3793 1 my $dist_dir = $self->dist_dir;
3794  
3795 1 $self->make_tarball($dist_dir);
3796 1 $self->delete_filetree($dist_dir);
3797 }
3798  
3799 0 ▶sub ACTION_distcheck {
Subroutine ACTION_distcheck: not called CC=5 SCAR=34.0
Pod undocumented
3800 0 my ($self) = @_;
3801  
3802 0 ▶ $self->_check_manifest_skip unless $self->invoked_action eq 'distclean';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->invoked_action eq "distclean" 0 0 0
3803  
3804 0 require ExtUtils::Manifest;
3805 0 local $^W; # ExtUtils::Manifest is not warnings clean.
3806 0 my ($missing, $extra) = ExtUtils::Manifest::fullcheck();
3807  
3808 0 ▶ return unless @$missing || @$extra;
Branch: 1 branch
BranchTrueFalseTotal
unless @$missing or @$extra 0 0 0
Condition0%0/3
@$missing or @$extra
l!l&&r!l&&!r
000
MC/DC0%0/2
@$missing or @$extra
@$missing @$extra
Truth table0%0/3
A or B
A= @$missingB= @$extra
ABresult
1X1
011
000
3809  
3810 0 my $msg = "MANIFEST appears to be out of sync with the distribution\n";
3811 0 ▶ if ( $self->invoked_action eq 'distcheck' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->invoked_action eq 'distcheck') { } 0 0 0
3812 0 die $msg;
3813 } else {
3814 0 warn $msg;
3815 }
3816 }
3817  
3818 0 ▶sub _check_mymeta_skip {
Subroutine _check_mymeta_skip: not called CC=6 SCAR=37.4
3819 0 my $self = shift;
3820 0 ▶ my $maniskip = shift || 'MANIFEST.SKIP';
Condition0%0/2
shift() || 'MANIFEST.SKIP'
l!l
00
MC/DC0%0/1
shift() || 'MANIFEST.SKIP'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
3821  
3822 0 require ExtUtils::Manifest;
3823 0 local $^W; # ExtUtils::Manifest is not warnings clean.
3824  
3825 # older ExtUtils::Manifest had a private _maniskip
3826 0 ▶ my $skip_factory = ExtUtils::Manifest->can('maniskip')
Condition0%0/3
'ExtUtils::Manifest'->can('maniskip') || 'ExtUtils::Manifest'->can('_maniskip')
l!l&&r!l&&!r
000
MC/DC0%0/2
'ExtUtils::Manifest'->can('maniskip') || 'ExtUtils::Manifest'->can('_maniskip')
'ExtUtils::Manifest'->can('maniskip') 'ExtUtils::Manifest'->can('_maniskip')
Truth table0%0/3
A || B
A= 'ExtUtils::Manifest'->can('maniskip')B= 'ExtUtils::Manifest'->can('_maniskip')
ABresult
1X1
011
000
3827 || ExtUtils::Manifest->can('_maniskip');
3828  
3829 0 my $mymetafile = $self->mymetafile;
3830 # we can't check it, just add it anyway to be safe
3831 0 for my $file ( $self->mymetafile, $self->mymetafile2 ) {
3832 0 ▶ unless ( $skip_factory && $skip_factory->($maniskip)->($file) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($skip_factory and &$skip_factory($maniskip)->($file)) 0 0 0
Condition0%0/3
$skip_factory and &$skip_factory($maniskip)->($file)
!ll&&!rl&&r
000
MC/DC0%0/2
$skip_factory and &$skip_factory($maniskip)->($file)
$skip_factory &$skip_factory($maniskip)->($file)
Truth table0%0/3
A and B
A= $skip_factoryB= &$skip_factory($maniskip)->($file)
ABresult
0X0
100
111
3833 0 $self->log_warn("File '$maniskip' does not include '$file'. Adding it now.\n");
3834 0 my $safe = quotemeta($file);
3835 0 $self->_append_maniskip("^$safe\$", $maniskip);
3836 }
3837 }
3838 }
3839  
3840 30 ▶sub _add_to_manifest {
Subroutine _add_to_manifest: called CC=9 SCAR=22.7
3841 30 my ($self, $manifest, $lines) = @_;
3842 30 ▶ $lines = [$lines] unless ref $lines;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $lines 30 0 30
3843  
3844 30 my $existing_files = $self->_read_manifest($manifest);
3845 30 ▶ return unless defined( $existing_files );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $existing_files 8 22 30
3846  
3847 22 ▶ @$lines = grep {!exists $existing_files->{$_}} @$lines
Branch: 1 branch
BranchTrueFalseTotal
@$lines = grep({not exists $existing_files->{$_};} @$lines) or return 22 0 22
3848 or return;
3849  
3850 22 my $mode = (stat $manifest)[2];
3851 22 ▶ chmod($mode | oct(222), $manifest) or die "Can't make $manifest writable: $!";
Branch: 1 branch
BranchTrueFalseTotal
chmod $mode | 146, $manifest or die "Can't make $manifest writable: $!" 22 0 22
3852  
3853 22 ▶ open(my $fh, '<', $manifest) or die "Can't read $manifest: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $manifest or die "Can't read ${manifest}: $!" 22 0 22
3854 22 ▶ my $last_line = (<$fh>)[-1] || "\n";
Condition50%1/2
(readline $fh)[-1] || "\n"
l!l
220
MC/DC0%0/1
(readline $fh)[-1] || "\n"
(readline $fh)[-1]
Truth table50%1/2
A
A= (readline $fh)[-1]
Aresult
11
00
3855 22 my $has_newline = $last_line =~ /\n$/;
3856 22 close $fh;
3857  
3858 22 ▶ open($fh, '>>', $manifest) or die "Can't write to $manifest: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">>", $manifest or die "Can't write to ${manifest}: $!" 22 0 22
3859 22 ▶ print $fh "\n" unless $has_newline;
Branch: 1 branch
BranchTrueFalseTotal
unless $has_newline 0 22 22
3860 22 print $fh map "$_\n", @$lines;
3861 22 close $fh;
3862 22 chmod($mode, $manifest);
3863  
3864 22 $self->log_verbose(map "Added to $manifest: $_\n", @$lines);
3865 }
3866  
3867 5 ▶sub _sign_dir {
Subroutine _sign_dir: called CC=3 SCAR=11.4
3868 5 my ($self, $dir) = @_;
3869  
3870 5 ▶ unless (eval { require Module::Signature; 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require Module::Signature; 1 } }) 0 5 5
3871 0 $self->log_warn("Couldn't load Module::Signature for 'distsign' action:\n $@\n");
3872 0 return;
3873 }
3874  
3875 # Add SIGNATURE to the MANIFEST
3876 {
3877 5 my $manifest = File::Spec->catfile($dir, 'MANIFEST');
3878 5 ▶ die "Signing a distribution requires a MANIFEST file" unless -e $manifest;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $manifest 0 5 5
3879 5 $self->_add_to_manifest($manifest, "SIGNATURE Added here by Module::Build");
3880 }
3881  
3882 # Would be nice if Module::Signature took a directory argument.
3883  
3884 5 ▶ $self->_do_in_dir($dir, sub {local $Module::Signature::Quiet = 1; Module::Signature::sign()});
Subroutine __ANON__: called CC=1 SCAR=0.0
3885 }
3886  
3887 18 ▶sub _do_in_dir {
Subroutine _do_in_dir: called CC=5 SCAR=16.8
3888 18 my ($self, $dir, $do) = @_;
3889  
3890 18 my $start_dir = File::Spec->rel2abs($self->cwd);
3891 18 ▶ chdir $dir or die "Can't chdir() to $dir: $!";
Branch: 1 branch
BranchTrueFalseTotal
chdir $dir or die "Can't chdir() to ${dir}: $!" 18 0 18
3892 18 eval {$do->()};
3893 18 ▶ my @err = $@ ? ($@) : ();
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 18 18
3894 18 ▶ chdir $start_dir or push @err, "Can't chdir() back to $start_dir: $!";
Branch: 1 branch
BranchTrueFalseTotal
chdir $start_dir or push @err, "Can't chdir() back to ${start_dir}: $!" 18 0 18
3895 18 ▶ die join "\n", @err if @err;
Branch: 1 branch
BranchTrueFalseTotal
if @err 0 18 18
3896 }
3897  
3898 0 ▶sub ACTION_distsign {
Subroutine ACTION_distsign: not called CC=2 SCAR=17.9
Pod undocumented
3899 0 my ($self) = @_;
3900 {
3901 0 local $self->{properties}{sign} = 0; # We'll sign it ourselves
3902 0 ▶ $self->depends_on('distdir') unless -d $self->dist_dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $self->dist_dir 0 0 0
3903 }
3904 0 $self->_sign_dir($self->dist_dir);
3905 }
3906  
3907 0 ▶sub ACTION_skipcheck {
Subroutine ACTION_skipcheck: not called CC=1 SCAR=6.9
Pod undocumented
3908 0 my ($self) = @_;
3909  
3910 0 require ExtUtils::Manifest;
3911 0 local $^W; # ExtUtils::Manifest is not warnings clean.
3912 0 ExtUtils::Manifest::skipcheck();
3913 }
3914  
3915 0 ▶sub ACTION_distclean {
Subroutine ACTION_distclean: not called CC=1 SCAR=6.9
Pod undocumented
3916 0 my ($self) = @_;
3917  
3918 0 $self->depends_on('realclean');
3919 0 $self->depends_on('distcheck');
3920 }
3921  
3922 1 ▶sub do_create_makefile_pl {
Subroutine do_create_makefile_pl: called CC=3 SCAR=12.6
Pod undocumented
3923 1 my $self = shift;
3924 1 require Module::Build::Compat;
3925 1 $self->log_info("Creating Makefile.PL\n");
3926 1 eval { Module::Build::Compat->create_makefile_pl($self->create_makefile_pl, $self, @_) };
3927 1 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
3928 0 ▶ 1 while unlink 'Makefile.PL';
Branch: 1 branch
BranchTrueFalseTotal
unlink "Makefile.PL" and do { '???' } 0 0 0
3929 0 die "$@\n";
3930 }
3931 1 $self->_add_to_manifest('MANIFEST', 'Makefile.PL');
3932 }
3933  
3934 0 ▶sub do_create_license {
Subroutine do_create_license: not called CC=5 SCAR=34.0
Pod undocumented
3935 0 my $self = shift;
3936 0 $self->log_info("Creating LICENSE file\n");
3937  
3938 0 ▶ if ( ! $self->_mb_feature('license_creation') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_mb_feature("license_creation")) 0 0 0
3939 0 $self->_warn_mb_feature_deps('license_creation');
3940 0 die "Aborting.\n";
3941 }
3942  
3943 0 ▶ my $l = $self->license
Branch: 1 branch
BranchTrueFalseTotal
my $l = $self->license or die "Can't create LICENSE file: No license specified\n" 0 0 0
3944 or die "Can't create LICENSE file: No license specified\n";
3945  
3946 0 ▶ my $license = $self->_software_license_object
Branch: 1 branch
BranchTrueFalseTotal
my $license = $self->_software_license_object or die "Can't create LICENSE file: '${l}' is not a valid license key\nor Software::License subclass;\n" 0 0 0
3947 or die << "HERE";
3948 Can't create LICENSE file: '$l' is not a valid license key
3949 or Software::License subclass;
3950 HERE
3951  
3952 0 $self->delete_filetree('LICENSE');
3953  
3954 0 ▶ open(my $fh, '>', 'LICENSE')
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", "LICENSE" or die "Can't write LICENSE file: $!" 0 0 0
3955 or die "Can't write LICENSE file: $!";
3956 0 print $fh $license->fulltext;
3957 0 close $fh;
3958  
3959 0 $self->_add_to_manifest('MANIFEST', 'LICENSE');
3960 }
3961  
3962 6 ▶sub do_create_readme {
Subroutine do_create_readme: called CC=7 SCAR=26.3
Pod undocumented
3963 6 my $self = shift;
3964 6 $self->delete_filetree('README');
3965  
3966 6 my $docfile = $self->_main_docfile;
3967 6 ▶ unless ( $docfile ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($docfile) 0 6 6
3968 0 $self->log_warn(<<EOF);
3969 Cannot create README: can't determine which file contains documentation;
3970 Must supply either 'dist_version_from', or 'module_name' parameter.
3971 EOF
3972 0 return;
3973 }
3974  
3975 # work around some odd Pod::Readme->new() failures in test reports by
3976 # confirming that new() is available
3977 0 ▶ if ( eval {require Pod::Readme; Pod::Readme->can('new') } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { require Pod::Readme; 'Pod::Readme'->can('new') } }) { } 0 6 6
elsif (eval { do { require Pod::Text; 1 } }) { } 6 0 6
3978 0 $self->log_info("Creating README using Pod::Readme\n");
3979  
3980 0 my $parser = Pod::Readme->new;
3981 0 $parser->parse_from_file($docfile, 'README', @_);
3982  
3983 6 } elsif ( eval {require Pod::Text; 1} ) {
3984 6 $self->log_info("Creating README using Pod::Text\n");
3985  
3986 6 ▶ if ( open(my $fh, '>', 'README') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, '>', 'README') { } 6 0 6
3987 6 local $^W = 0;
3988 297 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
3989  
3990 # work around bug in Pod::Text 3.01, which expects
3991 # Pod::Simple::parse_file to take input and output filehandles
3992 # when it actually only takes an input filehandle
3993  
3994 6 my $old_parse_file;
3995 0 $old_parse_file = \&{"Pod::Simple::parse_file"}
3996 and
3997 0 ▶ local *{"Pod::Simple::parse_file"} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3998 0 my $self = shift;
3999 0 ▶ $self->output_fh($_[1]) if $_[1];
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 0 0 0
4000 0 $self->$old_parse_file($_[0]);
4001 }
4002 6 ▶ if $Pod::Text::VERSION
Branch: 1 branch
BranchTrueFalseTotal
if $Pod::Text::VERSION == "3.01" 0 6 6
Condition16%1/6
$Pod::Text::VERSION == 3.01 && (($old_parse_file = \&{'Pod::Simple::parse_file';}) && (local *{'Pod::Simple::parse_file';} = sub { my $self = shift(); $self->output_fh($_[1]) if $_[1]; $self->$old_parse_file($_[0]); } ))
!ll&&!rl&&r
600
$old_parse_file = \&{"Pod::Simple::parse_file";} and local *{"Pod::Simple::parse_file";} = sub { my $self = shift(); $self->output_fh($_[1]) if $_[1]; $self->$old_parse_file($_[0]); }
!ll&&!rl&&r
000
MC/DC0%0/3
$Pod::Text::VERSION == 3.01 && (($old_parse_file = \&{'Pod::Simple::parse_file';}) && (local *{'Pod::Simple::parse_file';} = sub { my $self = shift(); $self->output_fh($_[1]) if $_[1]; $self->$old_parse_file($_[0]); } ))
$Pod::Text::VERSION == 3.01 $old_parse_file = \&{"Pod::Simple::parse_file";} local *{"Pod::Simple::parse_file";} = sub { my $self = shift(); $self->output_fh($_[1]) if $_[1]; $self->$old_parse_file($_[0]); }
Truth table0%0/4
A && B and C
A= $Pod::Text::VERSION == 3.01B= $old_parse_file = \&{"Pod::Simple::parse_file";}C= local *{"Pod::Simple::parse_file";} = sub { my $self = shift(); $self->output_fh($_[1]) if $_[1]; $self->$old_parse_file($_[0]); }
ABCresult
0XX0
10X0
1100
1111
4003 == 3.01; # Split line to avoid evil version-finder
4004  
4005 6 Pod::Text::pod2text( $docfile, $fh );
4006  
4007 6 close $fh;
4008 } else {
4009 0 $self->log_warn(
4010 "Cannot create 'README' file: Can't open file for writing\n" );
4011 0 return;
4012 }
4013  
4014 } else {
4015 0 $self->log_warn("Can't load Pod::Readme or Pod::Text to create README\n");
4016 0 return;
4017 }
4018  
4019 6 $self->_add_to_manifest('MANIFEST', 'README');
4020 }
4021  
4022 63 ▶sub _main_docfile {
Subroutine _main_docfile: called CC=3 SCAR=11.3
4023 63 my $self = shift;
4024 63 ▶ if ( my $pm_file = $self->dist_version_from ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pm_file = $self->dist_version_from) { } 63 0 63
4025 63 (my $pod_file = $pm_file) =~ s/.pm$/.pod/;
4026 63 ▶ return (-e $pod_file ? $pod_file : $pm_file);
Branch: 1 branch
BranchTrueFalseTotal
-e $pod_file ? : 10 53 63
4027 } else {
4028 0 return undef;
4029 }
4030 }
4031  
4032 0 ▶sub do_create_bundle_inc {
Subroutine do_create_bundle_inc: not called CC=2 SCAR=17.9
Pod undocumented
4033 0 my $self = shift;
4034 0 my $dist_inc = File::Spec->catdir( $self->dist_dir, 'inc' );
4035 0 require inc::latest;
4036 0 inc::latest->write($dist_inc, @{$self->bundle_inc_preload});
4037 0 inc::latest->bundle_module($_, $dist_inc) for @{$self->bundle_inc};
4038 0 return 1;
4039 }
4040  
4041 10 ▶sub ACTION_distdir {
Subroutine ACTION_distdir: called CC=11 SCAR=26.4
Pod undocumented
4042 10 my ($self) = @_;
4043  
4044 10 ▶ if ( @{$self->bundle_inc} && ! $self->_mb_feature('inc_bundling_support') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->bundle_inc;} and not $self->_mb_feature("inc_bundling_support")) 0 10 10
Condition33%1/3
@{$self->bundle_inc;} and not $self->_mb_feature("inc_bundling_support")
!ll&&!rl&&r
1000
MC/DC0%0/2
@{$self->bundle_inc;} and not $self->_mb_feature("inc_bundling_support")
@{$self->bundle_inc;} not $self->_mb_feature("inc_bundling_support")
Truth table33%1/3
A and not(B)
A= @{$self->bundle_inc;}B= not $self->_mb_feature("inc_bundling_support")
ABresult
0X0
100
111
4045 0 $self->_warn_mb_feature_deps('inc_bundling_support');
4046 0 die "Aborting.\n";
4047 }
4048  
4049 10 $self->depends_on('distmeta');
4050  
4051 10 ▶ my $dist_files = $self->_read_manifest('MANIFEST')
Branch: 1 branch
BranchTrueFalseTotal
my $dist_files = $self->_read_manifest("MANIFEST") or die "Can't create distdir without a MANIFEST file - run 'manifest' action first.\n" 10 0 10
4052 or die "Can't create distdir without a MANIFEST file - run 'manifest' action first.\n";
4053 10 delete $dist_files->{SIGNATURE}; # Don't copy, create a fresh one
4054 10 ▶ die "No files found in MANIFEST - try running 'manifest' action?\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $dist_files and keys %$dist_files 0 10 10
Condition33%1/3
$dist_files and keys %$dist_files
!ll&&!rl&&r
0010
MC/DC0%0/2
$dist_files and keys %$dist_files
$dist_files keys %$dist_files
Truth table33%1/3
A and B
A= $dist_filesB= keys %$dist_files
ABresult
0X0
100
111
4055 unless ($dist_files and keys %$dist_files);
4056 10 my $metafile = $self->metafile;
4057 $self->log_warn("*** Did you forget to add $metafile to the MANIFEST?\n")
4058 10 ▶ unless exists $dist_files->{$metafile};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $dist_files->{$metafile} 0 10 10
4059  
4060 10 my $dist_dir = $self->dist_dir;
4061 10 $self->delete_filetree($dist_dir);
4062 10 $self->log_info("Creating $dist_dir\n");
4063 10 $self->add_to_cleanup($dist_dir);
4064  
4065 10 foreach my $file (sort keys %$dist_files) {
4066 69 ▶ next if $file =~ m{^MYMETA\.}; # Double check that we skip MYMETA.*
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ /^MYMETA\./ 0 69 69
4067 69 my $new = $self->copy_if_modified(from => $file, to_dir => $dist_dir, verbose => 0);
4068 }
4069  
4070 10 ▶ $self->do_create_bundle_inc if @{$self->bundle_inc};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->bundle_inc;} 0 10 10
4071  
4072 10 ▶ $self->_sign_dir($dist_dir) if $self->{properties}{sign};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"properties"}{"sign"} 5 5 10
4073 }
4074  
4075 1 ▶sub ACTION_disttest {
Subroutine ACTION_disttest: called CC=1 SCAR=0.1
Pod undocumented
4076 1 my ($self) = @_;
4077  
4078 1 $self->depends_on('distdir');
4079  
4080 $self->_do_in_dir
4081 ( $self->dist_dir,
4082 1 ▶ sub {
Subroutine __ANON__: called CC=4 SCAR=14.6
4083 1 local $ENV{AUTHOR_TESTING} = 1;
4084 1 local $ENV{RELEASE_TESTING} = 1;
4085  
4086 # XXX could be different names for scripts
4087  
4088 1 ▶ $self->run_perl_script('Build.PL') # XXX Should this be run w/ --nouse-rcfile
Branch: 1 branch
BranchTrueFalseTotal
$self->run_perl_script("Build.PL") or die "Error executing 'Build.PL' in dist directory: $!" 1 0 1
4089 or die "Error executing 'Build.PL' in dist directory: $!";
4090 1 ▶ $self->run_perl_script($self->build_script)
Branch: 1 branch
BranchTrueFalseTotal
$self->run_perl_script($self->build_script) or die "Error executing $self->build_script in dist directory: $!" 1 0 1
4091 or die "Error executing $self->build_script in dist directory: $!";
4092 1 ▶ $self->run_perl_script($self->build_script, [], ['test'])
Branch: 1 branch
BranchTrueFalseTotal
$self->run_perl_script($self->build_script, [], ["test"]) or die "Error executing 'Build test' in dist directory" 1 0 1
4093 or die "Error executing 'Build test' in dist directory";
4094 1 });
4095 }
4096  
4097 0 ▶sub ACTION_distinstall {
Subroutine ACTION_distinstall: not called CC=1 SCAR=6.9
Pod undocumented
4098 0 my ($self, @args) = @_;
4099  
4100 0 $self->depends_on('distdir');
4101  
4102 $self->_do_in_dir ( $self->dist_dir,
4103 0 ▶ sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
4104 0 ▶ $self->run_perl_script('Build.PL')
Branch: 1 branch
BranchTrueFalseTotal
$self->run_perl_script("Build.PL") or die "Error executing 'Build.PL' in dist directory: $!" 0 0 0
4105 or die "Error executing 'Build.PL' in dist directory: $!";
4106 0 ▶ $self->run_perl_script($self->build_script)
Branch: 1 branch
BranchTrueFalseTotal
$self->run_perl_script($self->build_script) or die "Error executing $self->build_script in dist directory: $!" 0 0 0
4107 or die "Error executing $self->build_script in dist directory: $!";
4108 0 ▶ $self->run_perl_script($self->build_script, [], ['install'])
Branch: 1 branch
BranchTrueFalseTotal
$self->run_perl_script($self->build_script, [], ["install"]) or die "Error executing 'Build install' in dist directory" 0 0 0
4109 or die "Error executing 'Build install' in dist directory";
4110 }
4111 0 );
4112 }
4113  
4114 =begin private
4115  
4116 my $has_include = $build->_eumanifest_has_include;
4117  
4118 Returns true if the installed version of ExtUtils::Manifest supports
4119 #include and #include_default directives. False otherwise.
4120  
4121 =end private
4122  
4123 =cut
4124  
4125 # #!include and #!include_default were added in 1.50
4126 2 ▶sub _eumanifest_has_include {
Subroutine _eumanifest_has_include: called CC=1 SCAR=0.0
4127 2 my $self = shift;
4128  
4129 2 require ExtUtils::Manifest;
4130 2 return eval { ExtUtils::Manifest->VERSION(1.50); 1 };
4131 }
4132  
4133  
4134 =begin private
4135  
4136 my $maniskip_file = $build->_default_maniskip;
4137  
4138 Returns the location of the installed MANIFEST.SKIP file used by
4139 default.
4140  
4141 =end private
4142  
4143 =cut
4144  
4145 0 ▶sub _default_maniskip {
Subroutine _default_maniskip: not called CC=3 SCAR=24.8
4146 0 my $self = shift;
4147  
4148 0 my $default_maniskip;
4149 0 for my $dir (@INC) {
4150 0 $default_maniskip = File::Spec->catfile($dir, "ExtUtils", "MANIFEST.SKIP");
4151 0 ▶ last if -r $default_maniskip;
Branch: 1 branch
BranchTrueFalseTotal
if -r $default_maniskip 0 0 0
4152 }
4153  
4154 0 return $default_maniskip;
4155 }
4156  
4157  
4158 =begin private
4159  
4160 my $content = $build->_slurp($file);
4161  
4162 Reads $file and returns the $content.
4163  
4164 =end private
4165  
4166 =cut
4167  
4168 0 ▶sub _slurp {
Subroutine _slurp: not called CC=3 SCAR=24.8
4169 0 my $self = shift;
4170 0 my $file = shift;
4171 0 ▶ my $mode = shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
4172 0 ▶ open my $fh, "<$mode", $file or croak "Can't open $file for reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<$mode", $file or croak("Can't open $file for reading: $!") 0 0 0
4173 0 local $/;
4174 0 return <$fh>;
4175 }
4176  
4177 0 ▶sub _spew {
Subroutine _spew: not called CC=4 SCAR=30.0
4178 0 my $self = shift;
4179 0 my $file = shift;
4180 0 ▶ my $content = shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
4181 0 ▶ my $mode = shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
4182 0 ▶ open my $fh, ">$mode", $file or croak "Can't open $file for writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">$mode", $file or croak("Can't open $file for writing: $!") 0 0 0
4183 0 print {$fh} $content;
4184 0 close $fh;
4185 }
4186  
4187 35 ▶sub _case_tolerant {
Subroutine _case_tolerant: called CC=3 SCAR=11.0
4188 35 my $self = shift;
4189 35 ▶ if ( ref $self ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 34 1 35
4190 $self->{_case_tolerant} = File::Spec->case_tolerant
4191 34 ▶ unless defined($self->{_case_tolerant});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_case_tolerant"} 6 28 34
4192 34 return $self->{_case_tolerant};
4193 }
4194 else {
4195 1 return File::Spec->case_tolerant;
4196 }
4197 }
4198  
4199 0 ▶sub _append_maniskip {
Subroutine _append_maniskip: not called CC=5 SCAR=34.0
4200 0 my $self = shift;
4201 0 my $skip = shift;
4202 0 ▶ my $file = shift || 'MANIFEST.SKIP';
Condition0%0/2
shift() || 'MANIFEST.SKIP'
l!l
00
MC/DC0%0/1
shift() || 'MANIFEST.SKIP'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
4203 0 ▶ return unless defined $skip && length $skip;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $skip and length $skip 0 0 0
Condition0%0/3
defined $skip and length $skip
!ll&&!rl&&r
000
MC/DC0%0/2
defined $skip and length $skip
defined $skip length $skip
Truth table0%0/3
A and B
A= defined $skipB= length $skip
ABresult
0X0
100
111
4204 0 ▶ open(my $fh, '>>', $file)
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">>", $file or die "Can't open ${file}: $!" 0 0 0
4205 or die "Can't open $file: $!";
4206  
4207 0 print $fh "$skip\n";
4208 0 close $fh;
4209 }
4210  
4211 1 ▶sub _write_default_maniskip {
Subroutine _write_default_maniskip: called CC=4 SCAR=14.2
4212 1 my $self = shift;
4213 1 ▶ my $file = shift || 'MANIFEST.SKIP';
Condition50%1/2
shift() || 'MANIFEST.SKIP'
l!l
10
MC/DC0%0/1
shift() || 'MANIFEST.SKIP'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4214 1 ▶ open(my $fh, '>', $file)
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $file or die "Can't open ${file}: $!" 1 0 1
4215 or die "Can't open $file: $!";
4216  
4217 1 ▶ my $content = $self->_eumanifest_has_include ? "#!include_default\n"
Branch: 1 branch
BranchTrueFalseTotal
$self->_eumanifest_has_include ? : 1 0 1
4218 : $self->_slurp( $self->_default_maniskip );
4219  
4220 1 $content .= <<'EOF';
4221 # Avoid configuration metadata file
4222 ^MYMETA\.
4223  
4224 # Avoid Module::Build generated and utility files.
4225 \bBuild$
4226 \bBuild.bat$
4227 \b_build
4228 \bBuild.COM$
4229 \bBUILD.COM$
4230 \bbuild.com$
4231 ^MANIFEST\.SKIP
4232  
4233 # Avoid archives of this distribution
4234 EOF
4235  
4236 # Skip, for example, 'Module-Build-0.27.tar.gz'
4237 1 $content .= '\b'.$self->dist_name.'-[\d\.\_]+'."\n";
4238  
4239 1 print $fh $content;
4240
4241 1 close $fh;
4242  
4243 1 return;
4244 }
4245  
4246 0 ▶sub _check_manifest_skip {
Subroutine _check_manifest_skip: not called CC=2 SCAR=17.9
4247 0 my ($self) = @_;
4248  
4249 0 my $maniskip = 'MANIFEST.SKIP';
4250  
4251 0 ▶ if ( ! -e $maniskip ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -e $maniskip) { } 0 0 0
4252 0 $self->log_warn("File '$maniskip' does not exist: Creating a temporary '$maniskip'\n");
4253 0 $self->_write_default_maniskip($maniskip);
4254 0 $self->_unlink_on_exit($maniskip);
4255 }
4256 else {
4257 # MYMETA must not be added to MANIFEST, so always confirm the skip
4258 0 $self->_check_mymeta_skip( $maniskip );
4259 }
4260  
4261 0 return;
4262 }
4263  
4264 0 ▶sub ACTION_manifest {
Subroutine ACTION_manifest: not called CC=1 SCAR=6.9
Pod undocumented
4265 0 my ($self) = @_;
4266  
4267 0 $self->_check_manifest_skip;
4268  
4269 0 require ExtUtils::Manifest; # ExtUtils::Manifest is not warnings clean.
4270 0 local ($^W, $ExtUtils::Manifest::Quiet) = (0,1);
4271 0 ExtUtils::Manifest::mkmanifest();
4272 }
4273  
4274 0 ▶sub ACTION_manifest_skip {
Subroutine ACTION_manifest_skip: not called CC=2 SCAR=17.9
Pod undocumented
4275 0 my ($self) = @_;
4276  
4277 0 ▶ if ( -e 'MANIFEST.SKIP' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "MANIFEST.SKIP") 0 0 0
4278 0 $self->log_warn("MANIFEST.SKIP already exists.\n");
4279 0 return 0;
4280 }
4281 0 $self->log_info("Creating a new MANIFEST.SKIP file\n");
4282 0 return $self->_write_default_maniskip;
4283 0 return -e 'MANIFEST.SKIP'
4284 }
4285  
4286 # Case insensitive regex for files
4287 400 ▶sub file_qr {
Subroutine file_qr: called CC=2 SCAR=7.6
Pod undocumented
4288 400 ▶ return shift->{_case_tolerant} ? qr($_[0])i : qr($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->{'_case_tolerant'} ? : 0 400 400
4289 }
4290  
4291 29 ▶sub dist_dir {
Subroutine dist_dir: called CC=2 SCAR=6.9
Pod undocumented
4292 29 my ($self) = @_;
4293 29 my $dir = join "-", $self->dist_name, $self->dist_version;
4294 29 ▶ $dir .= "-" . $self->dist_suffix if $self->dist_suffix;
Branch: 1 branch
BranchTrueFalseTotal
if $self->dist_suffix 1 28 29
4295 29 return $dir;
4296 }
4297  
4298 8 ▶sub ppm_name {
Subroutine ppm_name: called CC=1 SCAR=0.0
Pod undocumented
4299 8 my $self = shift;
4300 8 return 'PPM-' . $self->dist_dir;
4301 }
4302  
4303 93 ▶sub _files_in {
Subroutine _files_in: called CC=5 SCAR=16.1
4304 93 my ($self, $dir) = @_;
4305 93 ▶ return unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 91 2 93
4306  
4307 2 local *DH;
4308 2 ▶ opendir DH, $dir or die "Can't read directory $dir: $!";
Branch: 1 branch
BranchTrueFalseTotal
opendir DH, $dir or die "Can't read directory ${dir}: $!" 2 0 2
4309  
4310 2 my @files;
4311 2 ▶ while (defined (my $file = readdir DH)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $file = readdir DH)) 8 2 10
4312 8 my $full_path = File::Spec->catfile($dir, $file);
4313 8 ▶ next if -d $full_path;
Branch: 1 branch
BranchTrueFalseTotal
if -d $full_path 4 4 8
4314 4 push @files, $full_path;
4315 }
4316 2 return @files;
4317 }
4318  
4319 179 ▶sub share_dir {
Subroutine share_dir: called CC=14 SCAR=32.5
Pod undocumented
4320 179 my $self = shift;
4321 179 my $p = $self->{properties};
4322  
4323 179 ▶ $p->{share_dir} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 179 179
4324  
4325 # Always coerce to proper hash form
4326 179 ▶ if ( ! defined $p->{share_dir} ) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $p->{'share_dir'}) { } 155 24 179
elsif (not ref $p->{'share_dir'}) { } 0 24 24
elsif (ref $p->{'share_dir'} eq 'ARRAY') { } 0 24 24
elsif (ref $p->{'share_dir'} eq 'HASH') { } 24 0 24
4327 155 return;
4328 }
4329 elsif ( ! ref $p->{share_dir} ) {
4330 # scalar -- treat as a single 'dist' directory
4331 0 $p->{share_dir} = { dist => [ $p->{share_dir} ] };
4332 }
4333 elsif ( ref $p->{share_dir} eq 'ARRAY' ) {
4334 # array -- treat as a list of 'dist' directories
4335 0 $p->{share_dir} = { dist => $p->{share_dir} };
4336 }
4337 elsif ( ref $p->{share_dir} eq 'HASH' ) {
4338 # hash -- check structure
4339 24 my $share_dir = $p->{share_dir};
4340 # check dist key
4341 24 ▶ if ( defined $share_dir->{dist} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $share_dir->{"dist"}) 24 0 24
4342 24 ▶ if ( ! ref $share_dir->{dist} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $share_dir->{'dist'}) { } 0 24 24
elsif (ref $share_dir->{'dist'} ne 'ARRAY') { } 0 24 24
4343 # scalar, so upgrade to arrayref
4344 0 $share_dir->{dist} = [ $share_dir->{dist} ];
4345 }
4346 elsif ( ref $share_dir->{dist} ne 'ARRAY' ) {
4347 0 die "'dist' key in 'share_dir' must be scalar or arrayref";
4348 }
4349 }
4350 # check module key
4351 24 ▶ if ( defined $share_dir->{module} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $share_dir->{"module"}) 6 18 24
4352 6 my $mod_hash = $share_dir->{module};
4353 6 ▶ if ( ref $mod_hash eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $mod_hash eq 'HASH') { } 6 0 6
4354 6 for my $k ( sort keys %$mod_hash ) {
4355 6 ▶ if ( ! ref $mod_hash->{$k} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $mod_hash->{$k}) { } 0 6 6
elsif (ref $mod_hash->{$k} ne 'ARRAY') { } 0 6 6
4356 0 $mod_hash->{$k} = [ $mod_hash->{$k} ];
4357 }
4358 elsif( ref $mod_hash->{$k} ne 'ARRAY' ) {
4359 0 die "modules in 'module' key of 'share_dir' must be scalar or arrayref";
4360 }
4361 }
4362 }
4363 else {
4364 0 die "'module' key in 'share_dir' must be hashref";
4365 }
4366 }
4367 }
4368 else {
4369 0 die "'share_dir' must be hashref, arrayref or string";
4370 }
4371  
4372 24 return $p->{share_dir};
4373 }
4374  
4375 107 ▶sub script_files {
Subroutine script_files: called CC=9 SCAR=24.8
Pod undocumented
4376 107 my $self = shift;
4377  
4378 107 for ($self->{properties}{script_files}) {
4379 107 ▶ $_ = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 107 107
4380 107 ▶ next unless $_;
Branch: 1 branch
BranchTrueFalseTotal
unless $_ 93 14 107
4381  
4382 # Always coerce into a hash
4383 14 ▶ return $_ if ref $_ eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "HASH" 0 14 14
4384 14 ▶ return $_ = { map {$_,1} @$_ } if ref $_ eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq "ARRAY" 14 0 14
4385  
4386 0 ▶ die "'script_files' must be a hashref, arrayref, or string" if ref();
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ 0 0 0
4387  
4388 0 ▶ return $_ = { map {$_,1} $self->_files_in( $_ ) } if -d $_;
Branch: 1 branch
BranchTrueFalseTotal
if -d $_ 0 0 0
4389 0 return $_ = {$_ => 1};
4390 }
4391  
4392 my %pl_files = map {
4393 21 File::Spec->canonpath( $_ ) => 1
4394 93 ▶ } keys %{ $self->PL_files || {} };
Condition100%2/2
$self->PL_files || {}
l!l
1974
MC/DC100%1/1
$self->PL_files || {}
$self->PL_files
Truth table100%2/2
A
A= $self->PL_files
Aresult
11
00
4395  
4396 93 my @bin_files = $self->_files_in('bin');
4397  
4398 my %bin_map = map {
4399 93 $_ => File::Spec->canonpath( $_ )
4400 } @bin_files;
4401  
4402 93 return $_ = { map {$_ => 1} grep !$pl_files{$bin_map{$_}}, @bin_files };
4403 }
4404 297 ▶BEGIN { *scripts = \&script_files; }
Subroutine BEGIN: called CC=1 SCAR=0.0
4405  
4406 {
4407 297 my %licenses = (
4408 perl => 'Perl_5',
4409 apache => 'Apache_2_0',
4410 apache_1_1 => 'Apache_1_1',
4411 artistic => 'Artistic_1',
4412 artistic_2 => 'Artistic_2',
4413 lgpl => 'LGPL_2_1',
4414 lgpl2 => 'LGPL_2_1',
4415 lgpl3 => 'LGPL_3_0',
4416 bsd => 'BSD',
4417 gpl => 'GPL_1',
4418 gpl2 => 'GPL_2',
4419 gpl3 => 'GPL_3',
4420 mit => 'MIT',
4421 mozilla => 'Mozilla_1_1',
4422 restrictive => 'Restricted',
4423 open_source => undef,
4424 unrestricted => undef,
4425 unknown => undef,
4426 );
4427  
4428 # TODO - would be nice to not have these here, since they're more
4429 # properly stored only in Software::License
4430 297 my %license_urls = (
4431 perl => 'http://dev.perl.org/licenses/',
4432 apache => 'http://apache.org/licenses/LICENSE-2.0',
4433 apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1',
4434 artistic => 'http://opensource.org/licenses/artistic-license.php',
4435 artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php',
4436 lgpl => 'http://opensource.org/licenses/lgpl-license.php',
4437 lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php',
4438 lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html',
4439 bsd => 'http://opensource.org/licenses/bsd-license.php',
4440 gpl => 'http://opensource.org/licenses/gpl-license.php',
4441 gpl2 => 'http://opensource.org/licenses/gpl-2.0.php',
4442 gpl3 => 'http://opensource.org/licenses/gpl-3.0.html',
4443 mit => 'http://opensource.org/licenses/mit-license.php',
4444 mozilla => 'http://opensource.org/licenses/mozilla1.1.php',
4445 restrictive => undef,
4446 open_source => undef,
4447 unrestricted => undef,
4448 unknown => undef,
4449 );
4450 69 ▶ sub valid_licenses {
Subroutine valid_licenses: called CC=1 SCAR=0.0
Pod undocumented
4451 69 return \%licenses;
4452 }
4453 22 ▶ sub _license_url {
Subroutine _license_url: called CC=1 SCAR=0.0
4454 22 return $license_urls{$_[1]};
4455 }
4456 }
4457  
4458 297 ▶sub _software_license_class {
Subroutine _software_license_class: called CC=7 SCAR=22.0
4459 23 my ($self, $license) = @_;
4460 0 ▶ if ($self->valid_licenses->{$license} && eval { require Software::LicenseUtils; Software::LicenseUtils->VERSION(0.103009) }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->valid_licenses->{$license} and eval { do { require Software::LicenseUtils; "Software::LicenseUtils"->VERSION("0.103009") } }) 0 23 23
Condition66%2/3
$self->valid_licenses->{$license} and eval { do { require Software::LicenseUtils; "Software::LicenseUtils"->VERSION("0.103009") } }
!ll&&!rl&&r
3200
MC/DC0%0/2
$self->valid_licenses->{$license} and eval { do { require Software::LicenseUtils; "Software::LicenseUtils"->VERSION("0.103009") } }
$self->valid_licenses->{$license} eval { do { require Software::LicenseUtils; "Software::LicenseUtils"->VERSION("0.103009") } }
Truth table66%2/3
A and B
A= $self->valid_licenses->{$license}B= eval { do { require Software::LicenseUtils; "Software::LicenseUtils"->VERSION("0.103009") } }
ABresult
0X0
100
111
4461 0 my @classes = Software::LicenseUtils->guess_license_from_meta_key($license, 1);
4462 0 ▶ if (@classes == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@classes == 1) 0 0 0
4463 0 eval "require $classes[0]";
4464 0 return $classes[0];
4465 }
4466 }
4467 23 LICENSE: for my $l ( $self->valid_licenses->{ $license }, $license ) {
4468 46 ▶ next unless defined $l;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $l 3 43 46
4469 43 my $trial = "Software::License::" . $l;
4470 43 ▶ if ( eval "require Software::License; Software::License->VERSION(0.014); require $trial; 1" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "require Software::License; Software::License->VERSION(0.014); require $trial; 1") 1 42 43
4471 1 return $trial;
4472 }
4473 }
4474 22 return;
4475 }
4476  
4477 # use mapping or license name directly
4478 23 ▶sub _software_license_object {
Subroutine _software_license_object: called CC=5 SCAR=16.6
4479 23 my ($self) = @_;
4480 23 ▶ return unless defined( my $license = $self->license );
Branch: 1 branch
BranchTrueFalseTotal
unless defined(my $license = $self->license) 0 23 23
4481  
4482 23 ▶ my $class = $self->_software_license_class($license) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $class = $self->_software_license_class($license) or return 1 22 23
4483  
4484 # Software::License requires a 'holder' argument
4485 1 ▶ my $author = join( " & ", @{ $self->dist_author }) || 'unknown';
Condition50%1/2
join(' & ', @{$self->dist_author;}) || 'unknown'
l!l
10
MC/DC0%0/1
join(' & ', @{$self->dist_author;}) || 'unknown'
join(' & ', @{$self->dist_author;})
Truth table50%1/2
A
A= join(' & ', @{$self->dist_author;})
Aresult
11
00
4486 1 my $sl = eval { $class->new({holder=>$author}) };
4487 1 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
4488 0 $self->log_warn( "Error getting '$class' object: $@" );
4489 }
4490  
4491 1 return $sl;
4492 }
4493  
4494 0 ▶sub _hash_merge {
Subroutine _hash_merge: not called CC=5 SCAR=34.0
4495 0 my ($self, $h, $k, $v) = @_;
4496 0 ▶ if (ref $h->{$k} eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $h->{$k} eq 'ARRAY') { } 0 0 0
elsif (ref $h->{$k} eq 'HASH') { } 0 0 0
4497 0 ▶ push @{$h->{$k}}, ref $v ? @$v : $v;
Branch: 1 branch
BranchTrueFalseTotal
ref $v ? : 0 0 0
4498 } elsif (ref $h->{$k} eq 'HASH') {
4499 0 $h->{$k}{$_} = $v->{$_} foreach keys %$v;
4500 } else {
4501 0 $h->{$k} = $v;
4502 }
4503 }
4504  
4505 13 ▶sub ACTION_distmeta {
Subroutine ACTION_distmeta: called CC=4 SCAR=14.6
Pod undocumented
4506 13 my ($self) = @_;
4507 13 ▶ $self->do_create_makefile_pl if $self->create_makefile_pl;
Branch: 1 branch
BranchTrueFalseTotal
if $self->create_makefile_pl 0 13 13
4508 13 ▶ $self->do_create_readme if $self->create_readme;
Branch: 1 branch
BranchTrueFalseTotal
if $self->create_readme 0 13 13
4509 13 ▶ $self->do_create_license if $self->create_license;
Branch: 1 branch
BranchTrueFalseTotal
if $self->create_license 0 13 13
4510 13 $self->do_create_metafile;
4511 }
4512  
4513 13 ▶sub do_create_metafile {
Subroutine do_create_metafile: called CC=8 SCAR=22.5
Pod undocumented
4514 13 my $self = shift;
4515 13 ▶ return if $self->{wrote_metadata};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"wrote_metadata"} 4 9 13
4516  
4517 9 my $p = $self->{properties};
4518  
4519 9 ▶ unless ($p->{license}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($p->{"license"}) 0 9 9
4520 0 $self->log_warn("No license specified, setting license = 'unknown'\n");
4521 0 $p->{license} = 'unknown';
4522 }
4523  
4524 9 my @metafiles = ( $self->metafile, $self->metafile2 );
4525 # If we're in the distdir, the metafile may exist and be non-writable.
4526 9 $self->delete_filetree($_) for @metafiles;
4527  
4528 # Since we're building ourself, we have to do some special stuff
4529 # here: the ConfigData module is found in blib/lib.
4530 9 local @INC = @INC;
4531 9 ▶ if (($self->module_name || '') eq 'Module::Build') {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->module_name || "") eq "Module::Build") 0 9 9
Condition50%1/2
$self->module_name || ''
l!l
90
MC/DC0%0/1
$self->module_name || ''
$self->module_name
Truth table50%1/2
A
A= $self->module_name
Aresult
11
00
4532 0 $self->depends_on('config_data');
4533 0 push @INC, File::Spec->catdir($self->blib, 'lib');
4534 }
4535  
4536 9 my $meta_obj = $self->_get_meta_object(
4537 quiet => 1, fatal => 1, auto => 1
4538 );
4539 9 my @created = $self->_write_meta_files( $meta_obj, 'META' );
4540 9 ▶ if ( @created ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@created) 9 0 9
4541 9 $self->{wrote_metadata} = 1;
4542 9 $self->_add_to_manifest('MANIFEST', $_) for @created;
4543 }
4544 9 return 1;
4545 }
4546  
4547 15 ▶sub _write_meta_files {
Subroutine _write_meta_files: called CC=6 SCAR=19.9
4548 15 my $self = shift;
4549 15 my ($meta, $file) = @_;
4550 15 $file =~ s{\.(?:yml|json)$}{};
4551  
4552 15 my @created;
4553 15 ▶ push @created, "$file\.yml"
Branch: 1 branch
BranchTrueFalseTotal
if $meta and $meta->save("$file.yml", {"version", "1.4"}) 15 0 15
Condition33%1/3
$meta and $meta->save("$file.yml", {"version", "1.4"})
!ll&&!rl&&r
0015
MC/DC0%0/2
$meta and $meta->save("$file.yml", {"version", "1.4"})
$meta $meta->save("$file.yml", {"version", "1.4"})
Truth table33%1/3
A and B
A= $metaB= $meta->save("$file.yml", {"version", "1.4"})
ABresult
0X0
100
111
4554 if $meta && $meta->save( "$file\.yml", {version => "1.4"} );
4555 15 ▶ push @created, "$file\.json"
Branch: 1 branch
BranchTrueFalseTotal
if $meta and $meta->save("$file.json") 15 0 15
Condition33%1/3
$meta and $meta->save("$file.json")
!ll&&!rl&&r
0015
MC/DC0%0/2
$meta and $meta->save("$file.json")
$meta $meta->save("$file.json")
Truth table33%1/3
A and B
A= $metaB= $meta->save("$file.json")
ABresult
0X0
100
111
4556 if $meta && $meta->save( "$file\.json" );
4557  
4558 15 ▶ if ( @created ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@created) 15 0 15
4559 15 $self->log_info("Created " . join(" and ", @created) . "\n");
4560 }
4561 15 return @created;
4562 }
4563  
4564 15 ▶sub _get_meta_object {
Subroutine _get_meta_object: called CC=5 SCAR=16.8
4565 15 my $self = shift;
4566 15 my %args = @_;
4567 15 ▶ return unless $self->try_require("CPAN::Meta", "2.142060");
Branch: 1 branch
BranchTrueFalseTotal
unless $self->try_require("CPAN::Meta", "2.142060") 0 15 15
4568  
4569 15 my $meta;
4570 15 eval {
4571 my $data = $self->get_metadata(
4572 fatal => $args{fatal},
4573 auto => $args{auto},
4574 15 );
4575 15 ▶ $data->{dynamic_config} = $args{dynamic} if defined $args{dynamic};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"dynamic"} 6 9 15
4576 15 $meta = CPAN::Meta->create($data);
4577 };
4578 15 ▶ if ($@ && ! $args{quiet}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ and not $args{"quiet"}) 0 15 15
Condition33%1/3
$@ and not $args{"quiet"}
!ll&&!rl&&r
1500
MC/DC0%0/2
$@ and not $args{"quiet"}
$@ not $args{"quiet"}
Truth table33%1/3
A and not(B)
A= $@B= not $args{"quiet"}
ABresult
0X0
100
111
4579 0 $self->log_warn(
4580 "Could not get valid metadata. Error is: $@\n"
4581 );
4582 }
4583  
4584 15 return $meta;
4585 }
4586  
4587 0 ▶sub read_metafile {
Subroutine read_metafile: not called CC=2 SCAR=17.9
Pod undocumented
4588 0 my $self = shift;
4589 0 my ($metafile) = @_;
4590  
4591 0 ▶ return unless $self->try_require("CPAN::Meta", "2.110420");
Branch: 1 branch
BranchTrueFalseTotal
unless $self->try_require("CPAN::Meta", "2.110420") 0 0 0
4592 0 my $meta = CPAN::Meta->load_file($metafile);
4593 0 return $meta->as_struct( {version => "2.0"} );
4594 }
4595  
4596 125 ▶sub normalize_version {
Subroutine normalize_version: called CC=7 SCAR=20.1
Pod undocumented
4597 125 my ($self, $version) = @_;
4598 125 ▶ $version = 0 unless defined $version and length $version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version and length $version 3 122 125
Condition100%3/3
defined $version and length $version
!ll&&!rl&&r
21122
MC/DC100%2/2
defined $version and length $version
defined $version length $version
Truth table100%3/3
A and B
A= defined $versionB= length $version
ABresult
0X0
100
111
4599  
4600 125 ▶ if ( $version =~ /[=<>!,]/ ) { # logic, not just version
Branch: 3 branches
BranchTrueFalseTotal
if ($version =~ /[=<>!,]/) { } 0 125 125
elsif (ref $version eq 'version') { } 81 44 125
elsif ($version =~ /^[^v][^.]*\.[^.]+\./) { } 0 44 44
4601 # take as is without modification
4602 }
4603 elsif ( ref $version eq 'version') { # version objects
4604 81 ▶ $version = $version->is_qv ? $version->normal : $version->stringify;
Branch: 1 branch
BranchTrueFalseTotal
$version->is_qv ? : 0 81 81
4605 }
4606 elsif ( $version =~ /^[^v][^.]*\.[^.]+\./ ) { # no leading v, multiple dots
4607 # normalize string tuples without "v": "1.2.3" -> "v1.2.3"
4608 0 $version = "v$version";
4609 }
4610 else {
4611 # leave alone
4612 }
4613 125 return $version;
4614 }
4615  
4616 297 my %prereq_map = (
4617 requires => [ qw/runtime requires/],
4618 configure_requires => [qw/configure requires/],
4619 build_requires => [ qw/build requires/ ],
4620 test_requires => [ qw/test requires/ ],
4621 test_recommends => [ qw/test recommends/ ],
4622 recommends => [ qw/runtime recommends/ ],
4623 conflicts => [ qw/runtime conflicts/ ],
4624 );
4625  
4626 26 ▶sub _normalize_prereqs {
Subroutine _normalize_prereqs: called CC=5 SCAR=16.1
4627 26 my ($self) = @_;
4628 26 my $p = $self->{properties};
4629  
4630 # copy prereq data structures so we can modify them before writing to META
4631 26 my %prereq_types;
4632 26 for my $type ( 'configure_requires', @{$self->prereq_action_types} ) {
4633 156 ▶ if (exists $p->{$type} and keys %{ $p->{$type} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $p->{$type} and keys %{$$p{$type};}) 21 135 156
Condition66%2/3
exists $p->{$type} and keys %{$$p{$type};}
!ll&&!rl&&r
013521
MC/DC50%1/2
exists $p->{$type} and keys %{$$p{$type};}
exists $p->{$type} keys %{$$p{$type};}
Truth table66%2/3
A and B
A= exists $p->{$type}B= keys %{$$p{$type};}
ABresult
0X0
100
111
4634 21 my ($phase, $relation) = @{ $prereq_map{$type} };
4635 21 for my $mod ( keys %{ $p->{$type} } ) {
4636 21 $prereq_types{$phase}{$relation}{$mod} = $self->normalize_version($p->{$type}{$mod});
4637 }
4638 }
4639 }
4640 26 return \%prereq_types;
4641 }
4642  
4643 23 ▶sub _get_license {
Subroutine _get_license: called CC=4 SCAR=14.0
4644 23 my $self = shift;
4645  
4646 23 my $license = $self->license;
4647 23 my ($meta_license, $meta_license_url);
4648  
4649 23 my $valid_licenses = $self->valid_licenses();
4650 23 ▶ if ( my $sl = $self->_software_license_object ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $sl = $self->_software_license_object) { } 1 22 23
elsif (exists $valid_licenses->{$license}) { } 22 0 22
4651 1 $meta_license = $sl->meta2_name;
4652 1 $meta_license_url = $sl->url;
4653 }
4654 elsif ( exists $valid_licenses->{$license} ) {
4655 22 ▶ $meta_license = $valid_licenses->{$license} ? lc $valid_licenses->{$license} : $license;
Branch: 1 branch
BranchTrueFalseTotal
$valid_licenses->{$license} ? : 20 2 22
4656 22 $meta_license_url = $self->_license_url( $license );
4657 }
4658 else {
4659 0 $self->log_warn( "Can not determine license type for '" . $self->license
4660 . "'\nSetting META license field to 'unknown'.\n");
4661 0 $meta_license = 'unknown';
4662 }
4663 23 return ($meta_license, $meta_license_url);
4664 }
4665  
4666 23 ▶sub get_metadata {
Subroutine get_metadata: called CC=19 SCAR=33.1
Pod undocumented
4667 23 my ($self, %args) = @_;
4668  
4669 23 ▶ my $fatal = $args{fatal} || 0;
Condition100%2/2
$args{'fatal'} || 0
l!l
158
MC/DC100%1/1
$args{'fatal'} || 0
$args{'fatal'}
Truth table100%2/2
A
A= $args{'fatal'}
Aresult
11
00
4670 23 my $p = $self->{properties};
4671  
4672 23 ▶ $self->auto_config_requires if $args{auto};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"auto"} 11 12 23
4673  
4674 # validate required fields
4675 23 foreach my $f (qw(dist_name dist_version dist_author dist_abstract license)) {
4676 115 my $field = $self->$f();
4677 115 ▶ unless ( defined $field and length $field ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $field and length $field) 0 115 115
Condition33%1/3
defined $field and length $field
!ll&&!rl&&r
00115
MC/DC0%0/2
defined $field and length $field
defined $field length $field
Truth table33%1/3
A and B
A= defined $fieldB= length $field
ABresult
0X0
100
111
4678 0 my $err = "ERROR: Missing required field '$f' for metafile\n";
4679 0 ▶ if ( $fatal ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fatal) { } 0 0 0
4680 0 die $err;
4681 }
4682 else {
4683 0 $self->log_warn($err);
4684 }
4685 }
4686 }
4687  
4688 my %metadata = (
4689 name => $self->dist_name,
4690 version => $self->normalize_version($self->dist_version),
4691 author => $self->dist_author,
4692 abstract => $self->dist_abstract,
4693 generated_by => "Module::Build version $Module::Build::VERSION",
4694 'meta-spec' => {
4695 version => '2',
4696 url => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec',
4697 },
4698 23 ▶ dynamic_config => exists $p->{dynamic_config} ? $p->{dynamic_config} : 1,
Branch: 1 branch
BranchTrueFalseTotal
exists $p->{'dynamic_config'} ? : 23 0 23
4699 release_status => $self->release_status,
4700 );
4701  
4702 23 my ($meta_license, $meta_license_url) = $self->_get_license;
4703 23 $metadata{license} = [ $meta_license ];
4704 23 ▶ $metadata{resources}{license} = [ $meta_license_url ] if defined $meta_license_url;
Branch: 1 branch
BranchTrueFalseTotal
if defined $meta_license_url 21 2 23
4705  
4706 23 $metadata{prereqs} = $self->_normalize_prereqs;
4707  
4708 23 ▶ if (exists $p->{no_index}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $p->{'no_index'}) { } 0 23 23
elsif (my $pkgs = eval { do { $self->find_dist_packages } }) { } 19 4 23
4709 0 $metadata{no_index} = $p->{no_index};
4710 23 } elsif (my $pkgs = eval { $self->find_dist_packages }) {
4711 19 ▶ $metadata{provides} = $pkgs if %$pkgs;
Branch: 1 branch
BranchTrueFalseTotal
if %$pkgs 18 1 19
4712 } else {
4713 4 $self->log_warn("$@\nWARNING: Possible missing or corrupt 'MANIFEST' file.\n" .
4714 "Nothing to enter for 'provides' field in metafile.\n");
4715 }
4716  
4717 23 ▶ if (my $add = $self->meta_add) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $add = $self->meta_add) 23 0 23
4718 23 ▶ if (not exists $add->{'meta-spec'} or $add->{'meta-spec'}{version} != 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $add->{"meta-spec"} or $add->{"meta-spec"}{"version"} != 2) 23 0 23
Condition33%1/3
not exists $add->{"meta-spec"} or $add->{"meta-spec"}{"version"} != 2
l!l&&r!l&&!r
2300
MC/DC0%0/2
not exists $add->{"meta-spec"} or $add->{"meta-spec"}{"version"} != 2
not exists $add->{"meta-spec"} $add->{"meta-spec"}{"version"} != 2
Truth table33%1/3
not(A) or B
A= not exists $add->{"meta-spec"}B= $add->{"meta-spec"}{"version"} != 2
ABresult
1X1
011
000
4719 23 require CPAN::Meta::Converter;
4720 23 ▶ if (CPAN::Meta::Converter->VERSION('2.141170')) {
Branch: 1 branch
BranchTrueFalseTotal
if ('CPAN::Meta::Converter'->VERSION('2.141170')) { } 23 0 23
4721 23 $add = CPAN::Meta::Converter->new($add)->upgrade_fragment;
4722 23 delete $add->{prereqs}; # XXX this would now overwrite all prereqs
4723 }
4724 else {
4725 0 $self->log_warn("Can't meta_add without CPAN::Meta 2.141170");
4726 }
4727 }
4728  
4729 23 ▶ while (my($k, $v) = each %{$add}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$add;}) 30 23 53
4730 30 $metadata{$k} = $v;
4731 }
4732 }
4733  
4734 23 ▶ if (my $merge = $self->meta_merge) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $merge = $self->meta_merge) 23 0 23
4735 23 ▶ if (eval { require CPAN::Meta::Merge }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require CPAN::Meta::Merge } }) { } 23 0 23
4736 23 %metadata = %{ CPAN::Meta::Merge->new(default_version => '1.4')->merge(\%metadata, $merge) };
4737 }
4738 else {
4739 0 $self->log_warn("Can't merge without CPAN::Meta::Merge");
4740 }
4741 }
4742  
4743 23 return \%metadata;
4744 }
4745  
4746 # To preserve compatibility with old API, $node *must* be a hashref
4747 # passed in to prepare_metadata. $keys is an arrayref holding a
4748 # list of keys -- it's use is optional and generally no longer needed
4749 # but kept for back compatibility. $args is an optional parameter to
4750 # support the new 'fatal' toggle
4751  
4752 0 ▶sub prepare_metadata {
Subroutine prepare_metadata: not called CC=3 SCAR=24.8
Pod undocumented
4753 0 my ($self, $node, $keys, $args) = @_;
4754 0 ▶ unless ( ref $node eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $node eq "HASH") 0 0 0
4755 0 croak "prepare_metadata() requires a hashref argument to hold output\n";
4756 }
4757 0 ▶ croak 'Keys argument to prepare_metadata is no longer supported' if $keys;
Branch: 1 branch
BranchTrueFalseTotal
if $keys 0 0 0
4758 0 %{$node} = %{ $self->get_meta(%{$args}) };
4759 0 return $node;
4760 }
4761  
4762 63 ▶sub _read_manifest {
Subroutine _read_manifest: called CC=2 SCAR=6.9
4763 63 my ($self, $file) = @_;
4764 63 ▶ return undef unless -e $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 12 51 63
4765  
4766 51 require ExtUtils::Manifest; # ExtUtils::Manifest is not warnings clean.
4767 51 local ($^W, $ExtUtils::Manifest::Quiet) = (0,1);
4768 51 return scalar ExtUtils::Manifest::maniread($file);
4769 }
4770  
4771 23 ▶sub find_dist_packages {
Subroutine find_dist_packages: called CC=2 SCAR=6.9
Pod undocumented
4772 23 my $self = shift;
4773  
4774 # Only packages in .pm files are candidates for inclusion here.
4775 # Only include things in the MANIFEST, not things in developer's
4776 # private stock.
4777  
4778 23 ▶ my $manifest = $self->_read_manifest('MANIFEST')
Branch: 1 branch
BranchTrueFalseTotal
my $manifest = $self->_read_manifest("MANIFEST") or die "Can't find dist packages without a MANIFEST file\nRun 'Build manifest' to generate one\n" 19 4 23
4779 or die "Can't find dist packages without a MANIFEST file\nRun 'Build manifest' to generate one\n";
4780  
4781 # Localize
4782 19 my %dist_files = map { $self->localize_file_path($_) => $_ }
4783 keys %$manifest;
4784  
4785 18 my @pm_files = sort grep { $_ !~ m{^t} } # skip things in t/
4786 18 grep {exists $dist_files{$_}}
4787 19 keys %{ $self->find_pm_files };
4788  
4789 19 return $self->find_packages_in_files(\@pm_files, \%dist_files);
4790 }
4791  
4792 # XXX Do not document this function; mst wrote it and now says the API is
4793 # stupid and needs to be fixed and it shouldn't become a public API until then
4794 19 ▶sub find_packages_in_files {
Subroutine find_packages_in_files: called CC=20 SCAR=46.1
Pod undocumented
4795 19 my ($self, $file_list, $filename_map) = @_;
4796  
4797 # First, we enumerate all packages & versions,
4798 # separating into primary & alternative candidates
4799 19 my( %prime, %alt );
4800 19 foreach my $file (@{$file_list}) {
4801 18 my $mapped_filename = $filename_map->{$file};
4802 18 my @path = split( /\//, $mapped_filename );
4803 18 (my $prime_package = join( '::', @path[1..$#path] )) =~ s/\.pm$//;
4804  
4805 18 my $pm_info = Module::Metadata->new_from_file( $file );
4806  
4807 18 foreach my $package ( $pm_info->packages_inside ) {
4808 18 ▶ next if $package eq 'main'; # main can appear numerous times, ignore
Branch: 1 branch
BranchTrueFalseTotal
if $package eq "main" 0 18 18
4809 18 ▶ next if $package eq 'DB'; # special debugging package, ignore
Branch: 1 branch
BranchTrueFalseTotal
if $package eq "DB" 0 18 18
4810 18 ▶ next if grep /^_/, split( /::/, $package ); # private package, ignore
Branch: 1 branch
BranchTrueFalseTotal
if grep /^_/, split(/::/, $package, 0) 0 18 18
4811  
4812 18 my $version = $pm_info->version( $package );
4813  
4814 18 ▶ if ( $package eq $prime_package ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($package eq $prime_package) { } 18 0 18
4815 18 ▶ if ( exists( $prime{$package} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $prime{$package}) { } 0 18 18
4816 # Module::Metadata will handle this conflict
4817 0 die "Unexpected conflict in '$package'; multiple versions found.\n";
4818 } else {
4819 18 $prime{$package}{file} = $mapped_filename;
4820 18 ▶ $prime{$package}{version} = $version if defined( $version );
Branch: 1 branch
BranchTrueFalseTotal
if defined $version 18 0 18
4821 }
4822 } else {
4823 0 push( @{$alt{$package}}, {
4824 file => $mapped_filename,
4825 version => $version,
4826 } );
4827 }
4828 }
4829 }
4830  
4831 # Then we iterate over all the packages found above, identifying conflicts
4832 # and selecting the "best" candidate for recording the file & version
4833 # for each package.
4834 19 foreach my $package ( sort keys( %alt ) ) {
4835 0 my $result = $self->_resolve_module_versions( $alt{$package} );
4836  
4837 0 ▶ if ( exists( $prime{$package} ) ) { # primary package selected
Branch: 1 branch
BranchTrueFalseTotal
if (exists $prime{$package}) { } 0 0 0
4838  
4839 0 ▶ if ( $result->{err} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($result->{'err'}) { } 0 0 0
elsif (defined $result->{'version'}) { } 0 0 0
4840 # Use the selected primary package, but there are conflicting
4841 # errors among multiple alternative packages that need to be
4842 # reported
4843 $self->log_warn(
4844 "Found conflicting versions for package '$package'\n" .
4845 " $prime{$package}{file} ($prime{$package}{version})\n" .
4846 $result->{err}
4847 0 );
4848  
4849 } elsif ( defined( $result->{version} ) ) {
4850 # There is a primary package selected, and exactly one
4851 # alternative package
4852  
4853 0 ▶ if ( exists( $prime{$package}{version} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $prime{$package}{'version'} and defined $prime{$package}{'version'}) { } 0 0 0
Condition0%0/3
exists $prime{$package}{"version"} and defined $prime{$package}{"version"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $prime{$package}{"version"} and defined $prime{$package}{"version"}
exists $prime{$package}{"version"} defined $prime{$package}{"version"}
Truth table0%0/3
A and B
A= exists $prime{$package}{"version"}B= defined $prime{$package}{"version"}
ABresult
0X0
100
111
4854 defined( $prime{$package}{version} ) ) {
4855 # Unless the version of the primary package agrees with the
4856 # version of the alternative package, report a conflict
4857 0 ▶ if ( $self->compare_versions( $prime{$package}{version}, '!=',
Branch: 1 branch
BranchTrueFalseTotal
if ($self->compare_versions($prime{$package}{"version"}, "!=", $result->{"version"})) 0 0 0
4858 $result->{version} ) ) {
4859 0 $self->log_warn(
4860 "Found conflicting versions for package '$package'\n" .
4861 " $prime{$package}{file} ($prime{$package}{version})\n" .
4862 " $result->{file} ($result->{version})\n"
4863 );
4864 }
4865  
4866 } else {
4867 # The prime package selected has no version so, we choose to
4868 # use any alternative package that does have a version
4869 0 $prime{$package}{file} = $result->{file};
4870 0 $prime{$package}{version} = $result->{version};
4871 }
4872  
4873 } else {
4874 # no alt package found with a version, but we have a prime
4875 # package so we use it whether it has a version or not
4876 }
4877  
4878 } else { # No primary package was selected, use the best alternative
4879  
4880 0 ▶ if ( $result->{err} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{"err"}) 0 0 0
4881 $self->log_warn(
4882 "Found conflicting versions for package '$package'\n" .
4883 $result->{err}
4884 0 );
4885 }
4886  
4887 # Despite possible conflicting versions, we choose to record
4888 # something rather than nothing
4889 0 $prime{$package}{file} = $result->{file};
4890 $prime{$package}{version} = $result->{version}
4891 0 ▶ if defined( $result->{version} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $result->{"version"} 0 0 0
4892 }
4893 }
4894  
4895 # Normalize versions or delete them if undef/0
4896 19 for my $provides ( values %prime ) {
4897 18 ▶ if ( $provides->{version} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($provides->{'version'}) { } 18 0 18
4898 $provides->{version} = $self->normalize_version( $provides->{version} )
4899 18 }
4900 else {
4901 0 delete $provides->{version};
4902 }
4903 }
4904  
4905 19 return \%prime;
4906 }
4907  
4908 # separate out some of the conflict resolution logic from
4909 # $self->find_dist_packages(), above, into a helper function.
4910 #
4911 0 ▶sub _resolve_module_versions {
Subroutine _resolve_module_versions: not called CC=8 SCAR=42.8
4912 0 my $self = shift;
4913  
4914 0 my $packages = shift;
4915  
4916 0 my( $file, $version );
4917 0 my $err = '';
4918 0 foreach my $p ( @$packages ) {
4919 0 ▶ if ( defined( $p->{version} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $p->{"version"}) 0 0 0
4920 0 ▶ if ( defined( $version ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $version) { } 0 0 0
4921 0 ▶ if ( $self->compare_versions( $version, '!=', $p->{version} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->compare_versions($version, '!=', $p->{'version'})) { } 0 0 0
4922 0 $err .= " $p->{file} ($p->{version})\n";
4923 } else {
4924 # same version declared multiple times, ignore
4925 }
4926 } else {
4927 0 $file = $p->{file};
4928 0 $version = $p->{version};
4929 }
4930 }
4931 0 ▶ $file ||= $p->{file} if defined( $p->{file} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->{"file"} 0 0 0
Condition0%0/3
$file ||= $p->{"file"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$file ||= $p->{"file"}
$file $p->{"file"}
Truth table0%0/3
A ||= B
A= $fileB= $p->{"file"}
ABresult
1X1
011
000
4932 }
4933  
4934 0 ▶ if ( $err ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err) 0 0 0
4935 0 $err = " $file ($version)\n" . $err;
4936 }
4937  
4938 0 my %result = (
4939 file => $file,
4940 version => $version,
4941 err => $err
4942 );
4943  
4944 0 return \%result;
4945 }
4946  
4947 4 ▶sub make_tarball {
Subroutine make_tarball: called CC=11 SCAR=31.3
Pod undocumented
4948 4 my ($self, $dir, $file) = @_;
4949 4 ▶ $file ||= $dir;
Condition66%2/3
$file ||= $dir
l!l&&r!l&&!r
310
MC/DC0%0/2
$file ||= $dir
$file $dir
Truth table66%2/3
A ||= B
A= $fileB= $dir
ABresult
1X1
011
000
4950  
4951 4 $self->log_info("Creating $file.tar.gz\n");
4952  
4953 4 ▶ if ($self->{args}{tar}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'args'}{'tar'}) { } 0 4 4
4954 0 ▶ my $tar_flags = $self->verbose ? 'cvf' : 'cf';
Branch: 1 branch
BranchTrueFalseTotal
$self->verbose ? : 0 0 0
4955  
4956 # See ExtUtils::MM_Darwin
4957 # 10.4 wants COPY_EXTENDED_ATTRIBUTES_DISABLE.
4958 # 10.5 wants COPYFILE_DISABLE.
4959 # So just set both.
4960 0 ▶ local $ENV{COPY_EXTENDED_ATTRIBUTES_DISABLE} = 1 if $^O eq 'darwin';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "darwin" 0 0 0
4961 0 ▶ local $ENV{COPYFILE_DISABLE} = 1 if $^O eq 'darwin';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "darwin" 0 0 0
4962  
4963 0 $self->do_system($self->split_like_shell($self->{args}{tar}), $tar_flags, "$file.tar", $dir);
4964 0 ▶ $self->do_system($self->split_like_shell($self->{args}{gzip}), "$file.tar") if $self->{args}{gzip};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"args"}{"gzip"} 0 0 0
4965 } else {
4966 4 ▶ eval { require Archive::Tar && Archive::Tar->VERSION(1.09); 1 }
Branch: 2 branches
BranchTrueFalseTotal
eval { do { require Archive::Tar and "Archive::Tar"->VERSION("1.09"); 1 } } or die "You must install Archive::Tar 1.09+ to make a distribution tarball\nor specify a binary tar program with the '--tar' option.\nSee the documentation for the 'dist' action.\n" 4 0 4
require Archive::Tar and "Archive::Tar"->VERSION("1.09") 4 0 4
4967 or die "You must install Archive::Tar 1.09+ to make a distribution tarball\n".
4968 "or specify a binary tar program with the '--tar' option.\n".
4969 "See the documentation for the 'dist' action.\n";
4970  
4971 4 my $files = $self->rscan_dir($dir);
4972  
4973 # Archive::Tar versions >= 1.09 use the following to enable a compatibility
4974 # hack so that the resulting archive is compatible with older clients.
4975 # If no file path is 100 chars or longer, we disable the prefix field
4976 # for maximum compatibility. If there are any long file paths then we
4977 # need the prefix field after all.
4978 $Archive::Tar::DO_NOT_USE_PREFIX =
4979 4 ▶ (grep { length($_) >= 100 } @$files) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
grep({length $_ >= 100;} @$files) ? : 0 4 4
4980  
4981 4 my $tar = Archive::Tar->new;
4982 4 $tar->add_files(@$files);
4983 4 for my $f ($tar->get_files) {
4984 73 $f->mode($f->mode & ~022); # chmod go-w
4985 }
4986 4 $tar->write("$file.tar.gz", 1);
4987 }
4988 }
4989  
4990 334 ▶sub install_path {
Subroutine install_path: called CC=6 SCAR=17.9
Pod undocumented
4991 334 my $self = shift;
4992 334 my( $type, $value ) = ( @_, '<empty>' );
4993  
4994 334 ▶ Carp::croak( 'Type argument missing' )
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 334 334
4995 unless defined( $type );
4996  
4997 334 my $map = $self->{properties}{install_path};
4998 334 ▶ return $map unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 15 319 334
4999  
5000 # delete existing value if $value is literal undef()
5001 319 ▶ unless ( defined( $value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 1 318 319
5002 1 delete( $map->{$type} );
5003 1 return undef;
5004 }
5005  
5006 # return existing value if no new $value is given
5007 318 ▶ if ( $value eq '<empty>' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq "<empty>") 317 1 318
5008 317 ▶ return undef unless exists $map->{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $map->{$type} 266 51 317
5009 51 return $map->{$type};
5010 }
5011  
5012 # set value if $value is a valid relative path
5013 1 return $map->{$type} = $value;
5014 }
5015  
5016 217 ▶sub install_sets {
Subroutine install_sets: called CC=8 SCAR=26.6
Pod undocumented
5017 # Usage: install_sets('site'), install_sets('site', 'lib'),
5018 # or install_sets('site', 'lib' => $value);
5019 217 my ($self, $dirs, $key, $value) = @_;
5020 217 ▶ $dirs = $self->installdirs unless defined $dirs;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dirs 3 214 217
5021 # update property before merging with defaults
5022 217 ▶ if ( @_ == 4 && defined $dirs && defined $key) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 4 and defined $dirs and defined $key) 0 217 217
Condition33%2/6
@_ == 4 and defined $dirs and defined $key
!ll&&!rl&&r
21700
@_ == 4 and defined $dirs
!ll&&!rl&&r
21700
MC/DC0%0/3
@_ == 4 and defined $dirs and defined $key
@_ == 4 defined $dirs defined $key
Truth table25%1/4
A and B and C
A= @_ == 4B= defined $dirsC= defined $key
ABCresult
0XX0
10X0
1100
1111
5023 # $value can be undef; will mask default
5024 0 $self->{properties}{install_sets}{$dirs}{$key} = $value;
5025 }
5026 my $map = { $self->_merge_arglist(
5027 $self->{properties}{install_sets},
5028 $self->_default_install_paths->{install_sets}
5029 217 )};
5030 217 ▶ if ( defined $dirs && defined $key ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $dirs and defined $key) { } 0 217 217
elsif (defined $dirs) { } 217 0 217
Condition33%1/3
defined $dirs and defined $key
!ll&&!rl&&r
02170
MC/DC0%0/2
defined $dirs and defined $key
defined $dirs defined $key
Truth table33%1/3
A and B
A= defined $dirsB= defined $key
ABresult
0X0
100
111
5031 0 return $map->{$dirs}{$key};
5032 }
5033 elsif ( defined $dirs ) {
5034 217 return $map->{$dirs};
5035 }
5036 else {
5037 0 croak "Can't determine installdirs for install_sets()";
5038 }
5039 }
5040  
5041 34 ▶sub original_prefix {
Subroutine original_prefix: called CC=4 SCAR=15.9
Pod undocumented
5042 # Usage: original_prefix(), original_prefix('lib'),
5043 # or original_prefix('lib' => $value);
5044 34 my ($self, $key, $value) = @_;
5045 # update property before merging with defaults
5046 34 ▶ if ( @_ == 3 && defined $key) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3 and defined $key) 0 34 34
Condition33%1/3
@_ == 3 and defined $key
!ll&&!rl&&r
3400
MC/DC0%0/2
@_ == 3 and defined $key
@_ == 3 defined $key
Truth table33%1/3
A and B
A= @_ == 3B= defined $key
ABresult
0X0
100
111
5047 # $value can be undef; will mask default
5048 0 $self->{properties}{original_prefix}{$key} = $value;
5049 }
5050 my $map = { $self->_merge_arglist(
5051 $self->{properties}{original_prefix},
5052 $self->_default_install_paths->{original_prefix}
5053 34 )};
5054 34 ▶ return $map unless defined $key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key 0 34 34
5055 34 return $map->{$key}
5056 }
5057  
5058 82 ▶sub install_base_relpaths {
Subroutine install_base_relpaths: called CC=4 SCAR=13.9
Pod undocumented
5059 # Usage: install_base_relpaths(), install_base_relpaths('lib'),
5060 # or install_base_relpaths('lib' => $value);
5061 82 my $self = shift;
5062 82 ▶ if ( @_ > 1 ) { # change values before merge
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 3 79 82
5063 3 $self->_set_relpaths($self->{properties}{install_base_relpaths}, @_);
5064 }
5065 my $map = { $self->_merge_arglist(
5066 $self->{properties}{install_base_relpaths},
5067 $self->_default_install_paths->{install_base_relpaths}
5068 81 )};
5069 81 ▶ return $map unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 8 73 81
5070 73 my $relpath = $map->{$_[0]};
5071 73 ▶ return defined $relpath ? File::Spec->catdir( @$relpath ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $relpath ? : 72 1 73
5072 }
5073  
5074 # Defaults to use in case the config install paths cannot be prefixified.
5075 34 ▶sub prefix_relpaths {
Subroutine prefix_relpaths: called CC=7 SCAR=19.5
Pod undocumented
5076 # Usage: prefix_relpaths('site'), prefix_relpaths('site', 'lib'),
5077 # or prefix_relpaths('site', 'lib' => $value);
5078 34 my $self = shift;
5079 34 ▶ my $installdirs = shift || $self->installdirs
Branch: 1 branch
BranchTrueFalseTotal
my $installdirs = shift() || $self->installdirs or croak("Can't determine installdirs for prefix_relpaths()") 34 0 34
Condition66%2/3
shift() || $self->installdirs
l!l&&r!l&&!r
3040
MC/DC0%0/2
shift() || $self->installdirs
shift() $self->installdirs
Truth table66%2/3
A || B
A= shift()B= $self->installdirs
ABresult
1X1
011
000
5080 or croak "Can't determine installdirs for prefix_relpaths()";
5081 34 ▶ if ( @_ > 1 ) { # change values before merge
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 3 31 34
5082 3 ▶ $self->{properties}{prefix_relpaths}{$installdirs} ||= {};
Condition100%2/2
$self->{"properties"}{"prefix_relpaths"}{$installdirs} ||= {}
l!l
21
MC/DC100%1/1
$self->{"properties"}{"prefix_relpaths"}{$installdirs} ||= {}
$self->{"properties"}{"prefix_relpaths"}{$installdirs}
Truth table100%2/2
A
A= $self->{"properties"}{"prefix_relpaths"}{$installdirs}
Aresult
11
00
5083 3 $self->_set_relpaths($self->{properties}{prefix_relpaths}{$installdirs}, @_);
5084 }
5085 my $map = {$self->_merge_arglist(
5086 $self->{properties}{prefix_relpaths}{$installdirs},
5087 33 $self->_default_install_paths->{prefix_relpaths}{$installdirs}
5088 )};
5089 33 ▶ return $map unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 6 27 33
5090 27 my $relpath = $map->{$_[0]};
5091 27 ▶ return defined $relpath ? File::Spec->catdir( @$relpath ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $relpath ? : 26 1 27
5092 }
5093  
5094 6 ▶sub _set_relpaths {
Subroutine _set_relpaths: called CC=4 SCAR=13.9
5095 6 my $self = shift;
5096 6 my( $map, $type, $value ) = @_;
5097  
5098 6 ▶ Carp::croak( 'Type argument missing' )
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 6 6
5099 unless defined( $type );
5100  
5101 # set undef if $value is literal undef()
5102 6 ▶ if ( ! defined( $value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value) { } 2 4 6
5103 2 $map->{$type} = undef;
5104 2 return;
5105 }
5106 # set value if $value is a valid relative path
5107 else {
5108 4 ▶ Carp::croak( "Value must be a relative path" )
Branch: 1 branch
BranchTrueFalseTotal
if "File::Spec::Unix"->file_name_is_absolute($value) 2 2 4
5109 if File::Spec::Unix->file_name_is_absolute($value);
5110  
5111 2 my @value = split( /\//, $value );
5112 2 $map->{$type} = \@value;
5113 }
5114 }
5115  
5116 # Translated from ExtUtils::MM_Any::init_INSTALL_from_PREFIX
5117 24 ▶sub prefix_relative {
Subroutine prefix_relative: called CC=1 SCAR=0.0
Pod undocumented
5118 24 my ($self, $type) = @_;
5119 24 my $installdirs = $self->installdirs;
5120  
5121 24 my $relpath = $self->install_sets($installdirs)->{$type};
5122  
5123 24 return $self->_prefixify($relpath,
5124 $self->original_prefix($installdirs),
5125 $type,
5126 );
5127 }
5128  
5129 # Translated from ExtUtils::MM_Unix::prefixify()
5130 24 ▶sub _prefixify {
Subroutine _prefixify: called CC=8 SCAR=27.7
5131 24 my($self, $path, $sprefix, $type) = @_;
5132  
5133 24 my $rprefix = $self->prefix;
5134 24 ▶ $rprefix .= '/' if $sprefix =~ m|/$|;
Branch: 1 branch
BranchTrueFalseTotal
if $sprefix =~ m[/$] 0 24 24
5135  
5136 24 ▶ $self->log_verbose(" prefixify $path from $sprefix to $rprefix\n")
Branch: 1 branch
BranchTrueFalseTotal
if defined $path and length $path 24 0 24
Condition33%1/3
defined $path and length $path
!ll&&!rl&&r
0024
MC/DC0%0/2
defined $path and length $path
defined $path length $path
Truth table33%1/3
A and B
A= defined $pathB= length $path
ABresult
0X0
100
111
5137 if defined( $path ) && length( $path );
5138  
5139 24 ▶ if( !defined( $path ) || ( length( $path ) == 0 ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $path or length $path == 0) { } 0 24 24
elsif (not 'File::Spec'->file_name_is_absolute($path)) { } 0 24 24
elsif (not $path =~ s/^\Q$sprefix\E\b//s) { } 24 0 24
Condition33%1/3
not defined $path or length $path == 0
l!l&&r!l&&!r
0024
MC/DC0%0/2
not defined $path or length $path == 0
not defined $path length $path == 0
Truth table33%1/3
not(A) or B
A= not defined $pathB= length $path == 0
ABresult
1X1
011
000
5140 0 $self->log_verbose(" no path to prefixify, falling back to default.\n");
5141 0 return $self->_prefixify_default( $type, $rprefix );
5142 } elsif( !File::Spec->file_name_is_absolute($path) ) {
5143 0 $self->log_verbose(" path is relative, not prefixifying.\n");
5144 } elsif( $path !~ s{^\Q$sprefix\E\b}{}s ) {
5145 24 $self->log_verbose(" cannot prefixify, falling back to default.\n");
5146 24 return $self->_prefixify_default( $type, $rprefix );
5147 }
5148  
5149 0 $self->log_verbose(" now $path in $rprefix\n");
5150  
5151 0 return $path;
5152 }
5153  
5154 24 ▶sub _prefixify_default {
Subroutine _prefixify_default: called CC=2 SCAR=7.5
5155 24 my $self = shift;
5156 24 my $type = shift;
5157 24 my $rprefix = shift;
5158  
5159 24 my $default = $self->prefix_relpaths($self->installdirs, $type);
5160 24 ▶ if( !$default ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $default) { } 0 24 24
5161 0 $self->log_verbose(" no default install location for type '$type', using prefix '$rprefix'.\n");
5162 0 return $rprefix;
5163 } else {
5164 24 return $default;
5165 }
5166 }
5167  
5168 241 ▶sub install_destination {
Subroutine install_destination: called CC=6 SCAR=18.0
Pod undocumented
5169 241 my ($self, $type) = @_;
5170  
5171 241 ▶ return $self->install_path($type) if $self->install_path($type);
Branch: 1 branch
BranchTrueFalseTotal
if $self->install_path($type) 25 216 241
5172  
5173 216 ▶ if ( $self->install_base ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->install_base) 70 146 216
5174 70 my $relpath = $self->install_base_relpaths($type);
5175 70 ▶ return $relpath ? File::Spec->catdir($self->install_base, $relpath) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$relpath ? : 70 0 70
5176 }
5177  
5178 146 ▶ if ( $self->prefix ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->prefix) 24 122 146
5179 24 my $relpath = $self->prefix_relative($type);
5180 24 ▶ return $relpath ? File::Spec->catdir($self->prefix, $relpath) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$relpath ? : 24 0 24
5181 }
5182  
5183 122 return $self->install_sets($self->installdirs)->{$type};
5184 }
5185  
5186 12 ▶sub install_types {
Subroutine install_types: called CC=3 SCAR=11.2
Pod undocumented
5187 12 my $self = shift;
5188  
5189 12 my %types;
5190 12 ▶ if ( $self->install_base ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->install_base) { } 5 7 12
elsif ($self->prefix) { } 0 7 7
5191 5 %types = %{$self->install_base_relpaths};
5192 } elsif ( $self->prefix ) {
5193 0 %types = %{$self->prefix_relpaths};
5194 } else {
5195 7 %types = %{$self->install_sets($self->installdirs)};
5196 }
5197  
5198 12 %types = (%types, %{$self->install_path});
5199  
5200 12 return sort keys %types;
5201 }
5202  
5203 9 ▶sub install_map {
Subroutine install_map: called CC=12 SCAR=26.2
Pod undocumented
5204 9 my ($self, $blib) = @_;
5205 9 ▶ $blib ||= $self->blib;
Condition33%1/3
$blib ||= $self->blib
l!l&&r!l&&!r
090
MC/DC0%0/2
$blib ||= $self->blib
$blib $self->blib
Truth table33%1/3
A ||= B
A= $blibB= $self->blib
ABresult
1X1
011
000
5206  
5207 9 my( %map, @skipping );
5208 9 foreach my $type ($self->install_types) {
5209 72 my $localdir = File::Spec->catdir( $blib, $type );
5210 72 ▶ next unless -e $localdir;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $localdir 39 33 72
5211  
5212 # the line "...next if (($type eq 'bindoc'..." was one of many changes introduced for
5213 # improving HTML generation on ActivePerl, see https://rt.cpan.org/Public/Bug/Display.html?id=53478
5214 # Most changes were ok, but this particular line caused test failures in t/manifypods.t on windows,
5215 # therefore it is commented out.
5216  
5217 # ********* next if (($type eq 'bindoc' || $type eq 'libdoc') && not $self->is_unixish);
5218  
5219 33 ▶ if (my $dest = $self->install_destination($type)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dest = $self->install_destination($type)) { } 33 0 33
5220 33 $map{$localdir} = $dest;
5221 } else {
5222 0 push( @skipping, $type );
5223 }
5224 }
5225  
5226 $self->log_warn(
5227 9 ▶ "WARNING: Can't figure out install path for types: @skipping\n" .
Branch: 1 branch
BranchTrueFalseTotal
if @skipping 0 9 9
5228 "Files will not be installed.\n"
5229 ) if @skipping;
5230  
5231 # Write the packlist into the same place as ExtUtils::MakeMaker.
5232 9 ▶ if ($self->create_packlist and my $module_name = $self->module_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->create_packlist and my $module_name = $self->module_name) 9 0 9
Condition33%1/3
$self->create_packlist and my $module_name = $self->module_name
!ll&&!rl&&r
009
MC/DC0%0/2
$self->create_packlist and my $module_name = $self->module_name
$self->create_packlist my $module_name = $self->module_name
Truth table33%1/3
A and B
A= $self->create_packlistB= my $module_name = $self->module_name
ABresult
0X0
100
111
5233 9 my $archdir = $self->install_destination('arch');
5234 9 my @ext = split /::/, $module_name;
5235 9 $map{write} = File::Spec->catfile($archdir, 'auto', @ext, '.packlist');
5236 }
5237  
5238 # Handle destdir
5239 9 ▶ if (length(my $destdir = $self->destdir || '')) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(my $destdir = $self->destdir || "")) 5 4 9
Condition100%2/2
$self->destdir || ''
l!l
54
MC/DC100%1/1
$self->destdir || ''
$self->destdir
Truth table100%2/2
A
A= $self->destdir
Aresult
11
00
5240 5 foreach (keys %map) {
5241 # Need to remove volume from $map{$_} using splitpath, or else
5242 # we'll create something crazy like C:\Foo\Bar\E:\Baz\Quux
5243 # VMS will always have the file separate than the path.
5244 25 my ($volume, $path, $file) = File::Spec->splitpath( $map{$_}, 0 );
5245  
5246 # catdir needs a list of directories, or it will create something
5247 # crazy like volume:[Foo.Bar.volume.Baz.Quux]
5248 25 my @dirs = File::Spec->splitdir($path);
5249  
5250 # First merge the directories
5251 25 $path = File::Spec->catdir($destdir, @dirs);
5252  
5253 # Then put the file back on if there is one.
5254 25 ▶ if ($file ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($file ne '') { } 25 0 25
5255 25 $map{$_} = File::Spec->catfile($path, $file)
5256 } else {
5257 0 $map{$_} = $path;
5258 }
5259 }
5260 }
5261  
5262 9 $map{read} = ''; # To keep ExtUtils::Install quiet
5263  
5264 9 return \%map;
5265 }
5266  
5267 326 ▶sub depends_on {
Subroutine depends_on: called CC=2 SCAR=6.9
Pod undocumented
5268 326 my $self = shift;
5269 326 foreach my $action (@_) {
5270 354 $self->_call_action($action);
5271 }
5272 }
5273  
5274 471 ▶sub rscan_dir {
Subroutine rscan_dir: called CC=5 SCAR=16.1
Pod undocumented
5275 471 my ($self, $dir, $pattern) = @_;
5276 471 my @result;
5277 471 local $_; # find() can overwrite $_, so protect ourselves
5278 349 ▶ my $subr = !$pattern ? sub {push @result, $File::Find::name} :
Subroutine __ANON__: called CC=1 SCAR=0.0
5279 1252 ▶ !ref($pattern) || (ref $pattern eq 'Regexp') ? sub {push @result, $File::Find::name if /$pattern/} :
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if /$pattern/ 198 1054 1252
5280 59 ▶ ref($pattern) eq 'CODE' ? sub {push @result, $File::Find::name if $pattern->()} :
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if &$pattern() 24 35 59
5281 471 ▶ die "Unknown pattern type";
Branch: 3 branches
BranchTrueFalseTotal
!$pattern ? : 105 366 471
!ref($pattern) || ref $pattern eq 'Regexp' ? : 356 10 366
ref $pattern eq 'CODE' ? : 10 0 10
Condition66%2/3
not ref $pattern or ref $pattern eq "Regexp"
l!l&&r!l&&!r
035610
MC/DC50%1/2
not ref $pattern or ref $pattern eq "Regexp"
not ref $pattern ref $pattern eq "Regexp"
Truth table66%2/3
not(A) or B
A= not ref $patternB= ref $pattern eq "Regexp"
ABresult
1X1
011
000
5282  
5283 471 ▶ File::Find::find({wanted => $subr, no_chdir => 1, preprocess => sub { sort @_ } }, $dir);
Subroutine __ANON__: called CC=1 SCAR=0.0
5284 471 return \@result;
5285 }
5286  
5287 475 ▶sub delete_filetree {
Subroutine delete_filetree: called CC=4 SCAR=13.9
Pod undocumented
5288 475 my $self = shift;
5289 475 my $deleted = 0;
5290 475 foreach (@_) {
5291 580 ▶ next unless -e $_;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $_ 380 200 580
5292 200 $self->log_verbose("Deleting $_\n");
5293 200 File::Path::rmtree($_, 0, 0);
5294 200 ▶ die "Couldn't remove '$_': $!\n" if -e $_;
Branch: 1 branch
BranchTrueFalseTotal
if -e $_ 0 200 200
5295 200 $deleted++;
5296 }
5297 475 return $deleted;
5298 }
5299  
5300 0 ▶sub autosplit_file {
Subroutine autosplit_file: not called CC=1 SCAR=6.9
Pod undocumented
5301 0 my ($self, $file, $to) = @_;
5302 0 require AutoSplit;
5303 0 my $dir = File::Spec->catdir($to, 'lib', 'auto');
5304 0 AutoSplit::autosplit($file, $dir);
5305 }
5306  
5307 54 ▶sub cbuilder {
Subroutine cbuilder: called CC=3 SCAR=11.0
Pod undocumented
5308 # Returns a CBuilder object
5309  
5310 54 my $self = shift;
5311 54 my $s = $self->{stash};
5312 54 ▶ return $s->{_cbuilder} if $s->{_cbuilder};
Branch: 1 branch
BranchTrueFalseTotal
if $s->{"_cbuilder"} 37 17 54
5313  
5314 17 require ExtUtils::CBuilder;
5315 17 ▶ return $s->{_cbuilder} = ExtUtils::CBuilder->new(
Branch: 1 branch
BranchTrueFalseTotal
$self->quiet ? : 9 8 17
5316 config => $self->config,
5317 ($self->quiet ? (quiet => 1 ) : ()),
5318 );
5319 }
5320  
5321 27 ▶sub have_c_compiler {
Subroutine have_c_compiler: called CC=4 SCAR=14.1
Pod undocumented
5322 27 my ($self) = @_;
5323  
5324 27 my $p = $self->{properties};
5325 27 ▶ return $p->{_have_c_compiler} if defined $p->{_have_c_compiler};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->{"_have_c_compiler"} 19 8 27
5326  
5327 8 $self->log_verbose("Checking if compiler tools configured... ");
5328 8 my $b = $self->cbuilder;
5329 8 ▶ my $have = $b && eval { $b->have_compiler };
Condition33%1/3
$b && eval { do { $b->have_compiler } }
!ll&&!rl&&r
008
MC/DC0%0/2
$b && eval { do { $b->have_compiler } }
$b eval { do { $b->have_compiler } }
Truth table33%1/3
A && B
A= $bB= eval { do { $b->have_compiler } }
ABresult
0X0
100
111
5330 8 ▶ $self->log_verbose($have ? "ok.\n" : "failed.\n");
Branch: 1 branch
BranchTrueFalseTotal
$have ? : 8 0 8
5331 8 return $p->{_have_c_compiler} = $have;
5332 }
5333  
5334 19 ▶sub compile_c {
Subroutine compile_c: called CC=3 SCAR=11.0
Pod undocumented
5335 19 my ($self, $file, %args) = @_;
5336  
5337 19 ▶ if ( ! $self->have_c_compiler ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->have_c_compiler) 1 18 19
5338 1 die "Error: no compiler detected to compile '$file'. Aborting\n";
5339 }
5340  
5341 18 my $b = $self->cbuilder;
5342 18 my $obj_file = $b->object_file($file);
5343 18 $self->add_to_cleanup($obj_file);
5344 18 ▶ return $obj_file if $self->up_to_date($file, $obj_file);
Branch: 1 branch
BranchTrueFalseTotal
if $self->up_to_date($file, $obj_file) 6 12 18
5345  
5346 $b->compile(source => $file,
5347 defines => $args{defines},
5348 12 object_file => $obj_file,
5349 include_dirs => $self->include_dirs,
5350 extra_compiler_flags => $self->extra_compiler_flags,
5351 );
5352  
5353 12 return $obj_file;
5354 }
5355  
5356 18 ▶sub link_c {
Subroutine link_c: called CC=4 SCAR=14.2
Pod undocumented
5357 18 my ($self, $spec) = @_;
5358 18 my $p = $self->{properties}; # For convenience
5359  
5360 18 $self->add_to_cleanup($spec->{lib_file});
5361  
5362 18 ▶ my $objects = $p->{objects} || [];
Condition50%1/2
$p->{'objects'} || []
l!l
018
MC/DC0%0/1
$p->{'objects'} || []
$p->{'objects'}
Truth table50%1/2
A
A= $p->{'objects'}
Aresult
11
00
5363  
5364 return $spec->{lib_file}
5365 if $self->up_to_date([$spec->{obj_file}, @$objects],
5366 18 ▶ $spec->{lib_file});
Branch: 1 branch
BranchTrueFalseTotal
if $self->up_to_date([$spec->{"obj_file"}, @$objects], $spec->{"lib_file"}) 6 12 18
5367  
5368 12 ▶ my $module_name = $spec->{module_name} || $self->module_name;
Condition33%1/3
$spec->{'module_name'} || $self->module_name
l!l&&r!l&&!r
1200
MC/DC0%0/2
$spec->{'module_name'} || $self->module_name
$spec->{'module_name'} $self->module_name
Truth table33%1/3
A || B
A= $spec->{'module_name'}B= $self->module_name
ABresult
1X1
011
000
5369  
5370 $self->cbuilder->link(
5371 module_name => $module_name,
5372 objects => [$spec->{obj_file}, @$objects],
5373 lib_file => $spec->{lib_file},
5374 12 extra_linker_flags => $self->extra_linker_flags );
5375  
5376 12 return $spec->{lib_file};
5377 }
5378  
5379 13 ▶sub compile_xs {
Subroutine compile_xs: called CC=5 SCAR=27.7
Pod undocumented
5380 13 my ($self, $file, %args) = @_;
5381  
5382 13 $self->log_verbose("$file -> $args{outfile}\n");
5383  
5384 13 ▶ if (eval {require ExtUtils::ParseXS; 1}) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require ExtUtils::ParseXS; 1 } }) { } 13 0 13
5385  
5386 ExtUtils::ParseXS::process_file(
5387 filename => $file,
5388 prototypes => 0,
5389 output => $args{outfile},
5390 13 );
5391 } else {
5392 # Ok, I give up. Just use backticks.
5393  
5394 0 ▶ my $xsubpp = Module::Metadata->find_module_by_name('ExtUtils::xsubpp')
Branch: 1 branch
BranchTrueFalseTotal
my $xsubpp = "Module::Metadata"->find_module_by_name("ExtUtils::xsubpp") or die "Can't find ExtUtils::xsubpp in INC (@INC)" 0 0 0
5395 or die "Can't find ExtUtils::xsubpp in INC (@INC)";
5396  
5397 0 my @typemaps;
5398 0 push @typemaps, Module::Metadata->find_module_by_name(
5399 'ExtUtils::typemap', \@INC
5400 );
5401 0 my $lib_typemap = Module::Metadata->find_module_by_name(
5402 'typemap', [File::Basename::dirname($file), File::Spec->rel2abs('.')]
5403 );
5404 0 ▶ push @typemaps, $lib_typemap if $lib_typemap;
Branch: 1 branch
BranchTrueFalseTotal
if $lib_typemap 0 0 0
5405 0 @typemaps = map {+'-typemap', $_} @typemaps;
5406  
5407 0 my $cf = $self->{config};
5408 0 my $perl = $self->{properties}{perl};
5409  
5410 0 my @command = ($perl, "-I".$cf->get('installarchlib'), "-I".$cf->get('installprivlib'), $xsubpp, '-noprototypes',
5411 @typemaps, $file);
5412  
5413 0 $self->log_info("@command\n");
5414 0 ▶ open(my $fh, '>', $args{outfile}) or die "Couldn't write $args{outfile}: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $args{"outfile"} or die qq[Couldn't write $args{"outfile"}: $!] 0 0 0
5415 0 print {$fh} $self->_backticks(@command);
5416 0 close $fh;
5417 }
5418 }
5419  
5420 1812 ▶sub split_like_shell {
Subroutine split_like_shell: called CC=4 SCAR=13.9
Pod undocumented
5421 1812 my ($self, $string) = @_;
5422  
5423 1812 ▶ return () unless defined($string);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $string 1272 540 1812
5424 540 ▶ return @$string if ref $string eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $string eq "ARRAY" 115 425 540
5425 425 $string =~ s/^\s+|\s+$//g;
5426 425 ▶ return () unless length($string);
Branch: 1 branch
BranchTrueFalseTotal
unless length $string 63 362 425
5427  
5428 362 return Text::ParseWords::shellwords($string);
5429 }
5430  
5431 7 ▶sub oneliner {
Subroutine oneliner: called CC=4 SCAR=14.3
Pod undocumented
5432 # Returns a string that the shell can evaluate as a perl command.
5433 # This should be avoided whenever possible, since "the shell" really
5434 # means zillions of shells on zillions of platforms and it's really
5435 # hard to get it right all the time.
5436  
5437 # Some of this code is stolen with permission from ExtUtils::MakeMaker.
5438  
5439 7 my($self, $cmd, $switches, $args) = @_;
5440 7 ▶ $switches = [] unless defined $switches;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $switches 0 7 7
5441 7 ▶ $args = [] unless defined $args;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args 0 7 7
5442  
5443 # Strip leading and trailing newlines
5444 7 $cmd =~ s{^\n+}{};
5445 7 $cmd =~ s{\n+$}{};
5446  
5447 7 ▶ my $perl = ref($self) ? $self->perl : $self->find_perl_interpreter;
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 0 7 7
5448 7 return $self->_quote_args($perl, @$switches, '-e', $cmd, @$args);
5449 }
5450  
5451 3754 ▶sub run_perl_script {
Subroutine run_perl_script: called CC=3 SCAR=11.0
Pod undocumented
5452 3754 my ($self, $script, $preargs, $postargs) = @_;
5453 3754 foreach ($preargs, $postargs) {
5454 7508 ▶ $_ = [ $self->split_like_shell($_) ] unless ref();
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_ 308 7200 7508
5455 }
5456 3754 return $self->run_perl_command([@$preargs, $script, @$postargs]);
5457 }
5458  
5459 3766 ▶sub run_perl_command {
Subroutine run_perl_command: called CC=3 SCAR=11.0
Pod undocumented
5460 # XXX Maybe we should accept @args instead of $args? Must resolve
5461 # this before documenting.
5462 3766 my ($self, $args) = @_;
5463 3766 ▶ $args = [ $self->split_like_shell($args) ] unless ref($args);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args 0 3766 3766
5464 3766 ▶ my $perl = ref($self) ? $self->perl : $self->find_perl_interpreter;
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 260 3506 3766
5465  
5466 # Make sure our local additions to @INC are propagated to the subprocess
5467 3734 local $ENV{PERL5LIB} = join $self->config('path_sep'), $self->_added_to_INC;
5468  
5469 3702 return $self->do_system($perl, @$args);
5470 }
5471  
5472 # Infer various data from the path of the input filename
5473 # that is needed to create output files.
5474 # The input filename is expected to be of the form:
5475 # lib/Module/Name.ext or Module/Name.ext
5476 19 ▶sub _infer_xs_spec {
Subroutine _infer_xs_spec: called CC=7 SCAR=19.5
5477 19 my $self = shift;
5478 19 my $file = shift;
5479  
5480 19 my $cf = $self->{config};
5481  
5482 19 my %spec;
5483  
5484 19 my( $v, $d, $f ) = File::Spec->splitpath( $file );
5485 19 my @d = File::Spec->splitdir( $d );
5486 19 (my $file_base = $f) =~ s/\.[^.]+$//i;
5487  
5488 19 $spec{base_name} = $file_base;
5489  
5490 19 $spec{src_dir} = File::Spec->catpath( $v, $d, '' );
5491  
5492 # the module name
5493 19 ▶ shift( @d ) while @d && ($d[0] eq 'lib' || $d[0] eq '');
Branch: 1 branch
BranchTrueFalseTotal
@d and $d[0] eq "lib" || $d[0] eq "" and do { shift @d } 34 19 53
Condition100%6/6
@d and $d[0] eq "lib" || $d[0] eq ""
!ll&&!rl&&r
15434
$d[0] eq "lib" or $d[0] eq ""
l!l&&r!l&&!r
19154
MC/DC100%3/3
@d and $d[0] eq "lib" || $d[0] eq ""
@d $d[0] eq "lib" $d[0] eq ""
Truth table100%4/4
A and B or C
A= @dB= $d[0] eq "lib"C= $d[0] eq ""
ABCresult
0XX0
1000
11X1
1011
5494 19 ▶ pop( @d ) while @d && $d[-1] eq '';
Branch: 1 branch
BranchTrueFalseTotal
@d and $d[-1] eq "" and do { pop @d } 4 19 23
Condition100%3/3
@d and $d[-1] eq ""
!ll&&!rl&&r
1544
MC/DC100%2/2
@d and $d[-1] eq ""
@d $d[-1] eq ""
Truth table100%3/3
A and B
A= @dB= $d[-1] eq ""
ABresult
0X0
100
111
5495 19 $spec{module_name} = join( '::', (@d, $file_base) );
5496  
5497 19 $spec{archdir} = File::Spec->catdir($self->blib, 'arch', 'auto',
5498 @d, $file_base);
5499  
5500 $spec{c_file} = File::Spec->catfile( $spec{src_dir},
5501 19 "${file_base}.c" );
5502  
5503 $spec{obj_file} = File::Spec->catfile( $spec{src_dir},
5504 19 "${file_base}".$cf->get('obj_ext') );
5505  
5506 19 require DynaLoader;
5507 19 ▶ my $modfname = defined &DynaLoader::mod2fname ? DynaLoader::mod2fname([@d, $file_base]) : $file_base;
Branch: 1 branch
BranchTrueFalseTotal
defined &DynaLoader::mod2fname ? : 0 19 19
5508  
5509 19 $spec{bs_file} = File::Spec->catfile($spec{archdir}, "$modfname.bs");
5510  
5511 19 $spec{lib_file} = File::Spec->catfile($spec{archdir}, "$modfname.".$cf->get('dlext'));
5512  
5513 19 return \%spec;
5514 }
5515  
5516 19 ▶sub process_xs {
Subroutine process_xs: called CC=4 SCAR=13.9
Pod undocumented
5517 19 my ($self, $file) = @_;
5518  
5519 19 my $spec = $self->_infer_xs_spec($file);
5520  
5521 # File name, minus the suffix
5522 19 (my $file_base = $file) =~ s/\.[^.]+$//;
5523  
5524 # .xs -> .c
5525 19 $self->add_to_cleanup($spec->{c_file});
5526  
5527 19 ▶ unless ($self->up_to_date($file, $spec->{c_file})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->up_to_date($file, $spec->{"c_file"})) 13 6 19
5528 13 $self->compile_xs($file, outfile => $spec->{c_file});
5529 }
5530  
5531 # .c -> .o
5532 19 my $v = $self->dist_version;
5533 $self->compile_c($spec->{c_file},
5534 19 defines => {VERSION => qq{"$v"}, XS_VERSION => qq{"$v"}});
5535  
5536 # archdir
5537 18 ▶ File::Path::mkpath($spec->{archdir}, 0, oct(777)) unless -d $spec->{archdir};
Branch: 1 branch
BranchTrueFalseTotal
unless -d $spec->{"archdir"} 12 6 18
5538  
5539 # .xs -> .bs
5540 18 $self->add_to_cleanup($spec->{bs_file});
5541 18 ▶ unless ($self->up_to_date($file, $spec->{bs_file})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->up_to_date($file, $spec->{"bs_file"})) 12 6 18
5542 12 require ExtUtils::Mkbootstrap;
5543 12 $self->log_info("ExtUtils::Mkbootstrap::Mkbootstrap('$spec->{bs_file}')\n");
5544 12 ExtUtils::Mkbootstrap::Mkbootstrap($spec->{bs_file}); # Original had $BSLOADLIBS - what's that?
5545 12 open(my $fh, '>>', $spec->{bs_file}); # create
5546 12 utime((time)x2, $spec->{bs_file}); # touch
5547 }
5548  
5549 # .o -> .(a|bundle)
5550 18 $self->link_c($spec);
5551 }
5552  
5553 4046 ▶sub do_system {
Subroutine do_system: called CC=7 SCAR=25.2
Pod undocumented
5554 4046 my ($self, @cmd) = @_;
5555 4046 $self->log_verbose("@cmd\n");
5556  
5557 # Some systems proliferate huge PERL5LIBs, try to ameliorate:
5558 4046 my %seen;
5559 4046 my $sep = $self->config('path_sep');
5560 local $ENV{PERL5LIB} =
5561 ( !exists($ENV{PERL5LIB}) ? '' :
5562 length($ENV{PERL5LIB}) < 500
5563 ? $ENV{PERL5LIB}
5564 0 ▶ : join $sep, grep { ! $seen{$_}++ and -d $_ } split($sep, $ENV{PERL5LIB})
Condition0%0/3
!$seen{$_}++ && -d $_
!ll&&!rl&&r
000
MC/DC0%0/2
!$seen{$_}++ && -d $_
!$seen{$_}++ -d $_
Truth table0%0/3
not(A) && B
A= !$seen{$_}++B= -d $_
ABresult
0X0
100
111
5565 4046 ▶ );
Branch: 2 branches
BranchTrueFalseTotal
!exists $ENV{'PERL5LIB'} ? : 0 4046 4046
length $ENV{'PERL5LIB'} < 500 ? : 4046 0 4046
5566  
5567 4046 my $status = system(@cmd);
5568 4046 ▶ if ($status and $! =~ /Argument list too long/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status and $! =~ /Argument list too long/i) 0 4046 4046
Condition66%2/3
$status and $! =~ /Argument list too long/i
!ll&&!rl&&r
4027190
MC/DC0%0/2
$status and $! =~ /Argument list too long/i
$status $! =~ /Argument list too long/i
Truth table66%2/3
A and B
A= $statusB= $! =~ /Argument list too long/i
ABresult
0X0
100
111
5569 0 my $env_entries = '';
5570 0 foreach (sort keys %ENV) { $env_entries .= "$_=>".length($ENV{$_})."; " }
5571 0 warn "'Argument list' was 'too long', env lengths are $env_entries";
5572 }
5573 4046 return !$status;
5574 }
5575  
5576 212 ▶sub copy_if_modified {
Subroutine copy_if_modified: called CC=16 SCAR=30.2
Pod undocumented
5577 212 my $self = shift;
5578 212 ▶ my %args = (@_ > 3
Branch: 1 branch
BranchTrueFalseTotal
@_ > 3 ? : 194 18 212
5579 ? ( @_ )
5580 : ( from => shift, to_dir => shift, flatten => shift )
5581 );
5582 $args{verbose} = !$self->quiet
5583 212 ▶ unless exists $args{verbose};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"verbose"} 143 69 212
5584  
5585 212 my $file = $args{from};
5586 212 ▶ unless (defined $file and length $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file and length $file) 0 212 212
Condition33%1/3
defined $file and length $file
!ll&&!rl&&r
00212
MC/DC0%0/2
defined $file and length $file
defined $file length $file
Truth table33%1/3
A and B
A= defined $fileB= length $file
ABresult
0X0
100
111
5587 0 die "No 'from' parameter given to copy_if_modified";
5588 }
5589  
5590 # makes no sense to replicate an absolute path, so assume flatten
5591 212 ▶ $args{flatten} = 1 if File::Spec->file_name_is_absolute( $file );
Branch: 1 branch
BranchTrueFalseTotal
if "File::Spec"->file_name_is_absolute($file) 1 211 212
5592  
5593 212 my $to_path;
5594 212 ▶ if (defined $args{to} and length $args{to}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $args{'to'} and length $args{'to'}) { } 124 88 212
elsif (defined $args{'to_dir'} and length $args{'to_dir'}) { } 88 0 88
Condition66%2/3
defined $args{"to"} and length $args{"to"}
!ll&&!rl&&r
880124
MC/DC50%1/2
defined $args{"to"} and length $args{"to"}
defined $args{"to"} length $args{"to"}
Truth table66%2/3
A and B
A= defined $args{"to"}B= length $args{"to"}
ABresult
0X0
100
111
5595 124 $to_path = $args{to};
5596 ▶ } elsif (defined $args{to_dir} and length $args{to_dir}) {
Condition33%1/3
defined $args{"to_dir"} and length $args{"to_dir"}
!ll&&!rl&&r
0088
MC/DC0%0/2
defined $args{"to_dir"} and length $args{"to_dir"}
defined $args{"to_dir"} length $args{"to_dir"}
Truth table33%1/3
A and B
A= defined $args{"to_dir"}B= length $args{"to_dir"}
ABresult
0X0
100
111
5597 $to_path = File::Spec->catfile( $args{to_dir}, $args{flatten}
5598 88 ▶ ? File::Basename::basename($file)
Branch: 1 branch
BranchTrueFalseTotal
$args{'flatten'} ? : 19 69 88
5599 : $file );
5600 } else {
5601 0 die "No 'to' or 'to_dir' parameter given to copy_if_modified";
5602 }
5603  
5604 212 ▶ return if $self->up_to_date($file, $to_path); # Already fresh
Branch: 1 branch
BranchTrueFalseTotal
if $self->up_to_date($file, $to_path) 68 144 212
5605  
5606 {
5607 144 local $self->{properties}{quiet} = 1;
5608 144 $self->delete_filetree($to_path); # delete destination if exists
5609 }
5610  
5611 # Create parent directories
5612 144 File::Path::mkpath(File::Basename::dirname($to_path), 0, oct(777));
5613  
5614 144 $self->log_verbose("Copying $file -> $to_path\n");
5615  
5616 144 ▶ if ($^O eq 'os2') {# copy will not overwrite; 0x1 = overwrite
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'os2') { } 0 144 144
5617 0 chmod 0666, $to_path;
5618 0 ▶ File::Copy::syscopy($file, $to_path, 0x1) or die "Can't copy('$file', '$to_path'): $!";
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::syscopy($file, $to_path, 1) or die "Can't copy('${file}', '${to_path}'): $!" 0 0 0
5619 } else {
5620 144 ▶ File::Copy::copy($file, $to_path) or die "Can't copy('$file', '$to_path'): $!";
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::copy($file, $to_path) or die "Can't copy('${file}', '${to_path}'): $!" 144 0 144
5621 }
5622  
5623 # mode is read-only + (executable if source is executable)
5624 144 ▶ my $mode = oct(444) | ( $self->is_executable($file) ? oct(111) : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$self->is_executable($file) ? : 6 138 144
5625 144 chmod( $mode, $to_path );
5626  
5627 144 return $to_path;
5628 }
5629  
5630 341 ▶sub up_to_date {
Subroutine up_to_date: called CC=11 SCAR=24.2
Pod undocumented
5631 341 my ($self, $source, $derived) = @_;
5632 341 ▶ $source = [$source] unless ref $source;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $source 321 20 341
5633 341 ▶ $derived = [$derived] unless ref $derived;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $derived 335 6 341
5634  
5635 # empty $derived means $source should always run
5636 341 ▶ return 0 if @$source && !@$derived || grep {not -e} @$derived;
Branch: 1 branch
BranchTrueFalseTotal
if @$source and not @$derived or grep {not -e $_;} @$derived 226 115 341
Condition83%5/6
@$source and not @$derived or grep {not -e $_;} @$derived
l!l&&r!l&&!r
1225115
@$source and not @$derived
!ll&&!rl&&r
03401
MC/DC66%2/3
@$source and not @$derived or grep {not -e $_;} @$derived
@$source not @$derived grep {not -e $_;} @$derived
Truth table60%3/5
A and not(B) or C
A= @$sourceB= not @$derivedC= grep {not -e $_;} @$derived
ABCresult
11X1
0X11
1011
0X00
1000
5637  
5638 115 my $most_recent_source = time / (24*60*60);
5639 115 foreach my $file (@$source) {
5640 117 ▶ unless (-e $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $file) 0 117 117
5641 0 $self->log_warn("Can't find source file $file for up-to-date check");
5642 0 next;
5643 }
5644 117 ▶ $most_recent_source = -M _ if -M _ < $most_recent_source;
Branch: 1 branch
BranchTrueFalseTotal
if -M _ < $most_recent_source 116 1 117
5645 }
5646  
5647 115 foreach my $derived (@$derived) {
5648 115 ▶ return 0 if -M $derived > $most_recent_source;
Branch: 1 branch
BranchTrueFalseTotal
if -M $derived > $most_recent_source 1 114 115
5649 }
5650 114 return 1;
5651 }
5652  
5653 35 ▶sub dir_contains {
Subroutine dir_contains: called CC=5 SCAR=16.6
Pod undocumented
5654 35 my ($self, $first, $second) = @_;
5655 # File::Spec doesn't have an easy way to check whether one directory
5656 # is inside another, unfortunately.
5657  
5658 35 ($first, $second) = map File::Spec->canonpath($_), ($first, $second);
5659 35 my @first_dirs = File::Spec->splitdir($first);
5660 35 my @second_dirs = File::Spec->splitdir($second);
5661  
5662 35 ▶ return 0 if @second_dirs < @first_dirs;
Branch: 1 branch
BranchTrueFalseTotal
if @second_dirs < @first_dirs 0 35 35
5663  
5664 my $is_same = ( $self->_case_tolerant
5665 0 ▶ ? sub {lc(shift()) eq lc(shift())}
Subroutine __ANON__: not called CC=1 SCAR=6.9
5666 35 ▶ : sub {shift() eq shift()} );
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
$self->_case_tolerant ? : 0 35 35
5667  
5668 35 ▶ while (@first_dirs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@first_dirs) 91 35 126
5669 91 ▶ return 0 unless $is_same->(shift @first_dirs, shift @second_dirs);
Branch: 1 branch
BranchTrueFalseTotal
unless &$is_same(shift @first_dirs, shift @second_dirs) 0 91 91
5670 }
5671  
5672 35 return 1;
5673 }
5674  
5675 297 1;
5676 __END__
« blib/lib/Module/Build/Compat.pm ↑ Summary blib/lib/Module/Build/Platform/Windows.pm »