blib/script/cc_harness

filter: Statementstmt 32.5% 44 / 135 Branchbran 19.3% 19 / 98 Conditioncond 27.1% 16 / 59 MC/DCmcdc 5.7% 2 / 35 Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 25.1% 83 / 330 CC 25 SCAR 64.0
CC
25
Cov
27%
cc_harness_msvc
650.0
BEGIN
1.0
BEGIN
1.0
CRAP 601.9
« blib/lib/B/C.pm ↑ Summary script/cc_harness »
1 #!/usr/local/bin/perl
2 115 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 115 ▶use ExtUtils::Embed;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 115 my ($coredir, $libdir);
6 115 ▶if ($ENV{PERL_CORE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'PERL_CORE'}) { } 0 115 115
7 0 ▶ $libdir = $coredir = $^O eq 'MSWin32'? '../../lib/CORE' : '../..';
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 0 0
8 } else {
9 115 $libdir = $Config{prefix} . "/lib";
10 115 ▶ $coredir = $ENV{PERL_SRC} || $Config{archlib}."/CORE";
Condition50%1/2
$ENV{'PERL_SRC'} || $Config{'archlib'} . '/CORE'
l!l
0115
MC/DC0%0/1
$ENV{'PERL_SRC'} || $Config{'archlib'} . '/CORE'
$ENV{'PERL_SRC'}
Truth table50%1/2
A
A= $ENV{'PERL_SRC'}
Aresult
11
00
11 }
12 115 my $useshrplib = $Config{useshrplib} =~ /^(true|yes)$/;
13 115 my $libs = $Config{libs};
14 115 my $so = $Config{so};
15 115 my $libperl = $Config{libperl};
16 115 my ($linkargs, $quiet, $debug);
17 115 ▶my $pkg = ($Config{usecperl} and $libperl =~ /libcperl/) ? "cperl" : "perl";
Branch: 1 branch
BranchTrueFalseTotal
$Config{'usecperl'} && $libperl =~ /libcperl/ ? : 0 115 115
Condition33%1/3
$Config{"usecperl"} and $libperl =~ /libcperl/
!ll&&!rl&&r
11500
MC/DC0%0/2
$Config{"usecperl"} and $libperl =~ /libcperl/
$Config{"usecperl"} $libperl =~ /libcperl/
Truth table33%1/3
A and B
A= $Config{"usecperl"}B= $libperl =~ /libcperl/
ABresult
0X0
100
111
18 115 ▶if (grep {$_ eq '-q' or $_ eq '--quiet'} @ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "-q" or $_ eq "--quiet";} @ARGV) 115 0 115
Condition66%2/3
$_ eq '-q' || $_ eq '--quiet'
l!l&&r!l&&!r
1150345
MC/DC50%1/2
$_ eq '-q' || $_ eq '--quiet'
$_ eq '-q' $_ eq '--quiet'
Truth table66%2/3
A || B
A= $_ eq '-q'B= $_ eq '--quiet'
ABresult
1X1
011
000
19 115 $quiet++;
20 115 ▶ @ARGV = grep {$_ ne '-q' and $_ ne '--quiet'} @ARGV;
Condition66%2/3
$_ ne '-q' && $_ ne '--quiet'
!ll&&!rl&&r
1150345
MC/DC50%1/2
$_ ne '-q' && $_ ne '--quiet'
$_ ne '-q' $_ ne '--quiet'
Truth table66%2/3
A && B
A= $_ ne '-q'B= $_ ne '--quiet'
ABresult
0X0
100
111
21 }
22 115 ▶if (grep {$_ eq '-d' or $_ eq '--debug'} @ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "-d" or $_ eq "--debug";} @ARGV) 0 115 115
Condition33%1/3
$_ eq '-d' || $_ eq '--debug'
l!l&&r!l&&!r
00345
MC/DC0%0/2
$_ eq '-d' || $_ eq '--debug'
$_ eq '-d' $_ eq '--debug'
Truth table33%1/3
A || B
A= $_ eq '-d'B= $_ eq '--debug'
ABresult
1X1
011
000
23 0 $debug++;
24 0 ▶ @ARGV = grep {$_ ne '-d' and $_ ne '--debug'} @ARGV;
Condition0%0/3
$_ ne '-d' && $_ ne '--debug'
!ll&&!rl&&r
000
MC/DC0%0/2
$_ ne '-d' && $_ ne '--debug'
$_ ne '-d' $_ ne '--debug'
Truth table0%0/3
A && B
A= $_ ne '-d'B= $_ ne '--debug'
ABresult
0X0
100
111
25 }
26 115 ▶if (grep {$_ eq '-A'} @ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "-A";} @ARGV) 0 115 115
27 0 @ARGV = grep {$_ ne '-A'} @ARGV;
28 0 push @ARGV, '-DALLOW_PERL_OPTIONS';
29 }
30 115 eval { require B::C::Config; };
31  
32 115 ▶if (grep(/^-[cES]$/, @ARGV)) { # compile-only with -c -E or -S
Branch: 6 branches
BranchTrueFalseTotal
if (grep /^-[cES]$/, @ARGV) { } 0 115 115
elsif (grep /^-Bdynamic$/, @ARGV) { } 0 115 115
elsif (grep /^-Bstatic$/, @ARGV) { } 0 115 115
elsif (-e "$coredir/$libperl" and not $libperl =~ /\.$so$/) { } 115 0 115
elsif ($useshrplib and -e "$libdir/$libperl") { } 0 0 0
elsif ($useshrplib and -e "$coredir/$libperl") { } 0 0 0
33 ;
34 } elsif (grep(/^-Bdynamic$/, @ARGV)) { # force dynamic linking with -Bdynamic
35 0 @ARGV = grep{ !/^-Bdynamic$/o } @ARGV;
36 0 $linkargs = ldopts;
37 } elsif (grep(/^-Bstatic$/, @ARGV)) { # force static linking with -Bstatic
38 0 @ARGV = grep{ !/^-Bstatic$/o } @ARGV;
39 0 $linkargs = ldopts("-std");
40 0 for my $lib ("$libdir/lib$pkg.a", "$coredir/lib$pkg.a") {
41 0 ▶ if (-e $lib) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $lib) 0 0 0
42 0 $linkargs =~ s|-l$pkg |$lib |;
43 0 ▶ push @ARGV, ("$coredir/DynaLoader.o") if -e "$coredir/DynaLoader.o";
Branch: 1 branch
BranchTrueFalseTotal
if -e "$coredir/DynaLoader.o" 0 0 0
44 #$linkargs .= " $coredir/Win32CORE.o" if $^O eq 'cygwin' and -e "$coredir/Win32CORE.o";
45 0 last;
46 }
47 }
48 ▶} elsif (-e "$coredir/$libperl" and $libperl !~ /\.$so$/) {
Condition33%1/3
-e "$coredir/$libperl" and not $libperl =~ /\.$so$/
!ll&&!rl&&r
00115
MC/DC0%0/2
-e "$coredir/$libperl" and not $libperl =~ /\.$so$/
-e "$coredir/$libperl" not $libperl =~ /\.$so$/
Truth table33%1/3
A and not(B)
A= -e "$coredir/$libperl"B= not $libperl =~ /\.$so$/
ABresult
0X0
100
111
49 115 $linkargs = ldopts("-std"); # importlib or static
50 ▶} elsif ( $useshrplib and -e "$libdir/$libperl") {
Condition0%0/3
$useshrplib and -e "$libdir/$libperl"
!ll&&!rl&&r
000
MC/DC0%0/2
$useshrplib and -e "$libdir/$libperl"
$useshrplib -e "$libdir/$libperl"
Truth table0%0/3
A and B
A= $useshrplibB= -e "$libdir/$libperl"
ABresult
0X0
100
111
51 # debian: /usr/lib/libperl.so.5.10.1 and broken ExtUtils::Embed::ldopts
52 0 $linkargs = ldopts('-std');
53 0 $linkargs =~ s|-lc?perl |$libdir/$libperl |;
54 ▶} elsif ( $useshrplib and -e "$coredir/$libperl") {
Condition0%0/3
$useshrplib and -e "$coredir/$libperl"
!ll&&!rl&&r
000
MC/DC0%0/2
$useshrplib and -e "$coredir/$libperl"
$useshrplib -e "$coredir/$libperl"
Truth table0%0/3
A and B
A= $useshrplibB= -e "$coredir/$libperl"
ABresult
0X0
100
111
55 # just help cygwin debugging
56 0 $linkargs = ldopts('-std');
57 0 $linkargs =~ s|-lc?perl |$coredir/$libperl |;
58 } else { # try dynamic lib if no static lib exists
59 0 @ARGV = grep{ !/^-Bdynamic$/o } @ARGV;
60 0 $linkargs = ldopts('-std');
61 }
62 # Note (probably harmless): No library found for -lnsl
63 # another ldopts bug: ensure Win32CORE gets added.
64 115 ▶if ($^O =~ /^(cygwin|MSWin32|msys)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /^(cygwin|MSWin32|msys)/) 0 115 115
65 0 ▶ if (index($linkargs, "Win32CORE") < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($linkargs, "Win32CORE") == -1) 0 0 0
66 0 ▶ my $archdir = $ENV{PERL_CORE} ? "../.." : $Config{archlib};
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERL_CORE'} ? : 0 0 0
67 0 my $win32core = "-L$archdir/lib/auto/Win32CORE -lWin32CORE";
68 0 ▶ if (-e "$archdir/lib/auto/Win32CORE/Win32CORE.a") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "$archdir/lib/auto/Win32CORE/Win32CORE.a") 0 0 0
69 0 $win32core = "$archdir/lib/auto/Win32CORE/Win32CORE.a";
70 }
71 0 ▶ if ($linkargs =~ m{ (-lc?perl|\S*/$libperl)}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($linkargs =~ m[ (-lc?perl|\S*/$libperl)]) { } 0 0 0
72 0 $linkargs =~ s{ (-lc?perl|\S*/$libperl)}{ $win32core $1};
73 } else {
74 0 $linkargs .= " $win32core";
75 }
76 }
77 }
78 115 ▶$linkargs .= " -L".$coredir if $ENV{PERL_CORE};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PERL_CORE"} 0 115 115
79 115 ▶$linkargs .= " -l$pkg" unless $linkargs =~ /( -lc?perl|CORE\/libc?perl)/;
Branch: 1 branch
BranchTrueFalseTotal
unless $linkargs =~ m[( -lc?perl|CORE/libc?perl)] 0 115 115
80 115 $linkargs = $B::C::Config::extra_libs . " " . $linkargs;
81 115 ▶$linkargs .= " $libs" if index($linkargs,$libs) == -1;
Branch: 1 branch
BranchTrueFalseTotal
if index($linkargs, $libs) == -1 0 115 115
82  
83 0 ▶sub cc_harness_msvc {
Subroutine cc_harness_msvc: not called CC=25 SCAR=64.8
84 0 my @ARGV = @_;
85 0 my $cfile = 'a.c';
86 0 my $Output;
87 0 for my $i (0 .. @ARGV) {
88 0 ▶ if ($ARGV[$i] eq '-o') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ARGV[$i] eq "-o") 0 0 0
89 0 $Output = $ARGV[$i+1];
90 }
91 }
92 0 my @cfile = grep {!/^-/} @ARGV;
93 0 ▶ if (@cfile == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@cfile == 1) { } 0 0 0
elsif (@cfile > 1) { } 0 0 0
94 0 $cfile = $cfile[0];
95 } elsif (@cfile > 1) {
96 0 die "too many arguments @cfile";
97 }
98 0 my $obj = $cfile;
99 0 $obj =~ s/\.c$/.obj/;
100 0 ▶ unless ($Output) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Output) 0 0 0
101 0 $Output = $cfile;
102 0 $Output =~ s/\.c$/.exe/;
103 }
104 0 my $compile = ccopts()." -c @ARGV ";
105 0 ▶ if ($debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) { } 0 0 0
106 0 ▶ $compile .= "/Wall " if !$quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless $quiet 0 0 0
107 # remove conflicting flags
108 0 $compile .= "-g ";
109 0 $compile =~ s/ -O.? / -Od /;
110 0 $compile =~ s/ -DNDEBUG / -DDEBUG /;
111 } else {
112 # avoid expensive optimisations with low memory (1-2 hours!)
113 0 ▶ $compile .= " -Od" if $ENV{APPVEYOR} and $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"APPVEYOR"} and $^O eq "MSWin32" 0 0 0
Condition0%0/3
$ENV{"APPVEYOR"} and $^O eq "MSWin32"
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"APPVEYOR"} and $^O eq "MSWin32"
$ENV{"APPVEYOR"} $^O eq "MSWin32"
Truth table0%0/3
A and B
A= $ENV{"APPVEYOR"}B= $^O eq "MSWin32"
ABresult
0X0
100
111
114 0 ▶ if ($ENV{PERL_CORE} and $Config{ccflags} =~ /-flto/) { # too big
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"PERL_CORE"} and $Config{"ccflags"} =~ /-flto/) 0 0 0
Condition0%0/3
$ENV{"PERL_CORE"} and $Config{"ccflags"} =~ /-flto/
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"PERL_CORE"} and $Config{"ccflags"} =~ /-flto/
$ENV{"PERL_CORE"} $Config{"ccflags"} =~ /-flto/
Truth table0%0/3
A and B
A= $ENV{"PERL_CORE"}B= $Config{"ccflags"} =~ /-flto/
ABresult
0X0
100
111
115 0 $compile =~ s/-O\d / -O1 /;
116 }
117 }
118 0 ▶ $compile .= "-DHAVE_INDEPENDENT_COMALLOC " if $B::C::Config::have_independent_comalloc;
Branch: 1 branch
BranchTrueFalseTotal
if $B::C::Config::have_independent_comalloc 0 0 0
119 0 $compile .= $B::C::Config::extra_cflags;
120 0 ▶ $compile = ' -I"..\..\lib\CORE"'.$compile if $ENV{PERL_CORE};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PERL_CORE"} 0 0 0
121 0 ▶ print "running $Config{cc} $compile" unless $quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless $quiet 0 0 0
122 0 system("$Config{cc} $compile");
123
124 0 my $link = "-out:$Output $obj ";
125 0 ▶ $link .= " -libpath:".$coredir if $ENV{PERL_CORE};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PERL_CORE"} 0 0 0
126 # TODO: -shared,-static,-sharedxs,-staticxs
127 0 $link .= (" ".$B::C::Config::extra_libs);
128 0 ▶ if ($stash) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stash) { } 0 0 0
129 0 my @mods = split /-?u /, $stash;
130 0 $link .= " ".ldopts("-std", \@mods);
131 } else {
132 0 $link .= " ".ldopts("-std");
133 }
134 0 $link .= " ".$Config{optimize};
135 0 ▶ if ($debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) { } 0 0 0
136 0 $link .= " /DEBUG";
137 } else {
138 # avoid expensive folding with low memory
139 0 ▶ $link .= " /OPT:NOREF" if $ENV{APPVEYOR} and $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"APPVEYOR"} and $^O eq "MSWin32" 0 0 0
Condition0%0/3
$ENV{"APPVEYOR"} and $^O eq "MSWin32"
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"APPVEYOR"} and $^O eq "MSWin32"
$ENV{"APPVEYOR"} $^O eq "MSWin32"
Truth table0%0/3
A and B
A= $ENV{"APPVEYOR"}B= $^O eq "MSWin32"
ABresult
0X0
100
111
140 }
141 0 ▶ if (index($link, "Win32CORE") < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($link, "Win32CORE") == -1) 0 0 0
142 0 ▶ my $archdir = $ENV{PERL_CORE} ? "../.." : $Config{archlib};
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERL_CORE'} ? : 0 0 0
143 0 my $win32core = "-L$archdir/lib/auto/Win32CORE -lWin32CORE";
144 0 ▶ if (-e "$archdir/lib/auto/Win32CORE/Win32CORE.lib") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "$archdir/lib/auto/Win32CORE/Win32CORE.lib") 0 0 0
145 0 $win32core = "$archdir/lib/auto/Win32CORE/Win32CORE.lib";
146 }
147 0 $link .= " $win32core";
148 }
149 0 ▶ $link .= " ".($Config{usecperl}?"c":"")."perl5$Config{PERL_VERSION}.lib";
Branch: 1 branch
BranchTrueFalseTotal
$Config{'usecperl'} ? : 0 0 0
150 0 $link .= " kernel32.lib msvcrt.lib";
151 0 ▶ print "running $Config{ld} $link" unless $quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless $quiet 0 0 0
152 0 system("$Config{ld} $link");
153 }
154  
155 115 ▶if ($^O eq 'MSWin32' && $Config{cc} =~ 'cl') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32" and $Config{"cc"} =~ /cl/) 0 115 115
Condition33%1/3
$^O eq "MSWin32" and $Config{"cc"} =~ /cl/
!ll&&!rl&&r
11500
MC/DC0%0/2
$^O eq "MSWin32" and $Config{"cc"} =~ /cl/
$^O eq "MSWin32" $Config{"cc"} =~ /cl/
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= $Config{"cc"} =~ /cl/
ABresult
0X0
100
111
156 0 cc_harness_msvc(@ARGV);
157 0 exit;
158 }
159  
160 # ActivePerl 5.10.0.1004 claims to use MSVC6 but used MSVC8
161 #if ($Config::Config{ccversion} eq '12.0.8804' and $Config::Config{cc} eq 'cl') {
162 # $linkargs =~ s/ -opt:ref,icf//;
163 #}
164  
165 115 my $ccflags = $Config{optimize}." ".$Config{ccflags};
166 # crashes on cygwin
167 115 ▶if ($^O eq 'cygwin' and $ccflags =~ /-fstack-protector /
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "cygwin" and $ccflags =~ /-fstack-protector / and $linkargs =~ /-fstack-protector /) 0 115 115
Condition33%2/6
$^O eq "cygwin" and $ccflags =~ /-fstack-protector / and $linkargs =~ /-fstack-protector /
!ll&&!rl&&r
11500
$^O eq "cygwin" and $ccflags =~ /-fstack-protector /
!ll&&!rl&&r
11500
MC/DC0%0/3
$^O eq "cygwin" and $ccflags =~ /-fstack-protector / and $linkargs =~ /-fstack-protector /
$^O eq "cygwin" $ccflags =~ /-fstack-protector / $linkargs =~ /-fstack-protector /
Truth table25%1/4
A and B and C
A= $^O eq "cygwin"B= $ccflags =~ /-fstack-protector /C= $linkargs =~ /-fstack-protector /
ABCresult
0XX0
10X0
1100
1111
168 and $linkargs =~ /-fstack-protector /)
169 {
170 0 $linkargs =~ s/-fstack-protector //;
171 }
172 #-pedantic -Wextra -Wconversion
173 115 ▶if ($debug and $Config{cc} =~ /\bgcc/ and $Config{gccversion}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug and $Config{"cc"} =~ /\bgcc/ and $Config{"gccversion"}) 0 115 115
Condition33%2/6
$debug and $Config{"cc"} =~ /\bgcc/ and $Config{"gccversion"}
!ll&&!rl&&r
11500
$debug and $Config{"cc"} =~ /\bgcc/
!ll&&!rl&&r
11500
MC/DC0%0/3
$debug and $Config{"cc"} =~ /\bgcc/ and $Config{"gccversion"}
$debug $Config{"cc"} =~ /\bgcc/ $Config{"gccversion"}
Truth table25%1/4
A and B and C
A= $debugB= $Config{"cc"} =~ /\bgcc/C= $Config{"gccversion"}
ABCresult
0XX0
10X0
1100
1111
174 0 ▶ $ccflags .= " -ansi -Wall -Wshadow -Wcast-qual -Wwrite-strings"
Branch: 1 branch
BranchTrueFalseTotal
unless $quiet 0 0 0
175 if !$quiet;
176 # remove conflicting flags, esp. -s for strip
177 0 $ccflags =~ s/ -O.? / /;
178 0 $ccflags =~ s/ -s / /;
179 0 $linkargs =~ s/-s / /;
180 }
181  
182 # -Wl,--warn-once is not gold compatible
183 $ccflags .= " --no-warn"
184 115 ▶ if $Config{cc} =~ /\bgcc/ and $Config{gccversion} and $quiet and $^O ne 'darwin';
Branch: 1 branch
BranchTrueFalseTotal
if $Config{"cc"} =~ /\bgcc/ and $Config{"gccversion"} and $quiet and $^O ne "darwin" 0 115 115
Condition33%3/9
$Config{"cc"} =~ /\bgcc/ and $Config{"gccversion"} and $quiet and $^O ne "darwin"
!ll&&!rl&&r
11500
$Config{"cc"} =~ /\bgcc/ and $Config{"gccversion"} and $quiet
!ll&&!rl&&r
11500
$Config{"cc"} =~ /\bgcc/ and $Config{"gccversion"}
!ll&&!rl&&r
11500
MC/DC0%0/4
$Config{"cc"} =~ /\bgcc/ and $Config{"gccversion"} and $quiet and $^O ne "darwin"
$Config{"cc"} =~ /\bgcc/ $Config{"gccversion"} $quiet $^O ne "darwin"
Truth table20%1/5
A and B and C and D
A= $Config{"cc"} =~ /\bgcc/B= $Config{"gccversion"}C= $quietD= $^O ne "darwin"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
185 115 ▶$ccflags .= " -DHAVE_INDEPENDENT_COMALLOC" if $B::C::Config::have_independent_comalloc;
Branch: 1 branch
BranchTrueFalseTotal
if $B::C::Config::have_independent_comalloc 0 115 115
186 115 $ccflags .= $B::C::Config::extra_cflags;
187  
188 115 my $cccmd = "$Config{cc} $ccflags -I$coredir @ARGV $linkargs";
189 115 ▶print "$cccmd\n" unless $quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless $quiet 0 115 115
190 115 exec $cccmd;
« blib/lib/B/C.pm ↑ Summary script/cc_harness »