blib/lib/Tapper/Base.pm

filter: Statementstmt 65.5% 19 / 29 Branchbran 25.0% 4 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 100% 2 / 2 totaltotal 50.0% 28 / 56 CC 10 SCAR 27.5
CC
10
Cov
48%
makedir
30.0
log_and_exec
8.6
BEGIN
1.0
CRAP 15.7
↑ Summary
1 package Tapper::Base;
2 # git description: v5.0.0-1-g5b9d217
3  
4 3 our $AUTHORITY = 'cpan:TAPPER';
5 # ABSTRACT: Tapper - Common functions for all Tapper classes
6 3 $Tapper::Base::VERSION = '5.0.1';
7 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 with 'MooseX::Log::Log4perl';
12  
13  
14 sub makedir
15 0 ▶{
Subroutine makedir: not called CC=5 SCAR=34.0
Pod documented
16 0 my ($self, $dir) = @_;
17 0 ▶ return 0 if -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
if -d $dir 0 0 0
18 0 ▶ if (-e $dir and not -d $dir) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $dir and not -d $dir) 0 0 0
Condition0%0/3
-e $dir and not -d $dir
!ll&&!rl&&r
000
MC/DC0%0/2
-e $dir and not -d $dir
-e $dir not -d $dir
Truth table0%0/3
A and not(B)
A= -e $dirB= not -d $dir
ABresult
0X0
100
111
19 0 unlink $dir;
20 }
21 0 ▶ system("mkdir","-p",$dir) == 0 or return "Can't create $dir:$!";
Branch: 1 branch
BranchTrueFalseTotal
system("mkdir", "-p", $dir) == 0 or return "Can't create ${dir}:$!" 0 0 0
22 0 return 0;
23 }
24  
25  
26  
27 sub log_and_exec
28 1 ▶{
Subroutine log_and_exec: called CC=6 SCAR=21.5
Pod documented
29 1 my ($self, @cmd) = @_;
30 1 my $cmd = join " ",@cmd;
31 1 $self->log->debug( $cmd );
32 1 my $output=`$cmd 2>&1`;
33 1 my $retval=$?;
34 1 ▶ if (not defined($output)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $output) 0 1 1
35 0 $output = "Executing $cmd failed";
36 0 $retval = 1;
37 }
38 1 ▶ chomp $output if $output;
Branch: 1 branch
BranchTrueFalseTotal
if $output 0 1 1
39 1 ▶ if ($retval) {
Branch: 1 branch
BranchTrueFalseTotal
if ($retval) 0 1 1
40 0 ▶ return ($retval >> 8, $output) if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
41 0 return $output;
42 }
43 1 ▶ return (0, $output) if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
44 1 return 0;
45 }
46  
47 3 1; # End of Tapper::Base
48  
49 __END__
↑ Summary