line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Alien::Run; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
764
|
use strict; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
95
|
|
4
|
3
|
|
|
3
|
|
21
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
78
|
|
5
|
3
|
|
|
3
|
|
56
|
use 5.008004; |
|
3
|
|
|
|
|
10
|
|
6
|
3
|
|
|
3
|
|
20
|
use Test2::API qw( context ); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
4001
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Run object |
9
|
|
|
|
|
|
|
our $VERSION = '2.46'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
7
|
|
|
7
|
1
|
14337
|
sub out { shift->{out} } |
13
|
7
|
|
|
7
|
1
|
43
|
sub err { shift->{err} } |
14
|
27
|
|
|
27
|
1
|
140
|
sub exit { shift->{exit} } |
15
|
14
|
|
|
14
|
1
|
72
|
sub signal { shift->{sig} } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub success |
19
|
|
|
|
|
|
|
{ |
20
|
5
|
|
|
5
|
1
|
2169
|
my($self, $message) = @_; |
21
|
5
|
|
50
|
|
|
47
|
$message ||= 'command succeeded'; |
22
|
5
|
|
100
|
|
|
13
|
my $ok = $self->exit == 0 && $self->signal == 0; |
23
|
5
|
100
|
|
|
|
17
|
$ok = 0 if $self->{fail}; |
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
|
|
16
|
my $ctx = context(); |
26
|
5
|
|
|
|
|
453
|
$ctx->ok($ok, $message); |
27
|
5
|
100
|
|
|
|
1511
|
unless($ok) |
28
|
|
|
|
|
|
|
{ |
29
|
4
|
100
|
|
|
|
19
|
$ctx->diag(" command exited with @{[ $self->exit ]}") if $self->exit; |
|
1
|
|
|
|
|
10
|
|
30
|
4
|
100
|
|
|
|
264
|
$ctx->diag(" command killed with @{[ $self->signal ]}") if $self->signal; |
|
1
|
|
|
|
|
3
|
|
31
|
4
|
100
|
|
|
|
182
|
$ctx->diag(" @{[ $self->{fail} ]}") if $self->{fail}; |
|
2
|
|
|
|
|
9
|
|
32
|
|
|
|
|
|
|
} |
33
|
5
|
|
|
|
|
320
|
$ctx->release; |
34
|
5
|
|
|
|
|
150
|
$self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub exit_is |
39
|
|
|
|
|
|
|
{ |
40
|
4
|
|
|
4
|
1
|
8291
|
my($self, $exit, $message) = @_; |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
33
|
|
|
36
|
$message ||= "command exited with value $exit"; |
43
|
4
|
|
|
|
|
9
|
my $ok = $self->exit == $exit; |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
12
|
my $ctx = context(); |
46
|
4
|
|
|
|
|
299
|
$ctx->ok($ok, $message); |
47
|
4
|
100
|
|
|
|
786
|
$ctx->diag(" actual exit value was: @{[ $self->exit ]}") unless $ok; |
|
2
|
|
|
|
|
7
|
|
48
|
4
|
|
|
|
|
301
|
$ctx->release; |
49
|
4
|
|
|
|
|
85
|
$self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub exit_isnt |
54
|
|
|
|
|
|
|
{ |
55
|
4
|
|
|
4
|
1
|
8181
|
my($self, $exit, $message) = @_; |
56
|
|
|
|
|
|
|
|
57
|
4
|
|
33
|
|
|
32
|
$message ||= "command exited with value not $exit"; |
58
|
4
|
|
|
|
|
9
|
my $ok = $self->exit != $exit; |
59
|
|
|
|
|
|
|
|
60
|
4
|
|
|
|
|
10
|
my $ctx = context(); |
61
|
4
|
|
|
|
|
307
|
$ctx->ok($ok, $message); |
62
|
4
|
100
|
|
|
|
684
|
$ctx->diag(" actual exit value was: @{[ $self->exit ]}") unless $ok; |
|
2
|
|
|
|
|
6
|
|
63
|
4
|
|
|
|
|
322
|
$ctx->release; |
64
|
4
|
|
|
|
|
84
|
$self; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _like |
69
|
|
|
|
|
|
|
{ |
70
|
6
|
|
|
6
|
|
12
|
my($self, $regex, $source, $not, $message) = @_; |
71
|
|
|
|
|
|
|
|
72
|
6
|
|
|
|
|
35
|
my $ok = $self->{$source} =~ $regex; |
73
|
6
|
100
|
|
|
|
14
|
$ok = !$ok if $not; |
74
|
|
|
|
|
|
|
|
75
|
6
|
|
|
|
|
17
|
my $ctx = context(); |
76
|
6
|
|
|
|
|
452
|
$ctx->ok($ok, $message); |
77
|
6
|
100
|
|
|
|
802
|
unless($ok) |
78
|
|
|
|
|
|
|
{ |
79
|
2
|
|
|
|
|
7
|
$ctx->diag(" $source:"); |
80
|
2
|
|
|
|
|
322
|
$ctx->diag(" $_") for split /\r?\n/, $self->{$source}; |
81
|
2
|
100
|
|
|
|
295
|
$ctx->diag($not ? ' matches:' : ' does not match:'); |
82
|
2
|
|
|
|
|
326
|
$ctx->diag(" $regex"); |
83
|
|
|
|
|
|
|
} |
84
|
6
|
|
|
|
|
316
|
$ctx->release; |
85
|
|
|
|
|
|
|
|
86
|
6
|
|
|
|
|
126
|
$self; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub out_like |
90
|
|
|
|
|
|
|
{ |
91
|
2
|
|
|
2
|
1
|
3171
|
my($self, $regex, $message) = @_; |
92
|
2
|
|
33
|
|
|
19
|
$message ||= "output matches $regex"; |
93
|
2
|
|
|
|
|
7
|
$self->_like($regex, 'out', 0, $message); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub out_unlike |
98
|
|
|
|
|
|
|
{ |
99
|
2
|
|
|
2
|
1
|
8485
|
my($self, $regex, $message) = @_; |
100
|
2
|
|
33
|
|
|
21
|
$message ||= "output does not match $regex"; |
101
|
2
|
|
|
|
|
6
|
$self->_like($regex, 'out', 1, $message); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub err_like |
106
|
|
|
|
|
|
|
{ |
107
|
1
|
|
|
1
|
1
|
1511
|
my($self, $regex, $message) = @_; |
108
|
1
|
|
33
|
|
|
9
|
$message ||= "standard error matches $regex"; |
109
|
1
|
|
|
|
|
3
|
$self->_like($regex, 'err', 0, $message); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub err_unlike |
114
|
|
|
|
|
|
|
{ |
115
|
1
|
|
|
1
|
1
|
1548
|
my($self, $regex, $message) = @_; |
116
|
1
|
|
33
|
|
|
17
|
$message ||= "standard error does not match $regex"; |
117
|
1
|
|
|
|
|
4
|
$self->_like($regex, 'err', 1, $message); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub note |
122
|
|
|
|
|
|
|
{ |
123
|
1
|
|
|
1
|
1
|
34178
|
my($self) = @_; |
124
|
1
|
|
|
|
|
4
|
my $ctx = context(); |
125
|
1
|
|
|
|
|
88
|
$ctx->note("[cmd]"); |
126
|
1
|
|
|
|
|
232
|
$ctx->note(" @{$self->{cmd}}"); |
|
1
|
|
|
|
|
64
|
|
127
|
1
|
50
|
|
|
|
201
|
if($self->out ne '') |
128
|
|
|
|
|
|
|
{ |
129
|
1
|
|
|
|
|
4
|
$ctx->note("[out]"); |
130
|
1
|
|
|
|
|
180
|
$ctx->note(" $_") for split /\r?\n/, $self->out; |
131
|
|
|
|
|
|
|
} |
132
|
1
|
50
|
|
|
|
181
|
if($self->err ne '') |
133
|
|
|
|
|
|
|
{ |
134
|
1
|
|
|
|
|
3
|
$ctx->note("[err]"); |
135
|
1
|
|
|
|
|
176
|
$ctx->note(" $_") for split /\r?\n/, $self->err; |
136
|
|
|
|
|
|
|
} |
137
|
1
|
|
|
|
|
178
|
$ctx->release; |
138
|
1
|
|
|
|
|
22
|
$self; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub diag |
143
|
|
|
|
|
|
|
{ |
144
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
145
|
0
|
|
|
|
|
|
my $ctx = context(); |
146
|
0
|
|
|
|
|
|
$ctx->diag("[cmd]"); |
147
|
0
|
|
|
|
|
|
$ctx->diag(" @{$self->{cmd}}"); |
|
0
|
|
|
|
|
|
|
148
|
0
|
0
|
|
|
|
|
if($self->out ne '') |
149
|
|
|
|
|
|
|
{ |
150
|
0
|
|
|
|
|
|
$ctx->diag("[out]"); |
151
|
0
|
|
|
|
|
|
$ctx->diag(" $_") for split /\r?\n/, $self->out; |
152
|
|
|
|
|
|
|
} |
153
|
0
|
0
|
|
|
|
|
if($self->err ne '') |
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
|
|
|
|
|
|
|
1; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
__END__ |