blib/lib/Test/Alien/Run.pm

filter: Statementstmt 87.0% 87 / 100 Branchbran 85.7% 24 / 28 Conditioncond 58.8% 10 / 17 MC/DCmcdc 22.2% 2 / 9 Subroutinesub 94.4% 17 / 18 Podpod 100% 13 / 13 totaltotal 82.7% 153 / 185 CC 28 SCAR 19.2
CC
28
Cov
83%
diag
30.0
success
8.0
_like
5.0
CRAP 6.8
« blib/lib/Alien/Build/Plugin/Build/Make.pm ↑ Summary blib/lib/Alien/Build/Plugin/Fetch/LocalDir.pm »
1 package Test::Alien::Run;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Test2::API qw( context );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # ABSTRACT: Run object
9 4 our $VERSION = '2.88'; # VERSION
10  
11  
12 13 ▶sub out { shift->{out} }
Subroutine out: called CC=1 SCAR=0.0
Pod documented
13 13 ▶sub err { shift->{err} }
Subroutine err: called CC=1 SCAR=0.0
Pod documented
14 33 ▶sub exit { shift->{exit} }
Subroutine exit: called CC=1 SCAR=0.0
Pod documented
15 18 ▶sub signal { shift->{sig} }
Subroutine signal: called CC=1 SCAR=0.0
Pod documented
16  
17  
18 sub success
19 9 ▶{
Subroutine success: called CC=8 SCAR=20.8
Pod documented
20 9 my($self, $message) = @_;
21 9 ▶ $message ||= 'command succeeded';
Condition50%1/2
$message ||= "command succeeded"
l!l
09
MC/DC0%0/1
$message ||= "command succeeded"
$message
Truth table50%1/2
A
A= $message
Aresult
11
00
22 9 ▶ my $ok = $self->exit == 0 && $self->signal == 0;
Condition100%3/3
$self->exit == 0 && $self->signal == 0
!ll&&!rl&&r
117
MC/DC100%2/2
$self->exit == 0 && $self->signal == 0
$self->exit == 0 $self->signal == 0
Truth table100%3/3
A && B
A= $self->exit == 0B= $self->signal == 0
ABresult
0X0
100
111
23 9 ▶ $ok = 0 if $self->{fail};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"fail"} 2 7 9
24  
25 9 my $ctx = context();
26 9 $ctx->ok($ok, $message);
27 9 ▶ unless($ok)
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 4 5 9
28 {
29 4 ▶ $ctx->diag(" command exited with @{[ $self->exit ]}") if $self->exit;
Branch: 1 branch
BranchTrueFalseTotal
if $self->exit 1 3 4
30 4 ▶ $ctx->diag(" command killed with @{[ $self->signal ]}") if $self->signal;
Branch: 1 branch
BranchTrueFalseTotal
if $self->signal 1 3 4
31 4 ▶ $ctx->diag(" @{[ $self->{fail} ]}") if $self->{fail};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"fail"} 2 2 4
32 }
33 9 $ctx->release;
34 9 $self;
35 }
36  
37  
38 sub exit_is
39 6 ▶{
Subroutine exit_is: called CC=3 SCAR=11.0
Pod documented
40 6 my($self, $exit, $message) = @_;
41  
42 6 ▶ $message ||= "command exited with value $exit";
Condition50%1/2
$message ||= "command exited with value $exit"
l!l
06
MC/DC0%0/1
$message ||= "command exited with value $exit"
$message
Truth table50%1/2
A
A= $message
Aresult
11
00
43 6 my $ok = $self->exit == $exit;
44  
45 6 my $ctx = context();
46 6 $ctx->ok($ok, $message);
47 6 ▶ $ctx->diag(" actual exit value was: @{[ $self->exit ]}") unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 2 4 6
48 6 $ctx->release;
49 6 $self;
50 }
51  
52  
53 sub exit_isnt
54 4 ▶{
Subroutine exit_isnt: called CC=3 SCAR=11.0
Pod documented
55 4 my($self, $exit, $message) = @_;
56  
57 4 ▶ $message ||= "command exited with value not $exit";
Condition50%1/2
$message ||= "command exited with value not $exit"
l!l
04
MC/DC0%0/1
$message ||= "command exited with value not $exit"
$message
Truth table50%1/2
A
A= $message
Aresult
11
00
58 4 my $ok = $self->exit != $exit;
59  
60 4 my $ctx = context();
61 4 $ctx->ok($ok, $message);
62 4 ▶ $ctx->diag(" actual exit value was: @{[ $self->exit ]}") unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 2 2 4
63 4 $ctx->release;
64 4 $self;
65 }
66  
67  
68 sub _like
69 6 ▶{
Subroutine _like: called CC=5 SCAR=16.1
70 6 my($self, $regex, $source, $not, $message) = @_;
71  
72 6 my $ok = $self->{$source} =~ $regex;
73 6 ▶ $ok = !$ok if $not;
Branch: 1 branch
BranchTrueFalseTotal
if $not 3 3 6
74  
75 6 my $ctx = context();
76 6 $ctx->ok($ok, $message);
77 6 ▶ unless($ok)
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 2 4 6
78 {
79 2 $ctx->diag(" $source:");
80 2 $ctx->diag(" $_") for split /\r?\n/, $self->{$source};
81 2 ▶ $ctx->diag($not ? ' matches:' : ' does not match:');
Branch: 1 branch
BranchTrueFalseTotal
$not ? : 1 1 2
82 2 $ctx->diag(" $regex");
83 }
84 6 $ctx->release;
85  
86 6 $self;
87 }
88  
89 sub out_like
90 2 ▶{
Subroutine out_like: called CC=2 SCAR=7.1
Pod documented
91 2 my($self, $regex, $message) = @_;
92 2 ▶ $message ||= "output matches $regex";
Condition50%1/2
$message ||= "output matches $regex"
l!l
02
MC/DC0%0/1
$message ||= "output matches $regex"
$message
Truth table50%1/2
A
A= $message
Aresult
11
00
93 2 $self->_like($regex, 'out', 0, $message);
94 }
95  
96  
97 sub out_unlike
98 2 ▶{
Subroutine out_unlike: called CC=2 SCAR=7.1
Pod documented
99 2 my($self, $regex, $message) = @_;
100 2 ▶ $message ||= "output does not match $regex";
Condition50%1/2
$message ||= "output does not match $regex"
l!l
02
MC/DC0%0/1
$message ||= "output does not match $regex"
$message
Truth table50%1/2
A
A= $message
Aresult
11
00
101 2 $self->_like($regex, 'out', 1, $message);
102 }
103  
104  
105 sub err_like
106 1 ▶{
Subroutine err_like: called CC=2 SCAR=7.1
Pod documented
107 1 my($self, $regex, $message) = @_;
108 1 ▶ $message ||= "standard error matches $regex";
Condition50%1/2
$message ||= "standard error matches $regex"
l!l
01
MC/DC0%0/1
$message ||= "standard error matches $regex"
$message
Truth table50%1/2
A
A= $message
Aresult
11
00
109 1 $self->_like($regex, 'err', 0, $message);
110 }
111  
112  
113 sub err_unlike
114 1 ▶{
Subroutine err_unlike: called CC=2 SCAR=7.1
Pod documented
115 1 my($self, $regex, $message) = @_;
116 1 ▶ $message ||= "standard error does not match $regex";
Condition50%1/2
$message ||= "standard error does not match $regex"
l!l
01
MC/DC0%0/1
$message ||= "standard error does not match $regex"
$message
Truth table50%1/2
A
A= $message
Aresult
11
00
117 1 $self->_like($regex, 'err', 1, $message);
118 }
119  
120  
121 sub note
122 7 ▶{
Subroutine note: called CC=5 SCAR=16.1
Pod documented
123 7 my($self) = @_;
124 7 my $ctx = context();
125 7 $ctx->note("[cmd]");
126 7 $ctx->note(" @{$self->{cmd}}");
127 7 ▶ if($self->out ne '')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->out ne "") 1 6 7
128 {
129 1 $ctx->note("[out]");
130 1 $ctx->note(" $_") for split /\r?\n/, $self->out;
131 }
132 7 ▶ if($self->err ne '')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->err ne "") 1 6 7
133 {
134 1 $ctx->note("[err]");
135 1 $ctx->note(" $_") for split /\r?\n/, $self->err;
136 }
137 7 $ctx->release;
138 7 $self;
139 }
140  
141  
142 sub diag
143 0 ▶{
Subroutine diag: not called CC=5 SCAR=34.0
Pod documented
144 0 my($self) = @_;
145 0 my $ctx = context();
146 0 $ctx->diag("[cmd]");
147 0 $ctx->diag(" @{$self->{cmd}}");
148 0 ▶ if($self->out ne '')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->out ne "") 0 0 0
149 {
150 0 $ctx->diag("[out]");
151 0 $ctx->diag(" $_") for split /\r?\n/, $self->out;
152 }
153 0 ▶ if($self->err ne '')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->err ne "") 0 0 0
154 {
155 0 $ctx->diag("[err]");
156 0 $ctx->diag(" $_") for split /\r?\n/, $self->err;
157 }
158 0 $ctx->release;
159 0 $self;
160 }
161  
162 4 1;
163  
164 __END__
« blib/lib/Alien/Build/Plugin/Build/Make.pm ↑ Summary blib/lib/Alien/Build/Plugin/Fetch/LocalDir.pm »