line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Alien::Run; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
687
|
use strict; |
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
45
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
42
|
|
5
|
2
|
|
|
2
|
|
5
|
use Test2::API qw( context ); |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
1733
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Run object |
8
|
|
|
|
|
|
|
our $VERSION = '0.12'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
7
|
|
|
7
|
1
|
7897
|
sub out { shift->{out} } |
12
|
7
|
|
|
7
|
1
|
37
|
sub err { shift->{err} } |
13
|
27
|
|
|
27
|
1
|
116
|
sub exit { shift->{exit} } |
14
|
14
|
|
|
14
|
1
|
51
|
sub signal { shift->{sig} } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub success |
18
|
|
|
|
|
|
|
{ |
19
|
5
|
|
|
5
|
1
|
788
|
my($self, $message) = @_; |
20
|
5
|
|
50
|
|
|
32
|
$message ||= 'command succeeded'; |
21
|
5
|
|
100
|
|
|
11
|
my $ok = $self->exit == 0 && $self->signal == 0; |
22
|
5
|
100
|
|
|
|
16
|
$ok = 0 if $self->{fail}; |
23
|
|
|
|
|
|
|
|
24
|
5
|
|
|
|
|
11
|
my $ctx = context(); |
25
|
5
|
|
|
|
|
288
|
$ctx->ok($ok, $message); |
26
|
5
|
100
|
|
|
|
439
|
unless($ok) |
27
|
|
|
|
|
|
|
{ |
28
|
4
|
100
|
|
|
|
7
|
$ctx->diag(" command exited with @{[ $self->exit ]}") if $self->exit; |
|
1
|
|
|
|
|
6
|
|
29
|
4
|
100
|
|
|
|
63
|
$ctx->diag(" command killed with @{[ $self->signal ]}") if $self->signal; |
|
1
|
|
|
|
|
7
|
|
30
|
4
|
100
|
|
|
|
48
|
$ctx->diag(" @{[ $self->{fail} ]}") if $self->{fail}; |
|
2
|
|
|
|
|
9
|
|
31
|
|
|
|
|
|
|
} |
32
|
5
|
|
|
|
|
84
|
$ctx->release; |
33
|
5
|
|
|
|
|
73
|
$self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub exit_is |
38
|
|
|
|
|
|
|
{ |
39
|
4
|
|
|
4
|
1
|
6298
|
my($self, $exit, $message) = @_; |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
33
|
|
|
29
|
$message ||= "command exited with value $exit"; |
42
|
4
|
|
|
|
|
7
|
my $ok = $self->exit == $exit; |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
10
|
my $ctx = context(); |
45
|
4
|
|
|
|
|
242
|
$ctx->ok($ok, $message); |
46
|
4
|
100
|
|
|
|
347
|
$ctx->diag(" actual exit value was: @{[ $self->exit ]}") unless $ok; |
|
2
|
|
|
|
|
5
|
|
47
|
4
|
|
|
|
|
102
|
$ctx->release; |
48
|
4
|
|
|
|
|
70
|
$self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub exit_isnt |
53
|
|
|
|
|
|
|
{ |
54
|
4
|
|
|
4
|
1
|
4561
|
my($self, $exit, $message) = @_; |
55
|
|
|
|
|
|
|
|
56
|
4
|
|
33
|
|
|
24
|
$message ||= "command exited with value not $exit"; |
57
|
4
|
|
|
|
|
9
|
my $ok = $self->exit != $exit; |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
|
|
10
|
my $ctx = context(); |
60
|
4
|
|
|
|
|
250
|
$ctx->ok($ok, $message); |
61
|
4
|
100
|
|
|
|
297
|
$ctx->diag(" actual exit value was: @{[ $self->exit ]}") unless $ok; |
|
2
|
|
|
|
|
3
|
|
62
|
4
|
|
|
|
|
76
|
$ctx->release; |
63
|
4
|
|
|
|
|
59
|
$self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _like |
68
|
|
|
|
|
|
|
{ |
69
|
6
|
|
|
6
|
|
8
|
my($self, $regex, $source, $not, $message) = @_; |
70
|
|
|
|
|
|
|
|
71
|
6
|
|
|
|
|
30
|
my $ok = $self->{$source} =~ $regex; |
72
|
6
|
100
|
|
|
|
12
|
$ok = !$ok if $not; |
73
|
|
|
|
|
|
|
|
74
|
6
|
|
|
|
|
9
|
my $ctx = context(); |
75
|
6
|
|
|
|
|
331
|
$ctx->ok($ok, $message); |
76
|
6
|
100
|
|
|
|
303
|
unless($ok) |
77
|
|
|
|
|
|
|
{ |
78
|
2
|
|
|
|
|
7
|
$ctx->diag(" $source:"); |
79
|
2
|
|
|
|
|
85
|
$ctx->diag(" $_") for split /\r?\n/, $self->{$source}; |
80
|
2
|
100
|
|
|
|
67
|
$ctx->diag($not ? ' matches:' : ' does not match:'); |
81
|
2
|
|
|
|
|
64
|
$ctx->diag(" $regex"); |
82
|
|
|
|
|
|
|
} |
83
|
6
|
|
|
|
|
68
|
$ctx->release; |
84
|
|
|
|
|
|
|
|
85
|
6
|
|
|
|
|
79
|
$self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub out_like |
89
|
|
|
|
|
|
|
{ |
90
|
2
|
|
|
2
|
1
|
1751
|
my($self, $regex, $message) = @_; |
91
|
2
|
|
33
|
|
|
12
|
$message ||= "output matches $regex"; |
92
|
2
|
|
|
|
|
5
|
$self->_like($regex, 'out', 0, $message); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub out_unlike |
97
|
|
|
|
|
|
|
{ |
98
|
2
|
|
|
2
|
1
|
5063
|
my($self, $regex, $message) = @_; |
99
|
2
|
|
33
|
|
|
12
|
$message ||= "output does not match $regex"; |
100
|
2
|
|
|
|
|
4
|
$self->_like($regex, 'out', 1, $message); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub err_like |
105
|
|
|
|
|
|
|
{ |
106
|
1
|
|
|
1
|
1
|
965
|
my($self, $regex, $message) = @_; |
107
|
1
|
|
33
|
|
|
9
|
$message ||= "standard error matches $regex"; |
108
|
1
|
|
|
|
|
3
|
$self->_like($regex, 'err', 0, $message); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub err_unlike |
113
|
|
|
|
|
|
|
{ |
114
|
1
|
|
|
1
|
1
|
875
|
my($self, $regex, $message) = @_; |
115
|
1
|
|
33
|
|
|
6
|
$message ||= "standard error does not match $regex"; |
116
|
1
|
|
|
|
|
4
|
$self->_like($regex, 'err', 1, $message); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub note |
121
|
|
|
|
|
|
|
{ |
122
|
1
|
|
|
1
|
1
|
1956
|
my($self) = @_; |
123
|
1
|
|
|
|
|
5
|
my $ctx = context(); |
124
|
1
|
|
|
|
|
52
|
$ctx->note("[cmd]"); |
125
|
1
|
|
|
|
|
61
|
$ctx->note(" @{$self->{cmd}}"); |
|
1
|
|
|
|
|
6
|
|
126
|
1
|
50
|
|
|
|
56
|
if($self->out ne '') |
127
|
|
|
|
|
|
|
{ |
128
|
1
|
|
|
|
|
6
|
$ctx->note("[out]"); |
129
|
1
|
|
|
|
|
81
|
$ctx->note(" $_") for split /\r?\n/, $self->out; |
130
|
|
|
|
|
|
|
} |
131
|
1
|
50
|
|
|
|
85
|
if($self->err ne '') |
132
|
|
|
|
|
|
|
{ |
133
|
1
|
|
|
|
|
6
|
$ctx->note("[err]"); |
134
|
1
|
|
|
|
|
55
|
$ctx->note(" $_") for split /\r?\n/, $self->err; |
135
|
|
|
|
|
|
|
} |
136
|
1
|
|
|
|
|
53
|
$ctx->release; |
137
|
1
|
|
|
|
|
15
|
$self; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub diag |
142
|
|
|
|
|
|
|
{ |
143
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
144
|
0
|
|
|
|
|
|
my $ctx = context(); |
145
|
0
|
|
|
|
|
|
$ctx->diag("[cmd]"); |
146
|
0
|
|
|
|
|
|
$ctx->diag(" @{$self->{cmd}}"); |
|
0
|
|
|
|
|
|
|
147
|
0
|
0
|
|
|
|
|
if($self->out ne '') |
148
|
|
|
|
|
|
|
{ |
149
|
0
|
|
|
|
|
|
$ctx->diag("[out]"); |
150
|
0
|
|
|
|
|
|
$ctx->diag(" $_") for split /\r?\n/, $self->out; |
151
|
|
|
|
|
|
|
} |
152
|
0
|
0
|
|
|
|
|
if($self->err ne '') |
153
|
|
|
|
|
|
|
{ |
154
|
0
|
|
|
|
|
|
$ctx->diag("[err]"); |
155
|
0
|
|
|
|
|
|
$ctx->diag(" $_") for split /\r?\n/, $self->err; |
156
|
|
|
|
|
|
|
} |
157
|
0
|
|
|
|
|
|
$ctx->release; |
158
|
0
|
|
|
|
|
|
$self; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
__END__ |