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