t/test/inc/Module/Install/Can.pm

filter: Statementstmt 61.8% 34 / 55 Branchbran 38.8% 7 / 18 Conditioncond 28.5% 4 / 14 MC/DCmcdc 11.1% 1 / 9 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 3 totaltotal 50.0% 55 / 110 CC 14 SCAR 18.8
CC
14
Cov
52%
can_use
12.0
__ANON__
12.0
can_run
8.3
CRAP 6.6
« t/test/inc/Module/Install/WriteAll.pm ↑ Summary t/test/inc/Module/Install/External.pm »
1 #line 1
2 package Module::Install::Can;
3 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Config ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use ExtUtils::MakeMaker ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 use Module::Install::Base ();
9 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use vars qw{$VERSION @ISA $ISCORE};
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 BEGIN {
12 1 $VERSION = '0.91';
13 1 @ISA = 'Module::Install::Base';
14 $ISCORE = 1;
15 }
16  
17 # check if we can load some module
18 0 ▶### Upgrade this to not have to load the module if possible
Subroutine can_use: not called CC=3 SCAR=24.8
Pod undocumented
19 0 sub can_use {
20 0 my ($self, $mod, $ver) = @_;
21 0 ▶ $mod =~ s{::|\\}{/}g;
Branch: 1 branch
BranchTrueFalseTotal
unless $mod =~ /\.pm$/i 0 0 0
22 $mod .= '.pm' unless $mod =~ /\.pm$/i;
23 0  
24 0 my $pkg = $mod;
25 0 $pkg =~ s{/}{::}g;
26 $pkg =~ s{\.pm$}{}i;
27 0  
28 0 ▶ local $@;
Condition0%0/2
$ver || 0
l!l
00
MC/DC0%0/1
$ver || 0
$ver
Truth table0%0/2
A
A= $ver
Aresult
11
00
29 eval { require $mod; $pkg->VERSION($ver || 0); 1 };
30 }
31  
32 1 ▶# check if we can run some command
Subroutine can_run: called CC=7 SCAR=21.2
Pod undocumented
33 1 sub can_run {
34 my ($self, $cmd) = @_;
35 1  
36 1 ▶ my $_cmd = $cmd;
Branch: 1 branch
BranchTrueFalseTotal
if -x $_cmd or $_cmd = "MM"->maybe_command($_cmd) 0 1 1
Condition33%1/3
-x $_cmd or $_cmd = "MM"->maybe_command($_cmd)
l!l&&r!l&&!r
001
MC/DC0%0/2
-x $_cmd or $_cmd = "MM"->maybe_command($_cmd)
-x $_cmd $_cmd = "MM"->maybe_command($_cmd)
Truth table33%1/3
A or B
A= -x $_cmdB= $_cmd = "MM"->maybe_command($_cmd)
ABresult
1X1
011
000
37 return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
38 1  
39 8 ▶ for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
Branch: 1 branch
BranchTrueFalseTotal
if $dir eq "" 0 8 8
40 8 next if $dir eq '';
41 8 ▶ my $abs = File::Spec->catfile($dir, $_[1]);
Branch: 1 branch
BranchTrueFalseTotal
if -x $abs or $abs = "MM"->maybe_command($abs) 1 7 8
Condition66%2/3
-x $abs or $abs = "MM"->maybe_command($abs)
l!l&&r!l&&!r
107
MC/DC50%1/2
-x $abs or $abs = "MM"->maybe_command($abs)
-x $abs $abs = "MM"->maybe_command($abs)
Truth table66%2/3
A or B
A= -x $absB= $abs = "MM"->maybe_command($abs)
ABresult
1X1
011
000
42 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
43 }
44 0  
45 return;
46 }
47  
48 1 ▶# can we locate a (the) C compiler
Subroutine can_cc: called CC=4 SCAR=16.4
Pod undocumented
49 1 sub can_cc {
50 1 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
my @chunks = split(/ /, $Config::Config{"cc"}, 0) or return 1 0 1
51 my @chunks = split(/ /, $Config::Config{cc}) or return;
52  
53 1 ▶ # $Config{cc} may contain args; try to find out the program part
Branch: 1 branch
BranchTrueFalseTotal
if (@chunks) 1 0 1
54 1 ▶ while (@chunks) {
Condition33%1/3
$self->can_run(join($", @chunks)) || (pop @chunks, next)
l!l&&r!l&&!r
100
MC/DC0%0/2
$self->can_run(join($", @chunks)) || (pop @chunks, next)
$self->can_run(join($", @chunks)) (pop @chunks, next)
Truth table33%1/3
A || B
A= $self->can_run(join($", @chunks))B= (pop @chunks, next)
ABresult
1X1
011
000
55 return $self->can_run("@chunks") || (pop(@chunks), next);
56 }
57 0  
58 return;
59 }
60  
61 1 ▶# Fix Cygwin bug on maybe_command();
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "cygwin") 0 1 1
62 0 if ( $^O eq 'cygwin' ) {
63 0 require ExtUtils::MM_Cygwin;
64 0 ▶ require ExtUtils::MM_Win32;
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &ExtUtils::MM_Cygwin::maybe_command) 0 0 0
65 0 ▶ if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) {
Subroutine __ANON__: not called CC=3 SCAR=24.8
66 0 *ExtUtils::MM_Cygwin::maybe_command = sub {
67 0 ▶ my ($self, $file) = @_;
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ m[^/cygdrive/]i and 'ExtUtils::MM_Win32'->can('maybe_command')) { } 0 0 0
Condition0%0/3
$file =~ m[^/cygdrive/]i and "ExtUtils::MM_Win32"->can("maybe_command")
!ll&&!rl&&r
000
MC/DC0%0/2
$file =~ m[^/cygdrive/]i and "ExtUtils::MM_Win32"->can("maybe_command")
$file =~ m[^/cygdrive/]i "ExtUtils::MM_Win32"->can("maybe_command")
Truth table0%0/3
A and B
A= $file =~ m[^/cygdrive/]iB= "ExtUtils::MM_Win32"->can("maybe_command")
ABresult
0X0
100
111
68 0 if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) {
69 ExtUtils::MM_Win32->maybe_command($file);
70 0 } else {
71 ExtUtils::MM_Unix->maybe_command($file);
72 }
73 0 }
74 }
75 }
76 1  
77 1;
78  
79 __END__
« t/test/inc/Module/Install/WriteAll.pm ↑ Summary t/test/inc/Module/Install/External.pm »