inc/Module/Install/Can.pm

filter: Statementstmt 24.3% 20 / 82 Branchbran 3.3% 1 / 30 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 54.5% 6 / 11 Podpod 100% 4 / 4 totaltotal 20.6% 31 / 150 CC 21 SCAR 34.9
CC
21
Cov
17%
can_run
56.0
can_xs
56.0
can_cc
30.0
CRAP 32.6
« dist/t9vPd3GCmf/Foo-Bar-0.01/inc/Module/Install/Can.pm ↑ Summary blib/lib/Module/Install/AutoLicense.pm »
1 #line 1
2 package Module::Install::Can;
3 5 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Config ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use ExtUtils::MakeMaker ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 use Module::Install::Base ();
8 5 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use vars qw{$VERSION @ISA $ISCORE};
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 BEGIN {
11 5 $VERSION = '1.17';
12 5 @ISA = 'Module::Install::Base';
13 $ISCORE = 1;
14 }
15  
16 # check if we can load some module
17 0 ▶### Upgrade this to not have to load the module if possible
Subroutine can_use: not called CC=3 SCAR=24.8
Pod documented
18 0 sub can_use {
19 0 my ($self, $mod, $ver) = @_;
20 0 ▶ $mod =~ s{::|\\}{/}g;
Branch: 1 branch
BranchTrueFalseTotal
unless $mod =~ /\.pm$/i 0 0 0
21 $mod .= '.pm' unless $mod =~ /\.pm$/i;
22 0  
23 0 my $pkg = $mod;
24 0 $pkg =~ s{/}{::}g;
25 $pkg =~ s{\.pm$}{}i;
26 0  
27 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
28 eval { require $mod; $pkg->VERSION($ver || 0); 1 };
29 }
30  
31 0 ▶# Check if we can run some command
Subroutine can_run: not called CC=7 SCAR=40.3
Pod documented
32 0 sub can_run {
33 my ($self, $cmd) = @_;
34 0  
35 0 ▶ my $_cmd = $cmd;
Branch: 1 branch
BranchTrueFalseTotal
if -x $_cmd or $_cmd = "MM"->maybe_command($_cmd) 0 0 0
Condition0%0/3
-x $_cmd or $_cmd = "MM"->maybe_command($_cmd)
l!l&&r!l&&!r
000
MC/DC0%0/2
-x $_cmd or $_cmd = "MM"->maybe_command($_cmd)
-x $_cmd $_cmd = "MM"->maybe_command($_cmd)
Truth table0%0/3
A or B
A= -x $_cmdB= $_cmd = "MM"->maybe_command($_cmd)
ABresult
1X1
011
000
36 return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
37 0  
38 0 ▶ for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
Branch: 1 branch
BranchTrueFalseTotal
if $dir eq "" 0 0 0
39 0 next if $dir eq '';
40 0 require File::Spec;
41 0 ▶ my $abs = File::Spec->catfile($dir, $cmd);
Branch: 1 branch
BranchTrueFalseTotal
if -x $abs or $abs = "MM"->maybe_command($abs) 0 0 0
Condition0%0/3
-x $abs or $abs = "MM"->maybe_command($abs)
l!l&&r!l&&!r
000
MC/DC0%0/2
-x $abs or $abs = "MM"->maybe_command($abs)
-x $abs $abs = "MM"->maybe_command($abs)
Truth table0%0/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 0 ▶# Can our C compiler environment build XS files
Subroutine can_xs: not called CC=7 SCAR=40.3
Pod documented
49 0 sub can_xs {
50 my $self = shift;
51  
52 0 # Ensure we have the CBuilder module
53 $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 );
54  
55 0 # Do we have the configure_requires checker?
56 0 local $@;
57 0 ▶ eval "require ExtUtils::CBuilder;";
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
58 if ( $@ ) {
59 # They don't obey configure_requires, so it is
60 # someone old and delicate. Try to avoid hurting
61 0 # them by falling back to an older simpler test.
62 return $self->can_cc();
63 }
64  
65 0 # Do we have a working C compiler
66 my $builder = ExtUtils::CBuilder->new(
67 quiet => 1,
68 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
unless ($builder->have_compiler) 0 0 0
69 unless ( $builder->have_compiler ) {
70 0 # No working C compiler
71 return 0;
72 }
73  
74 0 # Write a C file representative of what XS becomes
75 0 require File::Temp;
76 my ( $FH, $tmpfile ) = File::Temp::tempfile(
77 "compilexs-XXXXX",
78 SUFFIX => '.c',
79 0 );
80 0 binmode $FH;
81 print $FH <<'END_C';
82 #include "EXTERN.h"
83 #include "perl.h"
84 #include "XSUB.h"
85  
86 int main(int argc, char **argv) {
87 return 0;
88 }
89  
90 int boot_sanexs() {
91 return 1;
92 }
93  
94 0 END_C
95 close $FH;
96  
97 0 # Can the C compiler access the same headers XS does
98 0 my @libs = ();
99 0 my $object = undef;
100 0 eval {
101 0 local $^W = 0;
102 $object = $builder->compile(
103 source => $tmpfile,
104 0 );
105 @libs = $builder->link(
106 objects => $object,
107 module_name => 'sanexs',
108 );
109 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 0 0
110 my $result = $@ ? 0 : 1;
111  
112 0 # Clean up all the build files
113 0 ▶ foreach ( $tmpfile, $object, @libs ) {
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 0 0
114 0 ▶ next unless defined $_;
Branch: 1 branch
BranchTrueFalseTotal
unlink $_ and do { '???' } 0 0 0
115 1 while unlink;
116 }
117 0  
118 return $result;
119 }
120  
121 0 ▶# Can we locate a (the) C compiler
Subroutine can_cc: not called CC=5 SCAR=34.0
Pod documented
122 0 sub can_cc {
123 my $self = shift;
124 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "VMS") 0 0 0
125 0 if ($^O eq 'VMS') {
126 0 require ExtUtils::CBuilder;
127 my $builder = ExtUtils::CBuilder->new(
128 quiet => 1,
129 0 );
130 return $builder->have_compiler;
131 }
132 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my @chunks = split(/ /, $Config::Config{"cc"}, 0) or return 0 0 0
133 my @chunks = split(/ /, $Config::Config{cc}) or return;
134  
135 0 ▶ # $Config{cc} may contain args; try to find out the program part
Branch: 1 branch
BranchTrueFalseTotal
if (@chunks) 0 0 0
136 0 ▶ while (@chunks) {
Condition0%0/3
$self->can_run(join($", @chunks)) || (pop @chunks, next)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->can_run(join($", @chunks)) || (pop @chunks, next)
$self->can_run(join($", @chunks)) (pop @chunks, next)
Truth table0%0/3
A || B
A= $self->can_run(join($", @chunks))B= (pop @chunks, next)
ABresult
1X1
011
000
137 return $self->can_run("@chunks") || (pop(@chunks), next);
138 }
139 0  
140 return;
141 }
142  
143 5 ▶# Fix Cygwin bug on maybe_command();
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "cygwin") 0 5 5
144 0 if ( $^O eq 'cygwin' ) {
145 0 require ExtUtils::MM_Cygwin;
146 0 ▶ require ExtUtils::MM_Win32;
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &ExtUtils::MM_Cygwin::maybe_command) 0 0 0
147 0 ▶ if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) {
Subroutine __ANON__: not called CC=3 SCAR=24.8
148 0 *ExtUtils::MM_Cygwin::maybe_command = sub {
149 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
150 0 if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) {
151 ExtUtils::MM_Win32->maybe_command($file);
152 0 } else {
153 ExtUtils::MM_Unix->maybe_command($file);
154 }
155 0 }
156 }
157 }
158 5  
159 1;
160  
161 __END__
« dist/t9vPd3GCmf/Foo-Bar-0.01/inc/Module/Install/Can.pm ↑ Summary blib/lib/Module/Install/AutoLicense.pm »