| 1 | package Devel::XSCover::Build; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 31 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 31 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 31 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 31 | ▶ | use Config (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 31 | ▶ | use File::Find (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 31 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | 31 | ▶ | use IPC::Open3 (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 31 | ▶ | use Symbol (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | 31 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | 31 | our (%SOURCE_EXT, $COVERAGE); | |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | 31 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | 31 | %SOURCE_EXT = map { $_ => 1 } qw(xs c cc cpp cxx h hh hpp); | |||||||||||||||||||||||||||||||||
| 19 | 31 | $COVERAGE = '-fprofile-arcs -ftest-coverage'; | |||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | 86 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 23 | 86 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||
| 24 | my $self = bless { | ||||||||||||||||||||||||||||||||||
| 25 | dir => '.', | ||||||||||||||||||||||||||||||||||
| 26 | make => 'make', | ||||||||||||||||||||||||||||||||||
| 27 | perl => $^X, | ||||||||||||||||||||||||||||||||||
| 28 | cc => $Config::Config{cc}, | ||||||||||||||||||||||||||||||||||
| 29 | 86 | gcov => undef, | |||||||||||||||||||||||||||||||||
| 30 | conditions => undef, | ||||||||||||||||||||||||||||||||||
| 31 | flow => undef, | ||||||||||||||||||||||||||||||||||
| 32 | dry => 0, | ||||||||||||||||||||||||||||||||||
| 33 | silent => 0, | ||||||||||||||||||||||||||||||||||
| 34 | skip => [qw(blib cover_db .git)], | ||||||||||||||||||||||||||||||||||
| 35 | }, $class; | ||||||||||||||||||||||||||||||||||
| 36 | 86 | $self->{$_} = $args{$_} for keys %args; | |||||||||||||||||||||||||||||||||
| 37 | 86 | return $self; | |||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | sub dir { $_[0]{dir} } | ||||||||||||||||||||||||||||||||
|
Subroutine
dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | 69 | ▶ | sub compiler { | ||||||||||||||||||||||||||||||||
|
Subroutine
compiler: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 43 | 69 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 44 | 69 | ▶ | return $self->{compiler} if $self->{compiler}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 45 | 52 | ▶ | my $banner = $self->_capture($self->{cc}, '--version') // ''; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_capture($self->{"cc"}, "--version") // ""
MC/DC100%1/1
$self->_capture($self->{"cc"}, "--version") // ""
$self->_capture($self->{"cc"}, "--version")
Truth table100%2/2
A
A= $self->_capture($self->{"cc"}, "--version")
| |||||||||||||||||||||||||||||||||||
| 46 | 52 | my ($first) = split /\n/, $banner; | |||||||||||||||||||||||||||||||||
| 47 | 52 | ▶ | $first //= ''; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$first //= ""
MC/DC100%1/1
$first //= ""
$first
Truth table100%2/2
A
A= $first
| |||||||||||||||||||||||||||||||||||
| 48 | 52 | my %c = (cc => $self->{cc}, name => 'unknown', major => 0, banner => $first); | |||||||||||||||||||||||||||||||||
| 49 | 52 | ▶ | if ($first =~ /clang version (\d+)/) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 50 | 12 | @c{qw(name major)} = ('clang', $1); | |||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||
| 52 | ▶ | elsif ($first =~ /\b(?:gcc|g\+\+|GCC)\b/ || $banner =~ /Free Software Foundation/ | |||||||||||||||||||||||||||||||||
|
Condition100%6/6
$first =~ /\b(?:gcc|g\+\+|GCC)\b/u or $banner =~ /Free Software Foundation/u or $first =~ /^\S+ \([^)]*\) \d+\.\d+(?:\.\d+)?\b/u
$first =~ /\b(?:gcc|g\+\+|GCC)\b/u or $banner =~ /Free Software Foundation/u
MC/DC100%3/3
$first =~ /\b(?:gcc|g\+\+|GCC)\b/u or $banner =~ /Free Software Foundation/u or $first =~ /^\S+ \([^)]*\) \d+\.\d+(?:\.\d+)?\b/u
$first =~ /\b(?:gcc|g\+\+|GCC)\b/u
$banner =~ /Free Software Foundation/u
$first =~ /^\S+ \([^)]*\) \d+\.\d+(?:\.\d+)?\b/u
Truth table100%4/4
A or B or C
A= $first =~ /\b(?:gcc|g\+\+|GCC)\b/uB= $banner =~ /Free Software Foundation/uC= $first =~ /^\S+ \([^)]*\) \d+\.\d+(?:\.\d+)?\b/u
| |||||||||||||||||||||||||||||||||||
| 53 | || $first =~ /^\S+ \([^)]*\) \d+\.\d+(?:\.\d+)?\b/) { | ||||||||||||||||||||||||||||||||||
| 54 | 37 | ▶ | @c{qw(name major)} = ('gcc', $first =~ /(\d+)\.\d+(?:\.\d+)?/ ? $1 : 0); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||
| 56 | 52 | return $self->{compiler} = \%c; | |||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | 48 | ▶ | sub gcov_command { | ||||||||||||||||||||||||||||||||
|
Subroutine
gcov_command: called CC=16 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 60 | 48 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 61 | 48 | ▶ | return [ split ' ', $self->{gcov} ] if defined $self->{gcov} && length $self->{gcov}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"gcov"} and length $self->{"gcov"}
MC/DC100%2/2
defined $self->{"gcov"} and length $self->{"gcov"}
defined $self->{"gcov"}
length $self->{"gcov"}
Truth table100%3/3
A and B
A= defined $self->{"gcov"}B= length $self->{"gcov"}
| |||||||||||||||||||||||||||||||||||
| 62 | 19 | my $c = $self->compiler; | |||||||||||||||||||||||||||||||||
| 63 | 19 | ▶ | if ($c->{name} eq 'clang') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 64 | 12 | my $gcov = $self->_which('gcov'); | |||||||||||||||||||||||||||||||||
| 65 | 12 | ▶ | if ($gcov) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 66 | 5 | ▶ | my $banner = $self->_capture($gcov, '--version') // ''; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_capture($gcov, "--version") // ""
MC/DC100%1/1
$self->_capture($gcov, "--version") // ""
$self->_capture($gcov, "--version")
Truth table100%2/2
A
A= $self->_capture($gcov, "--version")
| |||||||||||||||||||||||||||||||||||
| 67 | 5 | ▶ | return [$gcov] if $banner =~ /LLVM/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||
| 69 | 11 | for my $name ("llvm-cov-$c->{major}", 'llvm-cov') { | |||||||||||||||||||||||||||||||||
| 70 | 21 | my $path = $self->_which($name); | |||||||||||||||||||||||||||||||||
| 71 | 21 | ▶ | return [$path, 'gcov'] if $path; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||
| 73 | 8 | ▶ | if ($^O eq 'darwin') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | my $found = $self->_capture('xcrun', '--find', 'llvm-cov') // ''; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_capture("xcrun", "--find", "llvm-cov") // ""
MC/DC100%1/1
$self->_capture("xcrun", "--find", "llvm-cov") // ""
$self->_capture("xcrun", "--find", "llvm-cov")
Truth table100%2/2
A
A= $self->_capture("xcrun", "--find", "llvm-cov")
| |||||||||||||||||||||||||||||||||||
| 75 | 4 | chomp $found; | |||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | return [$found, 'gcov'] if length $found && -x $found; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $found and -x $found
MC/DC100%2/2
length $found and -x $found
length $found
-x $found
Truth table100%3/3
A and B
A= length $foundB= -x $found
| |||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||
| 78 | 7 | ▶ | return [ $gcov || 'gcov' ]; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$gcov || 'gcov'
MC/DC100%1/1
$gcov || 'gcov'
$gcov
Truth table100%2/2
A
A= $gcov
| |||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||
| 80 | 7 | for my $name ("gcov-$c->{major}", 'gcov') { | |||||||||||||||||||||||||||||||||
| 81 | 11 | my $path = $self->_which($name); | |||||||||||||||||||||||||||||||||
| 82 | 11 | ▶ | return [$path] if $path; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||
| 84 | 1 | return ['gcov']; | |||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | 43 | ▶ | sub conditions { | ||||||||||||||||||||||||||||||||
|
Subroutine
conditions: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 88 | 43 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 89 | 43 | ▶ | return $self->{conditions} ? 1 : 0 if defined $self->{conditions}; | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 90 | 37 | my $c = $self->compiler; | |||||||||||||||||||||||||||||||||
| 91 | 37 | ▶ | return $c->{name} eq 'gcc' && $c->{major} >= 14 ? 1 : 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c->{"name"} eq "gcc" and $c->{"major"} >= 14
MC/DC100%2/2
$c->{"name"} eq "gcc" and $c->{"major"} >= 14
$c->{"name"} eq "gcc"
$c->{"major"} >= 14
Truth table100%3/3
A and B
A= $c->{"name"} eq "gcc"B= $c->{"major"} >= 14
| |||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | 20 | ▶ | sub flow_kind { | ||||||||||||||||||||||||||||||||
|
Subroutine
flow_kind: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 95 | 20 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 96 | 20 | ▶ | return $self->{flow} if defined $self->{flow}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 97 | 18 | ▶ | my $banner = $self->_capture(@{ $self->gcov_command }, '--version') // ''; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_capture(@{$self->gcov_command;}, "--version") // ""
MC/DC100%1/1
$self->_capture(@{$self->gcov_command;}, "--version") // ""
$self->_capture(@{$self->gcov_command;}, "--version")
Truth table100%2/2
A
A= $self->_capture(@{$self->gcov_command;}, "--version")
| |||||||||||||||||||||||||||||||||||
| 98 | 18 | ▶ | return $self->{flow} = 'llvm' if $banner =~ /LLVM/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 99 | 16 | ▶ | return $self->{flow} = 'gcc' if $banner =~ /\b(\d+)\.\d+(?:\.\d+)?\b/ && $1 >= 9; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$banner =~ /\b(\d+)\.\d+(?:\.\d+)?\b/u and $1 >= 9
MC/DC100%2/2
$banner =~ /\b(\d+)\.\d+(?:\.\d+)?\b/u and $1 >= 9
$banner =~ /\b(\d+)\.\d+(?:\.\d+)?\b/u
$1 >= 9
Truth table100%3/3
A and B
A= $banner =~ /\b(\d+)\.\d+(?:\.\d+)?\b/uB= $1 >= 9
| |||||||||||||||||||||||||||||||||||
| 100 | 13 | return $self->{flow} = ''; | |||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||
| 103 | 27 | ▶ | sub flags { | ||||||||||||||||||||||||||||||||
|
Subroutine
flags: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 104 | 27 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 105 | 27 | ▶ | my $condition = $self->conditions ? ' -fcondition-coverage' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 106 | return ( | ||||||||||||||||||||||||||||||||||
| 107 | 27 | "OPTIMIZE=-O0 -g $COVERAGE -fprofile-update=atomic$condition", | |||||||||||||||||||||||||||||||||
| 108 | "OTHERLDFLAGS=$COVERAGE", | ||||||||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | 30 | ▶ | sub needs_configure { | ||||||||||||||||||||||||||||||||
|
Subroutine
needs_configure: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 113 | 30 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 114 | 30 | my $makefile = File::Spec->catfile($self->{dir}, 'Makefile'); | |||||||||||||||||||||||||||||||||
| 115 | 30 | my $pl = File::Spec->catfile($self->{dir}, 'Makefile.PL'); | |||||||||||||||||||||||||||||||||
| 116 | 30 | ▶ | return 1 unless -f $makefile; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 117 | 24 | ▶ | return 1 unless -f $pl; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 118 | 23 | ▶ | return (stat $makefile)[9] < (stat $pl)[9] ? 1 : 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||
| 121 | 15 | ▶ | sub clean_globs { | ||||||||||||||||||||||||||||||||
|
Subroutine
clean_globs: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 122 | 15 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 123 | 15 | my $pl = File::Spec->catfile($self->{dir}, 'Makefile.PL'); | |||||||||||||||||||||||||||||||||
| 124 | 15 | ▶ | open my $fh, '<', $pl or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 125 | 13 | my $text = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||
| 126 | 13 | close $fh; | |||||||||||||||||||||||||||||||||
| 127 | 13 | my @globs; | |||||||||||||||||||||||||||||||||
| 128 | 13 | ▶ | while ($text =~ /clean\s*=>\s*\{[^}]*?FILES\s*=>\s*(['"])(.*?)\1/sg) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 129 | 13 | push @globs, split ' ', $2; | |||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||
| 131 | 13 | ▶ | my ($name) = $text =~ /\bNAME\s*=>\s*(['"])(.*?)\1/ ? $2 : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 132 | 13 | (my $dist = $name) =~ s/::/-/g; | |||||||||||||||||||||||||||||||||
| 133 | 13 | my @out; | |||||||||||||||||||||||||||||||||
| 134 | 13 | for my $glob (@globs) { | |||||||||||||||||||||||||||||||||
| 135 | 23 | $glob =~ s/\$\(DISTNAME\)/$dist/g; | |||||||||||||||||||||||||||||||||
| 136 | 23 | ▶ | next if $glob =~ /\$\(/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 137 | 21 | push @out, $glob; | |||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||
| 139 | 13 | return @out; | |||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||
| 142 | 10 | ▶ | sub tarballs_at_risk { | ||||||||||||||||||||||||||||||||
|
Subroutine
tarballs_at_risk: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 143 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 144 | 10 | my %seen; | |||||||||||||||||||||||||||||||||
| 145 | my @hit; | ||||||||||||||||||||||||||||||||||
| 146 | 10 | for my $glob ($self->clean_globs) { | |||||||||||||||||||||||||||||||||
| 147 | 31 | ▶ | for my $file (glob File::Spec->catfile($self->{dir}, $glob)) { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 148 | 12 | ▶ | next unless $file =~ /\.(?:tar\.gz|tgz|zip)\z/ && -f $file; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$file =~ /\.(?:tar\.gz|tgz|zip)\z/u and -f $file
MC/DC100%2/2
$file =~ /\.(?:tar\.gz|tgz|zip)\z/u and -f $file
$file =~ /\.(?:tar\.gz|tgz|zip)\z/u
-f $file
Truth table100%3/3
A and B
A= $file =~ /\.(?:tar\.gz|tgz|zip)\z/uB= -f $file
| |||||||||||||||||||||||||||||||||||
| 149 | 7 | ▶ | push @hit, $file unless $seen{$file}++; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||
| 152 | 10 | return @hit; | |||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||
| 155 | 25 | ▶ | sub configure { | ||||||||||||||||||||||||||||||||
|
Subroutine
configure: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 156 | 25 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 157 | 25 | ▶ | return 0 unless $self->needs_configure; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 158 | 7 | ▶ | if (-f File::Spec->catfile($self->{dir}, 'Makefile')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 159 | 2 | my @risk = $self->tarballs_at_risk; | |||||||||||||||||||||||||||||||||
| 160 | 2 | ▶ | warn "xs_cover: a stale Makefile reruns clean by itself, and the clean glob in " | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 161 | . "Makefile.PL matches @risk\n" if @risk; | ||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||
| 163 | 7 | return $self->_run($self->{perl}, 'Makefile.PL'); | |||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||
| 166 | 33 | ▶ | sub touch { | ||||||||||||||||||||||||||||||||
|
Subroutine
touch: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 167 | 33 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 168 | 33 | my %skip = map { $_ => 1 } @{ $self->{skip} }; | |||||||||||||||||||||||||||||||||
| 169 | 33 | my $top = _slashes($self->{dir}); | |||||||||||||||||||||||||||||||||
| 170 | 33 | my $now = time; | |||||||||||||||||||||||||||||||||
| 171 | 33 | my @touched; | |||||||||||||||||||||||||||||||||
| 172 | File::Find::find({ | ||||||||||||||||||||||||||||||||||
| 173 | no_chdir => 1, | ||||||||||||||||||||||||||||||||||
| 174 | 407 | ▶ | wanted => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||
| 175 | 407 | ▶ | if (-d $_) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 176 | 111 | my $base = (File::Spec->splitdir($_))[-1]; | |||||||||||||||||||||||||||||||||
| 177 | 111 | ▶ | $File::Find::prune = 1 if $skip{$base} && _slashes($_) ne $top; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$skip{$base} and _slashes($_) ne $top
MC/DC100%2/2
$skip{$base} and _slashes($_) ne $top
$skip{$base}
_slashes($_) ne $top
Truth table100%3/3
A and B
A= $skip{$base}B= _slashes($_) ne $top
| |||||||||||||||||||||||||||||||||||
| 178 | 111 | return; | |||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||
| 180 | 296 | ▶ | return unless /\.([A-Za-z]+)\z/ && $SOURCE_EXT{ lc $1 }; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
/\.([A-Za-z]+)\z/u and $Devel::XSCover::Build::SOURCE_EXT{lc $1}
MC/DC100%2/2
/\.([A-Za-z]+)\z/u and $Devel::XSCover::Build::SOURCE_EXT{lc $1}
/\.([A-Za-z]+)\z/u
$Devel::XSCover::Build::SOURCE_EXT{lc $1}
Truth table100%3/3
A and B
A= /\.([A-Za-z]+)\z/uB= $Devel::XSCover::Build::SOURCE_EXT{lc $1}
| |||||||||||||||||||||||||||||||||||
| 181 | 89 | ▶ | return if lc $1 eq 'c' && -f substr($_, 0, -1) . 'xs'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
lc $1 eq "c" and -f substr($_, 0, -1) . 'xs'
MC/DC100%2/2
lc $1 eq "c" and -f substr($_, 0, -1) . 'xs'
lc $1 eq "c"
-f substr($_, 0, -1) . 'xs'
Truth table100%3/3
A and B
A= lc $1 eq "c"B= -f substr($_, 0, -1) . 'xs'
| |||||||||||||||||||||||||||||||||||
| 182 | 78 | push @touched, $_; | |||||||||||||||||||||||||||||||||
| 183 | 78 | ▶ | utime $now, $now, $_ unless $self->{dry}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 184 | }, | ||||||||||||||||||||||||||||||||||
| 185 | 33 | }, $self->{dir}); | |||||||||||||||||||||||||||||||||
| 186 | 33 | ▶ | $self->_say(sprintf 'xs_cover: touched %d source file%s', scalar @touched, @touched == 1 ? '' : 's'); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 187 | 33 | return @touched; | |||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||
| 190 | 24 | ▶ | sub build { | ||||||||||||||||||||||||||||||||
|
Subroutine
build: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 191 | 24 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 192 | 24 | return $self->_run($self->{make}, $self->flags); | |||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||
| 195 | 20 | ▶ | sub run { | ||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 196 | 20 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 197 | 20 | my $status = $self->configure; | |||||||||||||||||||||||||||||||||
| 198 | 20 | ▶ | return $status if $status; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 199 | 19 | $self->touch; | |||||||||||||||||||||||||||||||||
| 200 | 19 | return $self->build; | |||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||
| 203 | 31 | ▶ | sub _run { | ||||||||||||||||||||||||||||||||
|
Subroutine
_run: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||
| 204 | 31 | my ($self, @cmd) = @_; | |||||||||||||||||||||||||||||||||
| 205 | 31 | $self->_say("xs_cover: running @cmd"); | |||||||||||||||||||||||||||||||||
| 206 | 31 | ▶ | return 0 if $self->{dry}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 207 | 24 | my $status; | |||||||||||||||||||||||||||||||||
| 208 | 24 | ▶ | if ($self->{dir} eq '.') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 209 | 1 | $status = system @cmd; | |||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||
| 211 | else { | ||||||||||||||||||||||||||||||||||
| 212 | 23 | require Cwd; | |||||||||||||||||||||||||||||||||
| 213 | 23 | my $here = Cwd::getcwd(); | |||||||||||||||||||||||||||||||||
| 214 | 23 | ▶ | chdir $self->{dir} or die "xs_cover: cannot chdir to $self->{dir}: $!\n"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 215 | 22 | $status = system @cmd; | |||||||||||||||||||||||||||||||||
| 216 | 22 | chdir $here; | |||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||
| 218 | 23 | ▶ | return $status == -1 ? 127 : $status >> 8; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||
| 221 | 64 | ▶ | sub _say { | ||||||||||||||||||||||||||||||||
|
Subroutine
_say: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 222 | 64 | my ($self, $line) = @_; | |||||||||||||||||||||||||||||||||
| 223 | 64 | ▶ | print "$line\n" unless $self->{silent}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||
| 226 | 75 | ▶ | sub _capture { | ||||||||||||||||||||||||||||||||
|
Subroutine
_capture: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 227 | 75 | my ($self, @cmd) = @_; | |||||||||||||||||||||||||||||||||
| 228 | 75 | local *NULL; | |||||||||||||||||||||||||||||||||
| 229 | 75 | open NULL, '>', File::Spec->devnull; | |||||||||||||||||||||||||||||||||
| 230 | 75 | my ($in, $out) = (undef, Symbol::gensym()); | |||||||||||||||||||||||||||||||||
| 231 | 75 | my $pid = eval { IPC::Open3::open3($in, $out, '>&NULL', @cmd) }; | |||||||||||||||||||||||||||||||||
| 232 | 75 | ▶ | return undef unless $pid; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 233 | 73 | close $in; | |||||||||||||||||||||||||||||||||
| 234 | 73 | my $text = do { local $/; <$out> }; | |||||||||||||||||||||||||||||||||
| 235 | 73 | close $out; | |||||||||||||||||||||||||||||||||
| 236 | 73 | waitpid $pid, 0; | |||||||||||||||||||||||||||||||||
| 237 | 73 | return $text; | |||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | 47 | ▶ | sub _slashes { | ||||||||||||||||||||||||||||||||
|
Subroutine
_slashes: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 241 | 47 | my ($path) = @_; | |||||||||||||||||||||||||||||||||
| 242 | 47 | ▶ | $path =~ s{\\}{/}g if $^O eq 'MSWin32'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 243 | 47 | return $path; | |||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||
| 246 | 44 | ▶ | sub _which { | ||||||||||||||||||||||||||||||||
|
Subroutine
_which: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||
| 247 | 44 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||
| 248 | 44 | for my $dir (File::Spec->path) { | |||||||||||||||||||||||||||||||||
| 249 | 58 | my $path = File::Spec->catfile($dir, $name); | |||||||||||||||||||||||||||||||||
| 250 | 58 | ▶ | return $path if -f $path && -x $path; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
-f $path and -x $path
MC/DC100%2/2
-f $path and -x $path
-f $path
-x $path
Truth table100%3/3
A and B
A= -f $pathB= -x $path
| |||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||
| 252 | 30 | return undef; | |||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||
| 255 | 31 | 1; | |||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||
| 257 | __END__ | ||||||||||||||||||||||||||||||||||