| 1 | package Perl::Tests::Covering; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $Perl::Tests::Covering::VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Which tests run the file you just changed, from coverage kept on disk. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use re '/aa'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Config (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Cwd (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Cpanel::JSON::XS (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Devel::Cover::DB (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Devel::Cover::DB::IO (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Digest::MD5 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Digest::SHA (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use File::Find (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use File::Path (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use File::Slurper (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use File::Slurper::Temp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use File::Temp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use IO::Compress::Gzip (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use IO::Uncompress::Gunzip (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use List::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | use PPI (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | use TAP::Parser::SourceHandler::Perl (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | use Text::ParseWords (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use parent qw{Exporter}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | our @EXPORT_OK = qw{NO_TESTS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # What a map returns to say that a path reaches no test: the empty string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # which no path is. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | use constant NO_TESTS => q{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # Change it when what the cache holds changes shape. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | Readonly::Scalar my $CACHE_FORMAT => 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | Readonly::Scalar my $CACHE_NAME => 'perl-tests-covering'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # What this module names the files in its cache directory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | Readonly::Scalar my $CACHE_FILE_RX => qr/\A[0-9a-f]{40}[.]json[.]gz\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # The files that say a directory is the root of a distribution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | Readonly::Array my @DIST_MARKERS => qw{dist.ini Makefile.PL Build.PL cpanfile META.json .git}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # The map a distribution has when it names none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | Readonly::Scalar my $DEFAULT_MAP => '.tests-covering-map.pl'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # What exec returns with in a child that could not become the test. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | Readonly::Scalar my $EXEC_FAILED => 127; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # The directory this module was loaded from, so that a run can load the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # recorder from the same place. Taken now, because __FILE__ may be relative to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # the directory we started in. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | Readonly::Scalar my $OWN_LIB => File::Spec->rel2abs(__FILE__) =~ s{[/\\]Perl[/\\]Tests[/\\]Covering[.]pm\z}{}r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my ( $class, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my %known = map { $_ => 1 } qw{root tests lib jobs cache_dir map unexplained}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my @unknown = grep { !$known{$_} } sort keys %opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | Carp::croak("Unknown option(s) to $class->new: @unknown") if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | my $root = defined $opts{root} ? Cwd::abs_path( $opts{root} ) : _find_root( Cwd::getcwd() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | Carp::croak( 'No root: ' . ( $opts{root} // 'no distribution above ' . Cwd::getcwd() ) ) if !defined $root || !-d $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
defined $root and -d $root
$opts{"root"} // 'no distribution above ' . Cwd::getcwd()
MC/DC0%0/2
defined $root and -d $root
defined $root
-d $root
MC/DC0%0/1
$opts{"root"} // 'no distribution above ' . Cwd::getcwd()
$opts{"root"}
Truth table0%0/3
A and B
A= defined $rootB= -d $root
Truth table0%0/2
A
A= $opts{"root"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | foreach my $list (qw{tests lib}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | Carp::croak("$list must be a list of directories, not '$opts{$list}'") if defined $opts{$list} && ref $opts{$list} ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $opts{$list} and ref $opts{$list} ne "ARRAY"
MC/DC0%0/2
defined $opts{$list} and ref $opts{$list} ne "ARRAY"
defined $opts{$list}
ref $opts{$list} ne "ARRAY"
Truth table0%0/3
A and B
A= defined $opts{$list}B= ref $opts{$list} ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my $jobs = $opts{jobs} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"jobs"} // 1
MC/DC0%0/1
$opts{"jobs"} // 1
$opts{"jobs"}
Truth table0%0/2
A
A= $opts{"jobs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | Carp::croak("jobs must be a whole number of 1 or more, not '$jobs'") if $jobs !~ m/\A[1-9][0-9]*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | my $unexplained = $opts{unexplained} // 'none'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"unexplained"} // "none"
MC/DC0%0/1
$opts{"unexplained"} // "none"
$opts{"unexplained"}
Truth table0%0/2
A
A= $opts{"unexplained"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | Carp::croak("unexplained must be none or all, not '$unexplained'") if $unexplained !~ m/\A(?:none|all)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | root => $root, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | tests => [ @{ $opts{tests} // ['t'] } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"tests"} // ["t"]
MC/DC0%0/1
$opts{"tests"} // ["t"]
$opts{"tests"}
Truth table0%0/2
A
A= $opts{"tests"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | lib => [ @{ $opts{lib} // ['lib'] } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$opts{"lib"} // ["lib"]
$opts{"cache_dir"} // _default_cache_dir()
MC/DC0%0/1
$opts{"lib"} // ["lib"]
$opts{"lib"}
MC/DC0%0/2
$opts{"cache_dir"} // _default_cache_dir()
$opts{"cache_dir"}
_default_cache_dir()
Truth table0%0/2
A
A= $opts{"lib"}
Truth table0%0/3
A // B
A= $opts{"cache_dir"}B= _default_cache_dir()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | jobs => $jobs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | cache_dir => $opts{cache_dir} // _default_cache_dir(), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | unexplained => $unexplained, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | blob => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $default_map = File::Spec->catfile( $root, $DEFAULT_MAP ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $self->{map} = $self->_load_map( exists $opts{map} ? $opts{map} : -e $default_map ? $default_map : undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub root { return $_[0]{root} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
root: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub tests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tests: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my @tests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | foreach my $dir ( grep { -d } map { File::Spec->catdir( $self->{root}, $_ ) } @{ $self->{tests} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | File::Find::find( { no_chdir => 1, wanted => sub { push @tests, $File::Find::name if m/[.]t\z/ && -e && !-d } }, $dir ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
Condition0%0/6
/[.]t\z/aa and -e $_ and not -d $_
/[.]t\z/aa and -e $_
MC/DC0%0/3
/[.]t\z/aa and -e $_ and not -d $_
/[.]t\z/aa
-e $_
not -d $_
Truth table0%0/4
A and B and not(C)
A= /[.]t\z/aaB= -e $_C= not -d $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | return sort map { File::Spec->abs2rel( $_, $self->{root} ) } @tests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub refresh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # A file edited between two refreshes has a new blob. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $self->{blob} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $cache = $self->_read_cache(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $before = $cache->{tests}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my ( %after, @stale ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | foreach my $test ( $self->tests() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if ( $self->_record_holds( $before->{$test}, {} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $after{$test} = $before->{$test}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | push @stale, $test; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $ran = $self->_run_tests(@stale); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $versions = $cache->{versions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | foreach my $test ( keys %$ran ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my $new = delete $ran->{$test}{versions} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $ran->{$test}{"versions"} // {}
MC/DC0%0/1
delete $ran->{$test}{"versions"} // {}
delete $ran->{$test}{"versions"}
Truth table0%0/2
A
A= delete $ran->{$test}{"versions"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | @{$versions}{ keys %$new } = values %$new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $after{$test} = $ran->{$test}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | my $changed = $cache->{borrowed} || @stale || grep { !$after{$_} } keys %$before; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$cache->{'borrowed'} || @stale || grep({not $after{$_};} keys %$before)
$cache->{"borrowed"} or @stale
MC/DC0%0/3
$cache->{'borrowed'} || @stale || grep({not $after{$_};} keys %$before)
$cache->{"borrowed"}
@stale
grep({not $after{$_};} keys %$before)
Truth table0%0/4
A or B || C
A= $cache->{"borrowed"}B= @staleC= grep({not $after{$_};} keys %$before)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | $self->_write_cache( \%after, $versions ) if $changed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $self->{before} = $before; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $self->{after} = \%after; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $self->{versions} = $versions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return @stale; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub tests_covering { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tests_covering: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my ( $self, @files ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my @wanted = grep { defined } map { $self->_relative( $_, Cwd::getcwd() ) } @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $self->refresh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my @records = ( $self->{before}, $self->{after} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my %covering = map { $_ => 1 } map { _loaders( $_, @records ) } @wanted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $covering{$_} = 1 for $self->_unexplained_tests( \@wanted, \@records, {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # A test that is gone covers nothing it could be run for. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return sort grep { $self->{after}{$_} } keys %covering; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub tests_covering_diff { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tests_covering_diff: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my ( $self, $diff ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $self->{blob} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $cache = $self->_read_cache(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $cwd = Cwd::getcwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my @changes = map { $self->_resolve_change( $_, $cwd ) } _parse_diff($diff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my %in_diff = map { $_ => 1 } grep { defined } map { @{$_}{qw{old new}} } @changes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my %chosen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | foreach my $test ( $self->tests() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $record = $cache->{tests}{$test}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | $chosen{$test} = 1 if $in_diff{$test} || !$self->_record_holds( $record, \%in_diff ) || grep { $self->_change_reaches( $_, $record, $cache->{versions} ) } @changes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$in_diff{$test} or not $self->_record_holds($record, \%in_diff) or grep {$self->_change_reaches($_, $record, $cache->{"versions"});} @changes
$in_diff{$test} or not $self->_record_holds($record, \%in_diff)
MC/DC0%0/3
$in_diff{$test} or not $self->_record_holds($record, \%in_diff) or grep {$self->_change_reaches($_, $record, $cache->{"versions"});} @changes
$in_diff{$test}
not $self->_record_holds($record, \%in_diff)
grep {$self->_change_reaches($_, $record, $cache->{"versions"});} @changes
Truth table0%0/4
A or not(B) or C
A= $in_diff{$test}B= not $self->_record_holds($record, \%in_diff)C= grep {$self->_change_reaches($_, $record, $cache->{"versions"});} @changes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # A Perl file that is new in the diff is usually reached through the files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # that use it, which are in the diff too, so the map's silence explains it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my ( %change_of, %quiet ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | foreach my $change (@changes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $change_of{$_} //= $change for grep { defined } @{$change}{qw{old new}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$change_of{$_} //= $change
MC/DC0%0/2
$change_of{$_} //= $change
$change_of{$_}
$change
Truth table0%0/3
A //= B
A= $change_of{$_}B= $change
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | $quiet{ $change->{new} } = 1 if !defined $change->{old} && defined $change->{new} && $self->_is_perl( $change->{new} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not defined $change->{"old"} and defined $change->{"new"} and $self->_is_perl($change->{"new"})
not defined $change->{"old"} and defined $change->{"new"}
MC/DC0%0/3
not defined $change->{"old"} and defined $change->{"new"} and $self->_is_perl($change->{"new"})
not defined $change->{"old"}
defined $change->{"new"}
$self->_is_perl($change->{"new"})
Truth table0%0/4
not(A) and B and C
A= not defined $change->{"old"}B= defined $change->{"new"}C= $self->_is_perl($change->{"new"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $chosen{$_} = 1 for $self->_unexplained_tests( [ sort keys %change_of ], [ $cache->{tests} ], \%change_of, \%quiet ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return sort keys %chosen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub tests_covering_sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tests_covering_sub: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my ( $self, $file, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | Carp::croak('tests_covering_sub needs a file and the name of a sub') if !defined $file || !defined $name || !length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $file and defined $name and length $name
defined $file and defined $name
MC/DC0%0/3
defined $file and defined $name and length $name
defined $file
defined $name
length $name
Truth table0%0/4
A and B and C
A= defined $fileB= defined $nameC= length $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $rel = $self->_relative( $file, Cwd::getcwd() ) // Carp::croak("$file is not under ${\ $self->root() }"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_relative($file, Cwd::getcwd()) // Carp::croak("$file is not under ${\$self->root;}")
MC/DC0%0/1
$self->_relative($file, Cwd::getcwd()) // Carp::croak("$file is not under ${\$self->root;}")
$self->_relative($file, Cwd::getcwd())
Truth table0%0/2
A
A= $self->_relative($file, Cwd::getcwd())
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $self->refresh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my $content = eval { File::Slurper::read_binary( File::Spec->catfile( $self->{root}, $rel ) ) } // Carp::croak("Cannot read $file: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
eval {
do {
File::Slurper::read_binary("File::Spec"->catfile($self->{"root"}, $rel))
}
} // Carp::croak("Cannot read ${file}: $@")
MC/DC0%0/1
eval {
do {
File::Slurper::read_binary("File::Spec"->catfile($self->{"root"}, $rel))
}
} // Carp::croak("Cannot read ${file}: $@")
eval {
do {
File::Slurper::read_binary("File::Spec"->catfile($self->{"root"}, $rel))
}
}
Truth table0%0/2
A
A= eval {
do {
File::Slurper::read_binary("File::Spec"->catfile($self->{"root"}, $rel))
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my @starts = _sub_lines( $content, $name =~ s/\A.*:://r ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | Carp::croak("No sub $name in $file") if !@starts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $blob = _git_blob($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | return sort grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $record = $self->{after}{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | defined $record->{loaded}{$rel} && _touches( $self->{versions}{$blob}, $record->{executed}{$rel}, \@starts, [] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $record->{'loaded'}{$rel} && _touches($self->{'versions'}{$blob}, $record->{'executed'}{$rel}, \@starts, scalar [])
MC/DC0%0/2
defined $record->{'loaded'}{$rel} && _touches($self->{'versions'}{$blob}, $record->{'executed'}{$rel}, \@starts, scalar [])
defined $record->{'loaded'}{$rel}
_touches($self->{'versions'}{$blob}, $record->{'executed'}{$rel}, \@starts, scalar [])
Truth table0%0/3
A && B
A= defined $record->{'loaded'}{$rel}B= _touches($self->{'versions'}{$blob}, $record->{'executed'}{$rel}, \@starts, scalar [])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | } keys %{ $self->{after} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub files_covered_by { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
files_covered_by: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my ( $self, $test ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | Carp::croak('files_covered_by needs a test') if !defined $test; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | my $rel = $self->_relative( $test, Cwd::getcwd() ) // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_relative($test, Cwd::getcwd()) // (return)
MC/DC0%0/1
$self->_relative($test, Cwd::getcwd()) // (return)
$self->_relative($test, Cwd::getcwd())
Truth table0%0/2
A
A= $self->_relative($test, Cwd::getcwd())
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->refresh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | return sort keys %{ $self->{after}{$rel}{loaded} // {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"after"}{$rel}{"loaded"} // {}
MC/DC0%0/1
$self->{"after"}{$rel}{"loaded"} // {}
$self->{"after"}{$rel}{"loaded"}
Truth table0%0/2
A
A= $self->{"after"}{$rel}{"loaded"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # The tests whose record, in any of @records, names $file as loaded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | sub _loaders { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_loaders: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my ( $file, @records ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my $records = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | grep { exists $records->{$_}{loaded}{$file} } keys %$records | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } @records; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # The tests that the map, and then the unexplained option, choose for the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # paths in @$paths that no test is and no record in @$records names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # $change_of holds the change from a diff for each path that has one. A path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # in %$quiet is explained when the map has nothing to say about it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub _unexplained_tests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unexplained_tests: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my ( $self, $paths, $records, $change_of, $quiet ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my %tests = map { $_ => 1 } $self->tests(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my ( %chosen, $unexplained ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | foreach my $path ( grep { !$tests{$_} && !_loaders( $_, @$records ) } List::Util::uniq(@$paths) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$tests{$_} || _loaders($_, @$records)
MC/DC0%0/2
$tests{$_} || _loaders($_, @$records)
$tests{$_}
_loaders($_, @$records)
Truth table0%0/3
A || B
A= $tests{$_}B= _loaders($_, @$records)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $answer = $self->_ask_map( $path, $change_of->{$path}, \%tests ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my @reached = ( @{ $answer->{tests} }, map { _loaders( $_, @$records ) } @{ $answer->{stand_ins} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $chosen{$_} = 1 for @reached; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | $unexplained ||= !( @reached || $answer->{none} || ( $quiet->{$path} && !$answer->{said} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
$unexplained ||= !(@reached || $answer->{"none"} || $quiet->{$path} && !$answer->{"said"})
@reached || $answer->{'none'} || $quiet->{$path} && !$answer->{'said'}
@reached or $answer->{"none"}
$quiet->{$path} and not $answer->{"said"}
MC/DC0%0/5
$unexplained ||= !(@reached || $answer->{"none"} || $quiet->{$path} && !$answer->{"said"})
$unexplained
@reached
$answer->{"none"}
$quiet->{$path}
not $answer->{"said"}
Truth table0%0/6
A ||= not(B or C || D and not(E))
A= $unexplainedB= @reachedC= $answer->{"none"}D= $quiet->{$path}E= not $answer->{"said"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | return sort keys %tests if $unexplained && $self->{unexplained} eq 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$unexplained and $self->{"unexplained"} eq "all"
MC/DC0%0/2
$unexplained and $self->{"unexplained"} eq "all"
$unexplained
$self->{"unexplained"} eq "all"
Truth table0%0/3
A and B
A= $unexplainedB= $self->{"unexplained"} eq "all"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | return grep { $tests{$_} } sort keys %chosen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # What the map says about one path, as a hash: tests and stand_ins, relative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # to the root; none, when it said NO_TESTS; and said, when it returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # anything at all. A path that is neither a test nor a file under the root is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # dropped with a warning, so a mistake in the map leaves the path unexplained | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # rather than explained by nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub _ask_map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ask_map: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my ( $self, $path, $change, $tests ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my %answer = ( tests => [], stand_ins => [], none => 0, said => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | my $map = $self->{map} or return \%answer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | my @said = $self->_in_root( sub { $map->( $path, $change ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $answer{said} = @said; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | foreach my $said (@said) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if ( defined $said && $said eq NO_TESTS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $said and $said eq ""
MC/DC0%0/2
defined $said and $said eq ""
defined $said
$said eq ""
Truth table0%0/3
A and B
A= defined $saidB= $said eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $answer{none} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | my $rel = defined $said ? $self->_relative( $said, $self->{root} ) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ( defined $rel && $tests->{$rel} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $rel and $tests->{$rel}
MC/DC0%0/2
defined $rel and $tests->{$rel}
defined $rel
$tests->{$rel}
Truth table0%0/3
A and B
A= defined $relB= $tests->{$rel}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | push @{ $answer{tests} }, $rel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ▶ | elsif ( defined $rel && -e File::Spec->catfile( $self->{root}, $rel ) && !-d _ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
defined $rel and -e "File::Spec"->catfile($self->{"root"}, $rel) and not -d _
defined $rel and -e "File::Spec"->catfile($self->{"root"}, $rel)
MC/DC0%0/3
defined $rel and -e "File::Spec"->catfile($self->{"root"}, $rel) and not -d _
defined $rel
-e "File::Spec"->catfile($self->{"root"}, $rel)
not -d _
Truth table0%0/4
A and B and not(C)
A= defined $relB= -e "File::Spec"->catfile($self->{"root"}, $rel)C= not -d _
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | push @{ $answer{stand_ins} }, $rel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | warn "tests-covering: the map said '${\( $said // 'undef' )}' for $path, which is neither a test nor a file under the root\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$said // "undef"
MC/DC0%0/1
$said // "undef"
$said
Truth table0%0/2
A
A= $said
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | return \%answer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # The code reference a map option names, or undef for none. A file is run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # as _in_root runs the map, so it can load the distribution's own modules. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | sub _load_map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_map: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my ( $self, $map ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | return if !defined $map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | return $map if ref $map eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | Carp::croak( 'map must be a code reference or the name of a file, not a ' . ref $map ) if ref $map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $path = File::Spec->rel2abs($map); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | my ($code) = $self->_in_root( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | local ( $@, $! ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $got = do $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | Carp::croak("Cannot compile the map $map: $@") if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | Carp::croak("Cannot read the map $map: ${\( $! || 'no such file' )}") if !defined $got && ( $! || !-e $path ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
not defined $got and $! || !(-e $path)
$! or not -e $path
$! || 'no such file'
MC/DC0%0/3
not defined $got and $! || !(-e $path)
not defined $got
$!
not -e $path
MC/DC0%0/1
$! || 'no such file'
$!
Truth table0%0/4
not(A) and B or not(C)
A= not defined $gotB= $!C= not -e $path
Truth table0%0/2
A
A= $!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | return $got; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | Carp::croak("The map $map returns ${\( ref $code || 'something' )}, not a code reference") if ref $code ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
ref $code || 'something'
MC/DC0%0/1
ref $code || 'something'
ref $code
Truth table0%0/2
A
A= ref $code
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | return $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # Runs $code with the root as the working directory and the library | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # directories at the front of @INC, and returns what it returns in list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | # context. A die in $code dies here, after the working directory is back. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | sub _in_root { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_in_root: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my ( $self, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $was = Cwd::getcwd(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | chdir $self->{root} or Carp::croak("Cannot chdir to $self->{root}: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | local @INC = ( ( map { File::Spec->rel2abs( $_, $self->{root} ) } @{ $self->{lib} } ), @INC ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my @got = eval { $code->() }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | chdir $was or Carp::croak("Cannot chdir back to $was: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | die $err if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | return @got; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # Whether a file relative to the root is Perl: by its name, or by a #! line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # that names perl. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | sub _is_perl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_perl: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my ( $self, $rel ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | return 1 if $rel =~ m/[.](?:pm|pl|PL|t)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | return ( _first_line( File::Spec->catfile( $self->{root}, $rel ) ) // q{} ) =~ m/\A#!.*\bperl/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_first_line("File::Spec"->catfile($self->{"root"}, $rel)) // ""
MC/DC0%0/1
_first_line("File::Spec"->catfile($self->{"root"}, $rel)) // ""
_first_line("File::Spec"->catfile($self->{"root"}, $rel))
Truth table0%0/2
A
A= _first_line("File::Spec"->catfile($self->{"root"}, $rel))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # The nearest directory, from $dir upwards, that holds a distribution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub _find_root { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_root: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my ($dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my ( $volume, $directories ) = File::Spec->splitpath( $dir, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my @dirs = File::Spec->splitdir($directories); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | while (@dirs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $candidate = File::Spec->catpath( $volume, File::Spec->catdir(@dirs), q{} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | return Cwd::abs_path($candidate) if grep { -e File::Spec->catfile( $candidate, $_ ) } @DIST_MARKERS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | pop @dirs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | sub _default_cache_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_cache_dir: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | my $base = $ENV{XDG_CACHE_HOME} || ( $ENV{HOME} && File::Spec->catdir( $ENV{HOME}, '.cache' ) ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$ENV{'XDG_CACHE_HOME'} || $ENV{'HOME'} && 'File::Spec'->catdir($ENV{'HOME'}, '.cache')
$ENV{"HOME"} and "File::Spec"->catdir($ENV{"HOME"}, ".cache")
MC/DC0%0/3
$ENV{'XDG_CACHE_HOME'} || $ENV{'HOME'} && 'File::Spec'->catdir($ENV{'HOME'}, '.cache')
$ENV{'XDG_CACHE_HOME'}
$ENV{"HOME"}
"File::Spec"->catdir($ENV{"HOME"}, ".cache")
Truth table0%0/4
A || B and C
A= $ENV{'XDG_CACHE_HOME'}B= $ENV{"HOME"}C= "File::Spec"->catdir($ENV{"HOME"}, ".cache")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | return File::Spec->catdir( $base, $CACHE_NAME ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # $file relative to the root, or undef when it is not under the root. A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # relative $file is relative to $base. Only the directory has to exist, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # that a file which was deleted still has a name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | sub _relative { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_relative: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my ( $self, $file, $base ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $abs = File::Spec->rel2abs( $file, $base ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my ( $volume, $dirs, $name ) = File::Spec->splitpath($abs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | my $dir = Cwd::abs_path( File::Spec->catpath( $volume, $dirs, q{} ) ) // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
Cwd::abs_path("File::Spec"->catpath($volume, $dirs, "")) // (return)
MC/DC0%0/1
Cwd::abs_path("File::Spec"->catpath($volume, $dirs, "")) // (return)
Cwd::abs_path("File::Spec"->catpath($volume, $dirs, ""))
Truth table0%0/2
A
A= Cwd::abs_path("File::Spec"->catpath($volume, $dirs, ""))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $rel = File::Spec->abs2rel( File::Spec->catfile( $dir, $name ), $self->{root} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | return if File::Spec->file_name_is_absolute($rel) || ( File::Spec->splitdir($rel) )[0] eq File::Spec->updir(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
"File::Spec"->file_name_is_absolute($rel) or ("File::Spec"->splitdir($rel))[0] eq "File::Spec"->updir
MC/DC0%0/2
"File::Spec"->file_name_is_absolute($rel) or ("File::Spec"->splitdir($rel))[0] eq "File::Spec"->updir
"File::Spec"->file_name_is_absolute($rel)
("File::Spec"->splitdir($rel))[0] eq "File::Spec"->updir
Truth table0%0/3
A or B
A= "File::Spec"->file_name_is_absolute($rel)B= ("File::Spec"->splitdir($rel))[0] eq "File::Spec"->updir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | return $rel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # The git blob id of a file relative to the root, or undef when it cannot be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # read. Kept until the next refresh or diff. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | sub _blob { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_blob: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my ( $self, $rel ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | return $self->{blob}{$rel} if exists $self->{blob}{$rel}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | return $self->{blob}{$rel} = _git_blob( _read( File::Spec->catfile( $self->{root}, $rel ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # The id git gives a file with this content, which is also what a diff from git | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # names it by. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | sub _git_blob { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_git_blob: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my ($content) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | return if !defined $content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | return Digest::SHA::sha1_hex( 'blob ' . length($content) . "\0" . $content ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # The bytes of a file, or undef when it is not a file that can be read. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | sub _read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my ($path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | return if !-e $path || -d _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not -e $path or -d _
MC/DC0%0/2
not -e $path or -d _
not -e $path
-d _
Truth table0%0/3
not(A) or B
A= not -e $pathB= -d _
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return eval { File::Slurper::read_binary($path) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # Whether a record can be used at all, and whether each file it names, other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # than those in %$except, is as it was when the record was made. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | sub _record_holds { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_record_holds: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my ( $self, $record, $except ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | return if ref $record ne 'HASH' || ref $record->{loaded} ne 'HASH' || !%{ $record->{loaded} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $record ne "HASH" or ref $record->{"loaded"} ne "HASH" or not %{$record->{"loaded"};}
ref $record ne "HASH" or ref $record->{"loaded"} ne "HASH"
MC/DC0%0/3
ref $record ne "HASH" or ref $record->{"loaded"} ne "HASH" or not %{$record->{"loaded"};}
ref $record ne "HASH"
ref $record->{"loaded"} ne "HASH"
not %{$record->{"loaded"};}
Truth table0%0/4
A or B or not(C)
A= ref $record ne "HASH"B= ref $record->{"loaded"} ne "HASH"C= not %{$record->{"loaded"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | foreach my $file ( grep { !$except->{$_} } keys %{ $record->{loaded} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | my $now = $self->_blob($file) // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_blob($file) // (return)
MC/DC0%0/1
$self->_blob($file) // (return)
$self->_blob($file)
Truth table0%0/2
A
A= $self->_blob($file)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | return if $now ne $record->{loaded}{$file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # Runs each test under coverage, $self->{jobs} at a time, and returns a record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # for each, keyed by test. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | sub _run_tests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_tests: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my ( $self, @queue ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my ( %running, %records ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | while ( @queue || %running ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@queue or %running
MC/DC0%0/2
@queue or %running
@queue
%running
Truth table0%0/3
A or B
A= @queueB= %running
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | while ( @queue && keys %running < $self->{jobs} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@queue and keys %running < $self->{"jobs"}
MC/DC0%0/2
@queue and keys %running < $self->{"jobs"}
@queue
keys %running < $self->{"jobs"}
Truth table0%0/3
A and B
A= @queueB= keys %running < $self->{"jobs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my $test = shift @queue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my $tmp = File::Temp->newdir(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $running{ $self->_spawn( $test, $tmp->dirname() ) } = [ $test, $tmp ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $pid = waitpid -1, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | last if $pid < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # Some other child of whoever called us. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | my $job = delete $running{$pid} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | $records{ $job->[0] } = $self->_record( $job->[0], $job->[1]->dirname() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return \%records; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # Starts one test under coverage, silently, and returns its pid. Devel::Cover | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # writes to cover_db under $tmp, and the recorder to loaded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | sub _spawn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_spawn: not called CC=9 SCAR=43.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my ( $self, $test, $tmp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my $loaded = File::Spec->catdir( $tmp, 'loaded' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | mkdir $loaded or Carp::croak("Cannot make $loaded: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my @lib = ( ( map { File::Spec->rel2abs( $_, $self->{root} ) } @{ $self->{lib} } ), _split_path( $ENV{PERL5LIB} ), $OWN_LIB ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my @opt = ( $self->_cover_switch( File::Spec->catdir( $tmp, 'cover_db' ) ), '-MPerl::Tests::Covering::Recorder' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my @perl = ( $^X, $self->_taint_switches( $test, \@lib, \@opt ), $test ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | my $pid = fork // Carp::croak("Cannot fork to run $test: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
fork // Carp::croak("Cannot fork to run ${test}: $!")
MC/DC0%0/1
fork // Carp::croak("Cannot fork to run ${test}: $!")
fork
Truth table0%0/2
A
A= fork
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | return $pid if $pid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | # From here on, this is the child, and it must not return into the caller's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # code: every way out is exec or _exit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $null = File::Spec->devnull(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | chdir $self->{root} or POSIX::_exit($EXEC_FAILED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | open STDIN, '<', $null or POSIX::_exit($EXEC_FAILED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | open STDOUT, '>', $null or POSIX::_exit($EXEC_FAILED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | open STDERR, '>&', \*STDOUT or POSIX::_exit($EXEC_FAILED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # A perl that a tainted test starts is not tainted, and reads these. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | $ENV{PERL5LIB} = join $Config::Config{path_sep}, @lib; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | $ENV{PERL5OPT} = join q{ }, @opt, grep { defined && length } $ENV{PERL5OPT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table0%0/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $ENV{PERL_TESTS_COVERING_LOADED} = $loaded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $ENV{HARNESS_ACTIVE} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | # A list exec of perl itself, with no shell in between. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | { no warnings 'exec'; exec {$^X} @perl } ## no critic (ProhibitShellDispatch) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | POSIX::_exit($EXEC_FAILED); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | # The switches that go before the test on perl's command line: none, unless its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # #! line asks for taint. Then they are the taint switch, and PERL5LIB and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | # PERL5OPT as switches, which is what prove does. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | sub _taint_switches { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_taint_switches: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my ( $self, $test, $lib, $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | my $taint = TAP::Parser::SourceHandler::Perl->get_taint( _first_line( File::Spec->catfile( $self->{root}, $test ) ) ) // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
"TAP::Parser::SourceHandler::Perl"->get_taint(_first_line("File::Spec"->catfile($self->{"root"}, $test))) // (return)
MC/DC0%0/1
"TAP::Parser::SourceHandler::Perl"->get_taint(_first_line("File::Spec"->catfile($self->{"root"}, $test))) // (return)
"TAP::Parser::SourceHandler::Perl"->get_taint(_first_line("File::Spec"->catfile($self->{"root"}, $test)))
Truth table0%0/2
A
A= "TAP::Parser::SourceHandler::Perl"->get_taint(_first_line("File::Spec"->catfile($self->{"root"}, $test)))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | return ( "-$taint", ( map { "-I$_" } @$lib ), @$opt, Text::ParseWords::shellwords( $ENV{PERL5OPT} // q{} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{"PERL5OPT"} // ""
MC/DC0%0/1
$ENV{"PERL5OPT"} // ""
$ENV{"PERL5OPT"}
Truth table0%0/2
A
A= $ENV{"PERL5OPT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # The first line of a file, or undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | sub _first_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_first_line: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my ($path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | open my $fh, '<', $path or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my $line = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # The directories in a PATH-like list, without the empty ones. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | sub _split_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_path: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my ($list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | return grep { length } split m/\Q$Config::Config{path_sep}\E/, $list // q{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$list // ""
MC/DC0%0/1
$list // ""
$list
Truth table0%0/2
A
A= $list
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # The -MDevel::Cover switch for one run. Devel::Cover splits its options on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # commas, and perl splits PERL5OPT on whitespace, so either in the root is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | # written as a \x escape, which the pattern still matches. A relative name is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # relative to the root, where the run starts, and is sorted out from the rest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # in _files_in_run. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | sub _cover_switch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cover_switch: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | my ( $self, $db ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ( my $root = quotemeta $self->{root} ) =~ s/\\([,\s])/sprintf '\\x%02x', ord $1/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | Carp::croak("Cannot put a temporary directory with a comma or a space in it in PERL5OPT: $db") if $db =~ m/[,\s]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | return "-MDevel::Cover=-db,$db,-silent,1,-coverage,statement,-select,^(?!/)|^$root/"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # The record of one run: the blob of every file of the distribution that the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # test loaded, by what Devel::Cover and the recorder say, and of the test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # itself; the lines of each that ran; and under versions, the layout of each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # file as it was, keyed by blob. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | sub _record { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_record: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | my ( $self, $test, $tmp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my $covered = $self->_files_covered( File::Spec->catdir( $tmp, 'cover_db' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | my %loaded = map { $_ => 1 } $test, keys %$covered, $self->_files_recorded( File::Spec->catdir( $tmp, 'loaded' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my %record = ( loaded => {}, executed => {}, versions => {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | foreach my $rel ( keys %loaded ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | my $content = _read( File::Spec->catfile( $self->{root}, $rel ) ) // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_read("File::Spec"->catfile($self->{"root"}, $rel)) // (next)
MC/DC0%0/1
_read("File::Spec"->catfile($self->{"root"}, $rel)) // (next)
_read("File::Spec"->catfile($self->{"root"}, $rel))
Truth table0%0/2
A
A= _read("File::Spec"->catfile($self->{"root"}, $rel))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | my $blob = $record{loaded}{$rel} = _git_blob($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # Lines are only good for the content they were counted in, and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # file may have changed while the test ran. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | my $run = $covered->{$rel}{ Digest::MD5::md5_hex($content) } or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | my $layout = _layout($content) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $record{executed}{$rel} = [ sort { $a <=> $b } keys %{ $run->{executed} } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $record{versions}{$blob} = { %$layout, statements => $run->{statements} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | return \%record; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # The files of the distribution that Devel::Cover saw in each run of one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # database, keyed by file and then by Devel::Cover's digest of the content: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # the lines that hold a statement, and those of them that ran. It reads the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # counts of each run as loaded, because the public runs() goes through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # cover(), which also needs the working directory the run had. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | sub _files_covered { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_files_covered: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my ( $self, $db ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my %files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | foreach my $dir ( _entries( File::Spec->catdir( $db, 'runs' ) ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | my $runs = eval { Devel::Cover::DB->new( db => $dir ) } or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | foreach my $run ( grep { ref eq 'HASH' } values %{ $runs->{runs} // {} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$runs->{"runs"} // {}
MC/DC0%0/1
$runs->{"runs"} // {}
$runs->{"runs"}
Truth table0%0/2
A
A= $runs->{"runs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | my $cwd = $run->{dir} // $self->{root}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$run->{"dir"} // $self->{"root"}
MC/DC0%0/2
$run->{"dir"} // $self->{"root"}
$run->{"dir"}
$self->{"root"}
Truth table0%0/3
A // B
A= $run->{"dir"}B= $self->{"root"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | foreach my $name ( keys %{ $run->{count} // {} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$run->{"count"} // {}
MC/DC0%0/1
$run->{"count"} // {}
$run->{"count"}
Truth table0%0/2
A
A= $run->{"count"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | my $rel = $self->_distribution_file( $name, $cwd ) // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_distribution_file($name, $cwd) // (next)
MC/DC0%0/1
$self->_distribution_file($name, $cwd) // (next)
$self->_distribution_file($name, $cwd)
Truth table0%0/2
A
A= $self->_distribution_file($name, $cwd)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | my $digest = $run->{digests}{$name} // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$run->{"digests"}{$name} // (next)
MC/DC0%0/1
$run->{"digests"}{$name} // (next)
$run->{"digests"}{$name}
Truth table0%0/2
A
A= $run->{"digests"}{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | my $lines = _statement_lines( $db, $digest ) // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_statement_lines($db, $digest) // (next)
MC/DC0%0/1
_statement_lines($db, $digest) // (next)
_statement_lines($db, $digest)
Truth table0%0/2
A
A= _statement_lines($db, $digest)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | my $counts = $run->{count}{$name}{statement} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$run->{"count"}{$name}{"statement"} // []
MC/DC0%0/1
$run->{"count"}{$name}{"statement"} // []
$run->{"count"}{$name}{"statement"}
Truth table0%0/2
A
A= $run->{"count"}{$name}{"statement"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | my $file = $files{$rel}{$digest} //= { statements => [ List::Util::uniqnum( sort { $a <=> $b } grep { defined } @$lines ) ], executed => {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$files{$rel}{$digest} //= {"statements", [&List::Util::uniqnum((sort {$a <=> $b;} grep({defined $_;} @$lines)))], "executed", {}}
MC/DC0%0/1
$files{$rel}{$digest} //= {"statements", [&List::Util::uniqnum((sort {$a <=> $b;} grep({defined $_;} @$lines)))], "executed", {}}
$files{$rel}{$digest}
Truth table0%0/2
A
A= $files{$rel}{$digest}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | $file->{executed}{ $lines->[$_] } = 1 for grep { $counts->[$_] && defined $lines->[$_] } 0 .. $#$counts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$counts->[$_] && defined $lines->[$_]
MC/DC0%0/2
$counts->[$_] && defined $lines->[$_]
$counts->[$_]
defined $lines->[$_]
Truth table0%0/3
A && B
A= $counts->[$_]B= defined $lines->[$_]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | return \%files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # The line of each statement in the file Devel::Cover knows by $digest, in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # order of its counts. Read from its structure file directly, because | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | # Devel::Cover::DB::Structure->read resolves the file against the working | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # directory and deletes the structure of a file that changed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | sub _statement_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_statement_lines: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my ( $db, $digest ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | my $structure = eval { Devel::Cover::DB::IO->new->read( File::Spec->catfile( $db, 'structure', $digest ) ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | return ref $structure eq 'HASH' && ref $structure->{statement} eq 'ARRAY' ? $structure->{statement} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $structure eq "HASH" and ref $structure->{"statement"} eq "ARRAY"
MC/DC0%0/2
ref $structure eq "HASH" and ref $structure->{"statement"} eq "ARRAY"
ref $structure eq "HASH"
ref $structure->{"statement"} eq "ARRAY"
Truth table0%0/3
A and B
A= ref $structure eq "HASH"B= ref $structure->{"statement"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # The files of the distribution in each list that the recorder wrote. A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # relative name in %INC is relative to wherever the require happened, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # the recorder cannot know, so it is taken as relative to the root, where the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # run started. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | sub _files_recorded { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_files_recorded: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my ( $self, $loaded ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | foreach my $list ( _entries($loaded) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | my @names = eval { File::Slurper::read_lines($list) } or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | push @files, grep { defined } map { $self->_distribution_file( $_, $self->{root} ) } @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | return @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # The paths in a directory, or none when it cannot be read. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | sub _entries { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_entries: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my ($dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | opendir my $dh, $dir or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my @entries = map { File::Spec->catfile( $dir, $_ ) } grep { !m/\A[.]/ } readdir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | return @entries; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # $name, which a run loaded from $cwd, relative to the root, or nothing when it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # is not a file of the distribution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | sub _distribution_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_distribution_file: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my ( $self, $name, $cwd ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | my $rel = $self->_relative( $name, $cwd ) // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_relative($name, $cwd) // (return)
MC/DC0%0/1
$self->_relative($name, $cwd) // (return)
$self->_relative($name, $cwd)
Truth table0%0/2
A
A= $self->_relative($name, $cwd)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # A test run after `make` loads the copy in blib. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | $rel =~ s{\Ablib/(?:lib|arch)/}{lib/} or $rel =~ s{\Ablib/script/}{bin/}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my $path = File::Spec->catfile( $self->{root}, $rel ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | return -e $path && !-d _ ? $rel : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $path and not -d _
MC/DC0%0/2
-e $path and not -d _
-e $path
not -d _
Truth table0%0/3
A and not(B)
A= -e $pathB= not -d _
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | # Each file a unified diff changes: its old and new paths as the diff names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | # them, or undef for /dev/null; the blob ids from its index line, which may be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | # abbreviated; and its blocks, which L</THE MAP> describes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | sub _parse_diff { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_diff: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my ($diff) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | # Where the parse is: the changes so far, and in the hunk being read, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | # next line on each side and how many are left. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | my %at = ( changes => [], old_left => 0, new_left => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | foreach my $line ( split m/\r?\n/, $diff // q{} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$diff // ""
MC/DC0%0/1
$diff // ""
$diff
Truth table0%0/2
A
A= $diff
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | if ( $at{old_left} || $at{new_left} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$at{"old_left"} or $at{"new_left"}
MC/DC0%0/2
$at{"old_left"} or $at{"new_left"}
$at{"old_left"}
$at{"new_left"}
Truth table0%0/3
A or B
A= $at{"old_left"}B= $at{"new_left"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | _hunk_line( \%at, $line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | _header_line( \%at, $line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | return @{ $at{changes} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | # One line of a hunk: removed, added, or the same on both sides. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | sub _hunk_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hunk_line: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my ( $at, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | my $mark = substr $line, 0, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | if ( $mark eq q{-} || $mark eq q{+} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mark eq "-" or $mark eq "+"
MC/DC0%0/2
$mark eq "-" or $mark eq "+"
$mark eq "-"
$mark eq "+"
Truth table0%0/3
A or B
A= $mark eq "-"B= $mark eq "+"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | $at->{block} //= _new_block( $at->{changes}[-1], $at->{old} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$at->{"block"} //= _new_block($at->{"changes"}[-1], $at->{"old"})
MC/DC0%0/2
$at->{"block"} //= _new_block($at->{"changes"}[-1], $at->{"old"})
$at->{"block"}
_new_block($at->{"changes"}[-1], $at->{"old"})
Truth table0%0/3
A //= B
A= $at->{"block"}B= _new_block($at->{"changes"}[-1], $at->{"old"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | my $side = $mark eq q{-} ? 'old' : 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | my $kind = $side eq 'old' ? 'deleted' : 'added'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | push @{ $at->{block}{$kind} }, $at->{$side}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | push @{ $at->{block}{"${kind}_text"} }, substr $line, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | $at->{"${side}_left"}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | return if $mark eq q{\\}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | undef $at->{block}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | $at->{$_}++ for qw{old new}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | $at->{"${_}_left"}-- for qw{old new}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | # One line outside a hunk. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | sub _header_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_header_line: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | my ( $at, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | my $changes = $at->{changes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | if ( $line =~ m/\Adiff --git (\S+) (\S+)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | push @$changes, { git => 1, old => _diff_path( $1, 1 ), new => _diff_path( $2, 1 ), blocks => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | if ( $line =~ m/\Adiff / || ( $line =~ m/\A--- / && ( !@$changes || @{ $changes->[-1]{blocks} } ) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$line =~ /\Adiff /aa or $line =~ /\A--- /aa and !@$changes || @{$changes->[-1]{"blocks"};}
$line =~ /\A--- /aa and !@$changes || @{$changes->[-1]{"blocks"};}
not @$changes or @{$changes->[-1]{"blocks"};}
MC/DC0%0/4
$line =~ /\Adiff /aa or $line =~ /\A--- /aa and !@$changes || @{$changes->[-1]{"blocks"};}
$line =~ /\Adiff /aa
$line =~ /\A--- /aa
not @$changes
@{$changes->[-1]{"blocks"};}
Truth table0%0/5
A or B and not(C) or D
A= $line =~ /\Adiff /aaB= $line =~ /\A--- /aaC= not @$changesD= @{$changes->[-1]{"blocks"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | push @$changes, { blocks => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | my $change = $changes->[-1] or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | if ( $line =~ m/\Aindex ([0-9a-f]+)[.][.]([0-9a-f]+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | @{$change}{qw{old_blob new_blob}} = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | elsif ( my ( $moved, $marked, $path ) = $line =~ m/\A(?:(?:rename|copy) (from|to)|(---|[+]{3})) (.+)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | my $side = ( $moved // $marked ) =~ m/\A(?:from|---)\z/ ? 'old' : 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$moved // $marked
MC/DC0%0/2
$moved // $marked
$moved
$marked
Truth table0%0/3
A // B
A= $movedB= $marked
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | $change->{$side} = _diff_path( $path, $marked && $change->{git} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$marked && $change->{'git'}
MC/DC0%0/2
$marked && $change->{'git'}
$marked
$change->{'git'}
Truth table0%0/3
A && B
A= $markedB= $change->{'git'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | elsif ( $line =~ m/\A\@\@ -(\d+)(?:,(\d+))? [+](\d+)(?:,(\d+))? \@\@/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | @{$at}{qw{old old_left new new_left}} = ( $1, $2 // 1, $3, $4 // 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$2 // 1
$4 // 1
MC/DC0%0/1
$2 // 1
$2
MC/DC0%0/1
$4 // 1
$4
Truth table0%0/2
A
A= $2
Truth table0%0/2
A
A= $4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | # An empty side is numbered by the line before it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | $at->{$_}++ for grep { !$at->{"${_}_left"} } qw{old new}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | undef $at->{block}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | $change->{hunks}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | sub _new_block { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_block: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | my ( $change, $at ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $block = { at => $at, deleted => [], added => [], deleted_text => [], added_text => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | push @{ $change->{blocks} }, $block; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | return $block; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # A path as a diff writes it, unquoted, without git's a/ or b/ in front when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # $git, and without the date that diff -u puts after a tab. Undef for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | # /dev/null. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | sub _diff_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_diff_path: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my ( $path, $git ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | if ( $path =~ m/\A"(.*)"\z/s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my %escape = ( n => "\n", t => "\t", q{"} => q{"}, q{\\} => q{\\} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | $path = $1 =~ s{\\([0-7]{3}|.)}{length $1 == 3 ? chr oct $1 : $escape{$1} // $1}gser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$escape{$1} // $1
MC/DC0%0/2
$escape{$1} // $1
$escape{$1}
$1
Truth table0%0/3
A // B
A= $escape{$1}B= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $path =~ s/\t.*\z//s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | return if $path eq '/dev/null'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | $path =~ s{\A[abciow]/}{} if $git; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | return $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | # A change from _parse_diff with its paths relative to the root. A path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | # outside the root is undef, like one that is not there. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | sub _resolve_change { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_change: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | my ( $self, $change, $cwd ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | my %resolved = %$change; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | $resolved{$_} = defined $change->{$_} ? $self->_relative( $change->{$_}, $cwd ) : undef for qw{old new}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | return \%resolved; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | # Whether a change could reach a test, going by the test's record and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | # layouts of the files it loaded. It reaches the test when it cannot tell. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | sub _change_reaches { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_change_reaches: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | my ( $self, $change, $record, $versions ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | # A file that is new in the change was not loaded before it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | my $old = $change->{old} // return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$change->{"old"} // (return 0)
MC/DC0%0/1
$change->{"old"} // (return 0)
$change->{"old"}
Truth table0%0/2
A
A= $change->{"old"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | my $blob = $record->{loaded}{$old} // return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$record->{"loaded"}{$old} // (return 0)
MC/DC0%0/1
$record->{"loaded"}{$old} // (return 0)
$record->{"loaded"}{$old}
Truth table0%0/2
A
A= $record->{"loaded"}{$old}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | # Every test that loaded a file breaks when it is deleted or moved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | return 1 if ( $change->{new} // q{} ) ne $old; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$change->{"new"} // ""
MC/DC0%0/1
$change->{"new"} // ""
$change->{"new"}
Truth table0%0/2
A
A= $change->{"new"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | ▶ | return 1 if !$change->{hunks} || !defined $change->{old_blob} || index( $blob, $change->{old_blob} ) != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $change->{"hunks"} && defined $change->{"old_blob"} or index($blob, $change->{"old_blob"}) != 0
$change->{'hunks'} && defined $change->{'old_blob'}
MC/DC0%0/3
not $change->{"hunks"} && defined $change->{"old_blob"} or index($blob, $change->{"old_blob"}) != 0
$change->{'hunks'}
defined $change->{'old_blob'}
index($blob, $change->{"old_blob"}) != 0
Truth table0%0/4
not(A && B) or C
A= $change->{'hunks'}B= defined $change->{'old_blob'}C= index($blob, $change->{"old_blob"}) != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my $version = $versions->{$blob}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | return 1 if !$version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | my %old_inert = map { $_ => 1 } @{ $version->{inert} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | my %new_inert = map { $_ => 1 } @{ $self->_new_inert($change) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | my ( @lines, @gaps ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | foreach my $block ( @{ $change->{blocks} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | my @code = grep { !$old_inert{$_} } @{ $block->{deleted} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | push @lines, @code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | # Code in place of nothing but comments, blank lines and POD goes in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | # between the lines around it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | push @gaps, $block->{at} if !@code && grep { !$new_inert{$_} } @{ $block->{added} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not @code and grep {not $new_inert{$_};} @{$$block{"added"};}
MC/DC0%0/2
not @code and grep {not $new_inert{$_};} @{$$block{"added"};}
not @code
grep {not $new_inert{$_};} @{$$block{"added"};}
Truth table0%0/3
not(A) and B
A= not @codeB= grep {not $new_inert{$_};} @{$$block{"added"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | return _touches( $version, $record->{executed}{$old}, \@lines, \@gaps ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | # The inert lines of the new side of a change, when the file in the work tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | # is that new side. Otherwise none, and every added line counts as code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | sub _new_inert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_inert: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | my ( $self, $change ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | my $new = $change->{new} // return []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$change->{"new"} // (return [])
MC/DC0%0/1
$change->{"new"} // (return [])
$change->{"new"}
Truth table0%0/2
A
A= $change->{"new"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | return [] if !defined $change->{new_blob} || index( $self->_blob($new) // q{}, $change->{new_blob} ) != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
not defined $change->{"new_blob"} or index($self->_blob($new) // "", $change->{"new_blob"}) != 0
$self->_blob($new) // ""
MC/DC0%0/2
not defined $change->{"new_blob"} or index($self->_blob($new) // "", $change->{"new_blob"}) != 0
not defined $change->{"new_blob"}
index($self->_blob($new) // "", $change->{"new_blob"}) != 0
MC/DC0%0/1
$self->_blob($new) // ""
$self->_blob($new)
Truth table0%0/3
not(A) or B
A= not defined $change->{"new_blob"}B= index($self->_blob($new) // "", $change->{"new_blob"}) != 0
Truth table0%0/2
A
A= $self->_blob($new)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | ▶ | my $layout = _layout( _read( File::Spec->catfile( $self->{root}, $new ) ) ) or return []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | return $layout->{inert}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | # Whether a test that ran @$executed of the lines of a file, in the version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | # that $version describes, could be affected by a change to @$lines, or by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | # code added before each of @$gaps. A changed line is judged by the innermost | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | # statement that holds it: by its first line when Devel::Cover counted a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | # statement there, and otherwise by any statement inside it. Added code is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | # judged by the innermost statement around it. When there is no such | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | # statement, or no statement inside it was counted, the answer is yes: that is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | # code which runs when the file is loaded, or code nothing measured. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | sub _touches { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_touches: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | my ( $version, $executed, $lines, $gaps ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | return 1 if ref $version ne 'HASH' || ref $executed ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $version ne "HASH" or ref $executed ne "ARRAY"
MC/DC0%0/2
ref $version ne "HASH" or ref $executed ne "ARRAY"
ref $version ne "HASH"
ref $executed ne "ARRAY"
Truth table0%0/3
A or B
A= ref $version ne "HASH"B= ref $executed ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | my %ran = map { $_ => 1 } @$executed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | my %known = map { $_ => 1 } @{ $version->{statements} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | foreach my $range ( ( map { [ $_, $_, 0 ] } @$lines ), ( map { [ $_ - 1, $_, 1 ] } @$gaps ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | my ( $from, $to, $is_gap ) = @$range; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | my $span = _innermost( $version->{spans}, $from, $to ) or return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | my @measured = !$is_gap && $known{ $span->[0] } ? ( $span->[0] ) : grep { $known{$_} } $span->[0] .. $span->[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $is_gap and $known{$span->[0]}
MC/DC0%0/2
not $is_gap and $known{$span->[0]}
not $is_gap
$known{$span->[0]}
Truth table0%0/3
not(A) and B
A= not $is_gapB= $known{$span->[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | return 1 if !@measured || grep { $ran{$_} } @measured; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not @measured or grep {$ran{$_};} @measured
MC/DC0%0/2
not @measured or grep {$ran{$_};} @measured
not @measured
grep {$ran{$_};} @measured
Truth table0%0/3
not(A) or B
A= not @measuredB= grep {$ran{$_};} @measured
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | # The innermost span that holds every line from $from to $to, or undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | sub _innermost { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_innermost: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | my ( $spans, $from, $to ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | my $best; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | ▶ | foreach my $span ( grep { $_->[0] <= $from && $_->[1] >= $to } @$spans ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_->[0] <= $from && $_->[1] >= $to
MC/DC0%0/2
$_->[0] <= $from && $_->[1] >= $to
$_->[0] <= $from
$_->[1] >= $to
Truth table0%0/3
A && B
A= $_->[0] <= $fromB= $_->[1] >= $to
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | $best = $span if !$best || $span->[0] > $best->[0] || ( $span->[0] == $best->[0] && $span->[1] < $best->[1] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
not $best or $span->[0] > $best->[0] or $span->[0] == $best->[0] and $span->[1] < $best->[1]
not $best or $span->[0] > $best->[0]
$span->[0] == $best->[0] and $span->[1] < $best->[1]
MC/DC0%0/4
not $best or $span->[0] > $best->[0] or $span->[0] == $best->[0] and $span->[1] < $best->[1]
not $best
$span->[0] > $best->[0]
$span->[0] == $best->[0]
$span->[1] < $best->[1]
Truth table0%0/5
not(A) or B or C and D
A= not $bestB= $span->[0] > $best->[0]C= $span->[0] == $best->[0]D= $span->[1] < $best->[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | return $best; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | # Where the statements of some perl are, as [ first line, last line ], and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | # which lines are inert: blank, a comment and nothing else, or POD. Undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | # when PPI cannot read it. A statement with a heredoc ends where the last of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | # its bodies does. A line of a string or of a heredoc body is never inert, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | # since changing it changes what the code does. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | sub _layout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_layout: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | my ($content) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | my $doc = _ppi($content) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | my @lines = split qq{\n}, $content, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | # What PPI calls a statement inside parentheses or brackets is part of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | # statement around it, and Devel::Cover counts that one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | ▶ | my @statements = grep { my $parent = $_->parent(); !$parent->isa('PPI::Structure') || $parent->isa('PPI::Structure::Block') } @{ $doc->find('PPI::Statement') || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
!$parent->isa('PPI::Structure') || $parent->isa('PPI::Structure::Block')
$doc->find('PPI::Statement') || []
MC/DC0%0/2
!$parent->isa('PPI::Structure') || $parent->isa('PPI::Structure::Block')
!$parent->isa('PPI::Structure')
$parent->isa('PPI::Structure::Block')
MC/DC0%0/1
$doc->find('PPI::Statement') || []
$doc->find('PPI::Statement')
Truth table0%0/3
not(A) || B
A= !$parent->isa('PPI::Structure')B= $parent->isa('PPI::Structure::Block')
Truth table0%0/2
A
A= $doc->find('PPI::Statement')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | my @spans; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | foreach my $statement (@statements) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | my $end = _last_line( $statement->last_token() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | ▶ | foreach my $heredoc ( @{ $statement->find('PPI::Token::HereDoc') || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$statement->find('PPI::Token::HereDoc') || []
MC/DC0%0/1
$statement->find('PPI::Token::HereDoc') || []
$statement->find('PPI::Token::HereDoc')
Truth table0%0/2
A
A= $statement->find('PPI::Token::HereDoc')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | my @body = $heredoc->heredoc(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | $end = List::Util::max( $end, $heredoc->line_number() + @body + 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | push @spans, [ $statement->first_token()->line_number(), $end ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | my %inert; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | foreach my $token ( $doc->tokens() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | my @span = ( $token->line_number() .. _last_line($token) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | if ( $token->isa('PPI::Token::Pod') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | $inert{$_} = 1 for @span; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | ▶ | elsif ( $token->isa('PPI::Token::Whitespace') || $token->isa('PPI::Token::Comment') ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$token->isa("PPI::Token::Whitespace") or $token->isa("PPI::Token::Comment")
MC/DC0%0/2
$token->isa("PPI::Token::Whitespace") or $token->isa("PPI::Token::Comment")
$token->isa("PPI::Token::Whitespace")
$token->isa("PPI::Token::Comment")
Truth table0%0/3
A or B
A= $token->isa("PPI::Token::Whitespace")B= $token->isa("PPI::Token::Comment")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | ▶ | $inert{$_} = 1 for grep { ( $lines[ $_ - 1 ] // q{} ) =~ m/\A\s*(?:#.*)?\z/ } @span; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$lines[$_ - 1] // ""
MC/DC0%0/1
$lines[$_ - 1] // ""
$lines[$_ - 1]
Truth table0%0/2
A
A= $lines[$_ - 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | return { spans => \@spans, inert => [ sort { $a <=> $b } keys %inert ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | # The first line of each sub named $name, in any package, in some perl. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | sub _sub_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sub_lines: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | my ( $content, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | ▶ | my $doc = _ppi($content) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | return map { $_->line_number() } grep { ( $_->name() // q{} ) =~ m/\A(?:.*::)?\Q$name\E\z/ } @{ $doc->find('PPI::Statement::Sub') || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$_->name // ""
$doc->find('PPI::Statement::Sub') || []
MC/DC0%0/1
$_->name // ""
$_->name
MC/DC0%0/1
$doc->find('PPI::Statement::Sub') || []
$doc->find('PPI::Statement::Sub')
Truth table0%0/2
A
A= $_->name
Truth table0%0/2
A
A= $doc->find('PPI::Statement::Sub')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | ▶ | sub _ppi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ppi: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my ($content) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | return if !defined $content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | my $doc = PPI::Document->new( \$content ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | $doc->index_locations(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | return $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | # The last line a token is on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | sub _last_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_last_line: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | my ($token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | my $content = $token->content(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | ▶ | return $token->line_number() + ( $content =~ tr/\n// ) - ( $content =~ m/\n\z/ ? 1 : 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | # The cache file of $root, by default the root of this object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | sub _cache_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cache_path: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | my ( $self, $root ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | ▶ | return if !defined $self->{cache_dir}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | return File::Spec->catfile( $self->{cache_dir}, Digest::SHA::sha1_hex( $root // $self->{root} ) . '.json.gz' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$root // $self->{"root"}
MC/DC0%0/2
$root // $self->{"root"}
$root
$self->{"root"}
Truth table0%0/3
A // B
A= $rootB= $self->{"root"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | # The format of the cache, the stamp of this file, the perl, and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | # configuration a run depends on. Records made under another key are stale. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | sub _cache_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cache_key: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | my @st = stat __FILE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | return join q{/}, $CACHE_FORMAT, join( q{:}, @st[ 0, 1, 7, 9 ] ), $^X, $], join( q{,}, @{ $self->{tests} } ), join( q{,}, @{ $self->{lib} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | # The records in the cache, under tests and keyed by test, and the layouts of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | # the files they name, under versions and keyed by blob. Without a usable cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | # of its own, a root takes the first usable one of its other checkouts, marked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | # borrowed. Both are empty when there is none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | sub _read_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_cache: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | my $path = $self->_cache_path() or return {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | my $own = $self->_usable_cache($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | return $own if $own; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | foreach my $root ( $self->_other_checkouts() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | my $cache = $self->_usable_cache( $self->_cache_path($root) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | ▶ | return { %$cache, borrowed => 1 } if $cache; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | return { tests => {}, versions => {} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | # The cache in the file $path, or undef when it does not read, or was made | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | # under another key. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | sub _usable_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_usable_cache: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | my ( $self, $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | # A cache that is not there fails to read, like one that is unreadable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | my $cache = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | my $gz = File::Slurper::read_binary($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | IO::Uncompress::Gunzip::gunzip( \$gz => \my $json ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | Cpanel::JSON::XS->new->decode($json); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | ▶ | my $usable = ref $cache eq 'HASH' && ( $cache->{key} // q{} ) eq $self->_cache_key() && ref $cache->{tests} eq 'HASH' && ref $cache->{versions} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/11
ref $cache eq 'HASH' && ($cache->{'key'} // '') eq $self->_cache_key && ref $cache->{'tests'} eq 'HASH' && ref $cache->{'versions'} eq 'HASH'
ref $cache eq "HASH" and ($cache->{"key"} // "") eq $self->_cache_key and ref $cache->{"tests"} eq "HASH"
ref $cache eq "HASH" and ($cache->{"key"} // "") eq $self->_cache_key
$cache->{"key"} // ""
MC/DC0%0/4
ref $cache eq 'HASH' && ($cache->{'key'} // '') eq $self->_cache_key && ref $cache->{'tests'} eq 'HASH' && ref $cache->{'versions'} eq 'HASH'
ref $cache eq "HASH"
$cache->{"key"}
ref $cache->{"tests"} eq "HASH"
ref $cache->{'versions'} eq 'HASH'
Truth table0%0/5
A and B and C && D
A= ref $cache eq "HASH"B= $cache->{"key"}C= ref $cache->{"tests"} eq "HASH"D= ref $cache->{'versions'} eq 'HASH'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | return $usable ? $cache : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | # The root of this distribution in each other checkout of its git repository: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | # the main checkout first, then each linked worktree. Empty when the root is in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | # no checkout, or in one whose repository has no other. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | sub _other_checkouts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_other_checkouts: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | my $top = $self->{root}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | until ( -e File::Spec->catfile( $top, '.git' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my $up = File::Basename::dirname($top); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | return if $up eq $top; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | $top = $up; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | ▶ | my $common = _git_common_dir( File::Spec->catfile( $top, '.git' ) ) // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_git_common_dir("File::Spec"->catfile($top, ".git")) // (return)
MC/DC0%0/1
_git_common_dir("File::Spec"->catfile($top, ".git")) // (return)
_git_common_dir("File::Spec"->catfile($top, ".git"))
Truth table0%0/2
A
A= _git_common_dir("File::Spec"->catfile($top, ".git"))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | # The directory above the common directory is a checkout unless the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | # repository is bare. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | my @tops = grep { -e File::Spec->catfile( $_, '.git' ) } File::Basename::dirname($common); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | my $list = File::Spec->catdir( $common, 'worktrees' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | ▶ | if ( opendir( my $dh, $list ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | foreach my $name ( sort grep { !m/\A[.]/ } readdir $dh ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | ▶ | my $dotgit = _first_line( File::Spec->catfile( $list, $name, 'gitdir' ) ) // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_first_line("File::Spec"->catfile($list, $name, "gitdir")) // (next)
MC/DC0%0/1
_first_line("File::Spec"->catfile($list, $name, "gitdir")) // (next)
_first_line("File::Spec"->catfile($list, $name, "gitdir"))
Truth table0%0/2
A
A= _first_line("File::Spec"->catfile($list, $name, "gitdir"))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | chomp $dotgit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | push @tops, File::Basename::dirname($dotgit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | my $rel = File::Spec->abs2rel( $self->{root}, $top ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | my %seen = ( $self->{root} => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | ▶ | return grep { -d && !$seen{$_}++ } map { Cwd::abs_path( File::Spec->catdir( $_, $rel ) ) // () } @tops; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
-d $_ && !$seen{$_}++
Cwd::abs_path("File::Spec"->catdir($_, $rel)) // ()
MC/DC0%0/2
-d $_ && !$seen{$_}++
-d $_
!$seen{$_}++
MC/DC0%0/2
Cwd::abs_path("File::Spec"->catdir($_, $rel)) // ()
Cwd::abs_path("File::Spec"->catdir($_, $rel))
()
Truth table0%0/3
A && not(B)
A= -d $_B= !$seen{$_}++
Truth table0%0/3
A // B
A= Cwd::abs_path("File::Spec"->catdir($_, $rel))B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | # The common directory of the repository of a checkout whose .git is $dotgit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | # The main checkout has the directory itself. A linked worktree has a file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | # that names its own directory, which names the common one in commondir. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | # Undef for anything else, such as the .git file of a submodule. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | ▶ | sub _git_common_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_git_common_dir: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | my ($dotgit) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | ▶ | return Cwd::abs_path($dotgit) if -d $dotgit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | my ($gitdir) = ( _first_line($dotgit) // q{} ) =~ m/\Agitdir:\s*(.+?)\s*\z/ or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
_first_line($dotgit) // ""
MC/DC0%0/1
_first_line($dotgit) // ""
_first_line($dotgit)
Truth table0%0/2
A
A= _first_line($dotgit)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | $gitdir = File::Spec->rel2abs( $gitdir, File::Basename::dirname($dotgit) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | ▶ | my $common = _first_line( File::Spec->catfile( $gitdir, 'commondir' ) ) // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_first_line("File::Spec"->catfile($gitdir, "commondir")) // (return)
MC/DC0%0/1
_first_line("File::Spec"->catfile($gitdir, "commondir")) // (return)
_first_line("File::Spec"->catfile($gitdir, "commondir"))
Truth table0%0/2
A
A= _first_line("File::Spec"->catfile($gitdir, "commondir"))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | chomp $common; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | return Cwd::abs_path( File::Spec->rel2abs( $common, $gitdir ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | # Replaces the file whole, so a reader never sees half of it. Keeps only the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | # versions that some record names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | ▶ | sub _write_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_cache: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | my ( $self, $records, $versions ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | ▶ | my $path = $self->_cache_path() or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | my %named = map { $_ => $versions->{$_} } grep { $versions->{$_} } map { values %{ $_->{loaded} } } values %$records; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | my $json = Cpanel::JSON::XS->new->canonical->encode( { key => $self->_cache_key(), root => $self->{root}, tests => $records, versions => \%named } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | # The root goes in the gzip header too, so that _prune_cache can read it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | # without decompressing the file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | ▶ | IO::Compress::Gzip::gzip( \$json => \my $gz, Comment => $self->{root} ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | File::Path::make_path( $self->{cache_dir}, { error => \my $errors } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | ▶ | return if @$errors; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | my $ok = eval { File::Slurper::Temp::write_binary( $path, $gz ); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | _prune_cache( $self->{cache_dir} ) if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | return $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | # Removes the cache of each root that is gone, such as a deleted checkout. A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | # file whose header cannot be read is removed too, since nothing can read it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | ▶ | sub _prune_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prune_cache: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | my ($cache_dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | ▶ | opendir( my $dh, $cache_dir ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | my @names = grep { m/$CACHE_FILE_RX/ } readdir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | foreach my $name (@names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | my $file = File::Spec->catfile( $cache_dir, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | my $root = _cached_root($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | ▶ | next if defined $root && -d $root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $root and -d $root
MC/DC0%0/2
defined $root and -d $root
defined $root
-d $root
Truth table0%0/3
A and B
A= defined $rootB= -d $root
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | unlink $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | # The root that a cache file is for, from its gzip header, or undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | ▶ | sub _cached_root { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cached_root: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | ▶ | my $z = IO::Uncompress::Gunzip->new($file) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | my $header = $z->getHeaderInfo(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | $z->close(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | ▶ | return ref $header eq 'HASH' ? $header->{Comment} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||