blib/lib/Shell/Autobox.pm

filter: Statementstmt 100% 42 / 42 Branchbran 100% 10 / 10 Conditioncond 66.6% 6 / 9 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 92.1% 70 / 76 CC 10 SCAR 16.4
CC
10
Cov
95%
__ANON__
9.1
import
2.0
BEGIN
1.0
CRAP 5.2
↑ Summary
1 package Shell::Autobox;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base qw(autobox);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use IPC::Run3 qw(run3);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # XXX this declaration must be on a single line
12 # https://metacpan.org/pod/version#How-to-declare()-a-dotted-decimal-version
13 2 ▶use version; our $VERSION = version->declare('v2.0.1');
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
16 2 my $class = shift;
17 2 my $caller = (caller)[0];
18  
19 2 for my $program (@_) {
20 19 ▶ my $sub = sub {
Subroutine __ANON__: called CC=9 SCAR=22.1
21 19 my ($input, @args) = @_;
22 19 my @command = ($program, @args);
23 19 my $command = join(' ', @command);
24 19 ▶ my $stdin = (defined($input) && ref($input) eq '') ? \$input : $input;
Branch: 1 branch
BranchTrueFalseTotal
defined $input && ref $input eq '' ? : 18 1 19
Condition66%2/3
defined $input and ref $input eq ""
!ll&&!rl&&r
0118
MC/DC50%1/2
defined $input and ref $input eq ""
defined $input ref $input eq ""
Truth table66%2/3
A and B
A= defined $inputB= ref $input eq ""
ABresult
0X0
100
111
25  
26 19 run3(\@command, $stdin, \my $stdout, \my $stderr, {
27 return_if_system_error => 1, # don't die on error
28 });
29  
30 19 ▶ my $error = (defined($stderr) && $stderr =~ /\S/) ? ": $stderr" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $stderr && $stderr =~ /\S/ ? : 8 11 19
Condition66%2/3
defined $stderr and $stderr =~ /\S/
!ll&&!rl&&r
0118
MC/DC50%1/2
defined $stderr and $stderr =~ /\S/
defined $stderr $stderr =~ /\S/
Truth table66%2/3
A and B
A= defined $stderrB= $stderr =~ /\S/
ABresult
0X0
100
111
31 19 my $message = "$command$error";
32  
33 19 ▶ if ($?) {
Branch: 2 branches
BranchTrueFalseTotal
if ($?) { } 4 15 19
elsif ($error) { } 4 11 15
34 4 confess "can't exec $message";
35 } elsif ($error) {
36 4 warn "error running $message";
37 }
38  
39 15 ▶ return (defined($stdout) && length($stdout)) ? $stdout : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $stdout && length $stdout ? : 14 1 15
Condition66%2/3
defined $stdout and length $stdout
!ll&&!rl&&r
0114
MC/DC50%1/2
defined $stdout and length $stdout
defined $stdout length $stdout
Truth table66%2/3
A and B
A= defined $stdoutB= length $stdout
ABresult
0X0
100
111
40 1 };
41  
42 {
43 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 *{"$caller\::$program"} = $sub;
45 }
46 }
47  
48 2 $class->SUPER::import(SCALAR => $caller, ARRAY => $caller);
49 }
50  
51 2 1;
52  
53 __END__
↑ Summary