| 1 | package Devel::XSCover; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 18 | ▶ | use 5.020; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 18 | ▶ | use Config (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 18 | ▶ | use Cwd (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 18 | ▶ | use File::Path (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 18 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 18 | ▶ | use Getopt::Long (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 18 | ▶ | use Pod::Usage (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 18 | ▶ | use Devel::XSCover::Build (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 18 | ▶ | use Devel::XSCover::Test (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 18 | ▶ | use Devel::XSCover::XS (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 18 | ▶ | use Devel::XSCover::Gcov (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 18 | ▶ | use Devel::XSCover::DB (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 18 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 18 | our (%DEFAULTS); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 18 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 18 | %DEFAULTS = ( | |||||||||||||||||||||||||||
| 25 | dir => '.', | ||||||||||||||||||||||||||||
| 26 | db => 'cover_db', | ||||||||||||||||||||||||||||
| 27 | report => 'XSCover', | ||||||||||||||||||||||||||||
| 28 | make => 'make', | ||||||||||||||||||||||||||||
| 29 | test => [], | ||||||||||||||||||||||||||||
| 30 | plain => [], | ||||||||||||||||||||||||||||
| 31 | timeout => 0, | ||||||||||||||||||||||||||||
| 32 | ignore => [], | ||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 29 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 29 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 38 | 29 | my $self = bless { %DEFAULTS }, $class; | |||||||||||||||||||||||||||
| 39 | 29 | $self->{$_} = $args{$_} for keys %args; | |||||||||||||||||||||||||||
| 40 | 29 | ▶ | $self->{test} = [ $self->{test} ] unless ref $self->{test}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 29 | ▶ | $self->{plain} = [ $self->{plain} ] unless ref $self->{plain}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 29 | ▶ | $self->{ignore} = [ $self->{ignore} ] unless ref $self->{ignore}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 29 | return $self; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 7 | ▶ | sub defaults_from_file { | ||||||||||||||||||||||||||
|
Subroutine
defaults_from_file: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 7 | my ($class, @argv) = @_; | |||||||||||||||||||||||||||
| 48 | 7 | my $dir = '.'; | |||||||||||||||||||||||||||
| 49 | 7 | for my $i (0 .. $#argv - 1) { | |||||||||||||||||||||||||||
| 50 | 36 | ▶ | $dir = $argv[$i + 1] if $argv[$i] eq '-dir' || $argv[$i] eq '--dir'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$argv[$i] eq "-dir" or $argv[$i] eq "--dir"
MC/DC50%1/2
$argv[$i] eq "-dir" or $argv[$i] eq "--dir"
$argv[$i] eq "-dir"
$argv[$i] eq "--dir"
Truth table66%2/3
A or B
A= $argv[$i] eq "-dir"B= $argv[$i] eq "--dir"
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 7 | my $file = File::Spec->catfile($dir, '.xs_cover'); | |||||||||||||||||||||||||||
| 53 | 7 | ▶ | open my $fh, '<', $file or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 1 | my @words; | |||||||||||||||||||||||||||
| 55 | 1 | ▶ | while (my $line = <$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 3 | $line =~ s/#.*//; | |||||||||||||||||||||||||||
| 57 | 3 | for my $word (split ' ', $line) { | |||||||||||||||||||||||||||
| 58 | 6 | $word =~ s/^(['"])(.*)\1$/$2/; | |||||||||||||||||||||||||||
| 59 | 6 | push @words, $word; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | 1 | close $fh; | |||||||||||||||||||||||||||
| 63 | 1 | return @words; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 6 | ▶ | sub new_from_argv { | ||||||||||||||||||||||||||
|
Subroutine
new_from_argv: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 67 | 6 | my ($class, @argv) = @_; | |||||||||||||||||||||||||||
| 68 | 6 | unshift @argv, $class->defaults_from_file(@argv); | |||||||||||||||||||||||||||
| 69 | 6 | my %opt = (test => [], plain => [], ignore => []); | |||||||||||||||||||||||||||
| 70 | 6 | my $parser = Getopt::Long::Parser->new(config => [qw(no_ignore_case)]); | |||||||||||||||||||||||||||
| 71 | 6 | ▶ | $parser->getoptionsfromarray(\@argv, \%opt, qw( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | dir=s db=s report=s gcov=s make=s cover=s | ||||||||||||||||||||||||||||
| 73 | test=s@ plain=s@ ignore=s@ timeout=i keep no_delete no_perl threads_covered dry silent | ||||||||||||||||||||||||||||
| 74 | help|h version|v | ||||||||||||||||||||||||||||
| 75 | )) or Pod::Usage::pod2usage(-exitval => 2, -verbose => 0, -input => $0); | ||||||||||||||||||||||||||||
| 76 | 5 | ▶ | Pod::Usage::pod2usage(-exitval => 0, -verbose => 1, -input => $0) if $opt{help}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 4 | ▶ | if ($opt{version}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 1 | print "xs_cover version $VERSION\n"; | |||||||||||||||||||||||||||
| 79 | 1 | exit 0; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | 3 | ▶ | Pod::Usage::pod2usage(-exitval => 2, -verbose => 0, -input => $0, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | -message => "xs_cover: unexpected argument @argv") if @argv; | ||||||||||||||||||||||||||||
| 83 | 2 | delete @opt{qw(help version)}; | |||||||||||||||||||||||||||
| 84 | 2 | return $class->new(%opt); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 2 | ▶ | sub dir { $_[0]{dir} } | ||||||||||||||||||||||||||
|
Subroutine
dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | 2 | ▶ | sub db { $_[0]{db} } | ||||||||||||||||||||||||||
|
Subroutine
db: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 89 | 1 | ▶ | sub cover { $_[0]{cover} } | ||||||||||||||||||||||||||
|
Subroutine
cover: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 2 | ▶ | sub make { $_[0]{make} } | ||||||||||||||||||||||||||
|
Subroutine
make: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | 3 | ▶ | sub tests { @{ $_[0]{test} } } | ||||||||||||||||||||||||||
|
Subroutine
tests: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 3 | ▶ | sub plains { @{ $_[0]{plain} } } | ||||||||||||||||||||||||||
|
Subroutine
plains: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | 20 | ▶ | sub timeout { $_[0]{timeout} || 0 } | ||||||||||||||||||||||||||
|
Subroutine
timeout: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 4 | ▶ | sub ignores { @{ $_[0]{ignore} } } | ||||||||||||||||||||||||||
|
Subroutine
ignores: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | 13 | ▶ | sub keep { $_[0]{keep} ? 1 : 0 } | ||||||||||||||||||||||||||
|
Subroutine
keep: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 45 | ▶ | sub dry { $_[0]{dry} ? 1 : 0 } | ||||||||||||||||||||||||||
|
Subroutine
dry: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 14 | ▶ | sub silent { $_[0]{silent} ? 1 : 0 } | ||||||||||||||||||||||||||
|
Subroutine
silent: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 20 | ▶ | sub gcov { $_[0]{gcov} } | ||||||||||||||||||||||||||
|
Subroutine
gcov: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 19 | ▶ | sub delete_db { $_[0]{no_delete} ? 0 : 1 } | ||||||||||||||||||||||||||
|
Subroutine
delete_db: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 19 | ▶ | sub no_perl { $_[0]{no_perl} ? 1 : 0 } | ||||||||||||||||||||||||||
|
Subroutine
no_perl: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 18 | ▶ | sub threads_covered { $_[0]{threads_covered} ? 1 : 0 } | ||||||||||||||||||||||||||
|
Subroutine
threads_covered: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 17 | ▶ | sub cover_command { | ||||||||||||||||||||||||||
|
Subroutine
cover_command: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 105 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||
| 106 | 17 | ▶ | return [ split ' ', $self->{cover} ] if defined $self->{cover} && length $self->{cover}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"cover"} and length $self->{"cover"}
MC/DC100%2/2
defined $self->{"cover"} and length $self->{"cover"}
defined $self->{"cover"}
length $self->{"cover"}
Truth table100%3/3
A and B
A= defined $self->{"cover"}B= length $self->{"cover"}
| |||||||||||||||||||||||||||||
| 107 | 5 | my @inc = $self->report_inc; | |||||||||||||||||||||||||||
| 108 | 5 | my ($vol, $bin) = File::Spec->splitpath($^X); | |||||||||||||||||||||||||||
| 109 | 5 | ▶ | for my $dir (File::Spec->catpath($vol, $bin, ''), grep { defined && length } @Config::Config{qw(installsitescript installsitebin installscript)}) { | ||||||||||||||||||||||||||
|
Condition100%3/3
defined $_ && length $_
MC/DC100%2/2
defined $_ && length $_
defined $_
length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||
| 110 | 8 | my $path = File::Spec->catfile($dir, 'cover'); | |||||||||||||||||||||||||||
| 111 | 8 | ▶ | return [ $^X, @inc, $path ] if -f $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | 2 | return ['cover']; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 8 | ▶ | sub report_inc { | ||||||||||||||||||||||||||
|
Subroutine
report_inc: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | 8 | ▶ | my $pm = $INC{'Devel/XSCover.pm'} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 7 | (my $lib = $pm) =~ s{[/\\]Devel[/\\]XSCover\.pm\z}{}; | |||||||||||||||||||||||||||
| 119 | 7 | ▶ | return -f File::Spec->catfile($lib, 'Devel', 'Cover', 'Report', 'XSCover.pm') ? ("-I$lib") : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 58 | ▶ | sub skip_dirs { | ||||||||||||||||||||||||||
|
Subroutine
skip_dirs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 123 | 58 | my ($self) = @_; | |||||||||||||||||||||||||||
| 124 | 58 | my $db = (File::Spec->splitdir($self->{db}))[-1]; | |||||||||||||||||||||||||||
| 125 | 58 | return [ 'blib', '.git', $db ]; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 18 | ▶ | sub run { | ||||||||||||||||||||||||||
|
Subroutine
run: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 129 | 18 | my ($self) = @_; | |||||||||||||||||||||||||||
| 130 | 18 | my %common = map { $_ => $self->{$_} } qw(dir make dry silent); | |||||||||||||||||||||||||||
| 131 | 18 | my $build = Devel::XSCover::Build->new(%common, gcov => $self->gcov, skip => $self->skip_dirs); | |||||||||||||||||||||||||||
| 132 | 18 | my $status = $build->run; | |||||||||||||||||||||||||||
| 133 | 18 | ▶ | if ($status) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 1 | warn "xs_cover: the build failed with status $status\n"; | |||||||||||||||||||||||||||
| 135 | 1 | return $status; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | my $test = Devel::XSCover::Test->new(%common, db => $self->{db}, test => $self->{test}, plain => $self->{plain}, | ||||||||||||||||||||||||||||
| 138 | 17 | delete => $self->delete_db, timeout => $self->timeout, no_perl => $self->no_perl, threads_covered => $self->threads_covered); | |||||||||||||||||||||||||||
| 139 | 17 | my $finder = Devel::XSCover::Gcov->new(%common, skip => $self->skip_dirs); | |||||||||||||||||||||||||||
| 140 | 17 | my $stale = $self->remove_counters($finder); | |||||||||||||||||||||||||||
| 141 | 17 | ▶ | $self->_say("xs_cover: removed $stale stale counter file" . ($stale == 1 ? '' : 's') . ' left by an earlier run') if $stale; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 142 | 17 | $status = $test->run; | |||||||||||||||||||||||||||
| 143 | 11 | ▶ | warn "xs_cover: the tests failed with status $status, reporting what ran\n" if $status; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 11 | my @maps = Devel::XSCover::XS->new(dir => $self->{dir}, skip => $self->skip_dirs)->read; | |||||||||||||||||||||||||||
| 145 | my $reader = Devel::XSCover::Gcov->new(%common, gcov => $build->gcov_command, conditions => $build->conditions, flow => $build->flow_kind, ignore => $self->{ignore}, | ||||||||||||||||||||||||||||
| 146 | 3 | generated => [ map { $_->{c} } @maps ], xsubs => { map { my $m = $_; map { $_ => $m->{xsubs}{$_}{file} } keys %{ $m->{xsubs} } } @maps }, | |||||||||||||||||||||||||||
| 147 | 11 | ▶ | inverse => { map { %{ $_->{inverse} || {} } } @maps }, | ||||||||||||||||||||||||||
|
Condition50%1/2
$_->{'inverse'} || {}
MC/DC0%0/1
$_->{'inverse'} || {}
$_->{'inverse'}
Truth table50%1/2
A
A= $_->{'inverse'}
| |||||||||||||||||||||||||||||
| 148 | skip => $self->skip_dirs, save => $self->gcov_dir($test->db_path)); | ||||||||||||||||||||||||||||
| 149 | 11 | my @objects = $reader->read; | |||||||||||||||||||||||||||
| 150 | 11 | my $writer = Devel::XSCover::DB->new(%common, db => $test->db_path); | |||||||||||||||||||||||||||
| 151 | 11 | my $entries = $writer->entries($writer->merge(@objects), @maps); | |||||||||||||||||||||||||||
| 152 | 11 | ▶ | if (%$entries) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 3 | $writer->write($entries); | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | else { | ||||||||||||||||||||||||||||
| 156 | 8 | $self->_say('xs_cover: no C counters found, nothing to write'); | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | 11 | $self->report($test->db_path); | |||||||||||||||||||||||||||
| 159 | 11 | ▶ | $self->cleanup($build, $reader, $test->db_path) unless $self->keep; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 11 | return $status; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 12 | ▶ | sub report { | ||||||||||||||||||||||||||
|
Subroutine
report: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 164 | 12 | my ($self, $db) = @_; | |||||||||||||||||||||||||||
| 165 | 12 | ▶ | my @cmd = (@{ $self->cover_command }, '-nogcov', '-report', $self->report_name, $self->silent ? ('-silent') : (), $db); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 12 | $self->_say("xs_cover: running @cmd"); | |||||||||||||||||||||||||||
| 167 | 12 | ▶ | return 0 if $self->dry; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 11 | my $here = Cwd::getcwd(); | |||||||||||||||||||||||||||
| 169 | 11 | ▶ | chdir $self->{dir} or die "xs_cover: cannot chdir to $self->{dir}: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 10 | my $status = system @cmd; | |||||||||||||||||||||||||||
| 171 | 10 | chdir $here; | |||||||||||||||||||||||||||
| 172 | 10 | ▶ | $status = $status == -1 ? 127 : $status >> 8; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 10 | ▶ | warn "xs_cover: cover exited with status $status\n" if $status; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | 10 | return $status; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 21 | ▶ | sub gcov_dir { | ||||||||||||||||||||||||||
|
Subroutine
gcov_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 21 | my ($self, $db) = @_; | |||||||||||||||||||||||||||
| 179 | 21 | return "$db.gcov"; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 27 | ▶ | sub remove_counters { | ||||||||||||||||||||||||||
|
Subroutine
remove_counters: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 183 | 27 | my ($self, $reader, $graphs) = @_; | |||||||||||||||||||||||||||
| 184 | 27 | my @gone; | |||||||||||||||||||||||||||
| 185 | 27 | for my $gcda ($reader->find_gcda) { | |||||||||||||||||||||||||||
| 186 | 20 | (my $gcno = $gcda) =~ s/\.gcda\z/.gcno/; | |||||||||||||||||||||||||||
| 187 | 20 | ▶ | for my $rel ($gcda, ($graphs ? $gcno : ())) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 31 | my $path = File::Spec->catfile($self->{dir}, $rel); | |||||||||||||||||||||||||||
| 189 | 31 | ▶ | next unless -f $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 22 | push @gone, $rel; | |||||||||||||||||||||||||||
| 191 | 22 | ▶ | unlink $path unless $self->dry; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | 27 | return scalar @gone; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 10 | ▶ | sub cleanup { | ||||||||||||||||||||||||||
|
Subroutine
cleanup: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 198 | 10 | my ($self, $build, $reader, $db) = @_; | |||||||||||||||||||||||||||
| 199 | 10 | my @gone = (1) x $self->remove_counters($reader, 1); | |||||||||||||||||||||||||||
| 200 | 10 | my $saved = $self->gcov_dir($db); | |||||||||||||||||||||||||||
| 201 | 10 | ▶ | File::Path::remove_tree($saved) if -d $saved && !$self->dry; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
-d $saved and not $self->dry
MC/DC100%2/2
-d $saved and not $self->dry
-d $saved
not $self->dry
Truth table100%3/3
A and not(B)
A= -d $savedB= not $self->dry
| |||||||||||||||||||||||||||||
| 202 | 10 | my @touched = do { local $build->{silent} = 1; $build->touch }; | |||||||||||||||||||||||||||
| 203 | 10 | ▶ | $self->_say(sprintf 'xs_cover: removed %d counter file%s and touched %d source%s, so the next make rebuilds without coverage', | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 204 | scalar @gone, @gone == 1 ? '' : 's', scalar @touched, @touched == 1 ? '' : 's'); | ||||||||||||||||||||||||||||
| 205 | 10 | return scalar @gone; | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 15 | ▶ | sub report_name { $_[0]{report} } | ||||||||||||||||||||||||||
|
Subroutine
report_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 36 | ▶ | sub _say { | ||||||||||||||||||||||||||
|
Subroutine
_say: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 211 | 36 | my ($self, $line) = @_; | |||||||||||||||||||||||||||
| 212 | 36 | ▶ | print "$line\n" unless $self->{silent}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 18 | 1; | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | __END__ | ||||||||||||||||||||||||||||