line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Alien::Run; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
904
|
use strict; |
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
54
|
|
4
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
50
|
|
5
|
2
|
|
|
2
|
|
7
|
use Test2::API qw( context ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
2164
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Run object |
8
|
|
|
|
|
|
|
our $VERSION = '0.14'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
7
|
|
|
7
|
1
|
9409
|
sub out { shift->{out} } |
12
|
7
|
|
|
7
|
1
|
36
|
sub err { shift->{err} } |
13
|
27
|
|
|
27
|
1
|
103
|
sub exit { shift->{exit} } |
14
|
14
|
|
|
14
|
1
|
79
|
sub signal { shift->{sig} } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub success |
18
|
|
|
|
|
|
|
{ |
19
|
5
|
|
|
5
|
1
|
843
|
my($self, $message) = @_; |
20
|
5
|
|
50
|
|
|
38
|
$message ||= 'command succeeded'; |
21
|
5
|
|
100
|
|
|
12
|
my $ok = $self->exit == 0 && $self->signal == 0; |
22
|
5
|
100
|
|
|
|
22
|
$ok = 0 if $self->{fail}; |
23
|
|
|
|
|
|
|
|
24
|
5
|
|
|
|
|
18
|
my $ctx = context(); |
25
|
5
|
|
|
|
|
328
|
$ctx->ok($ok, $message); |
26
|
5
|
100
|
|
|
|
508
|
unless($ok) |
27
|
|
|
|
|
|
|
{ |
28
|
4
|
100
|
|
|
|
12
|
$ctx->diag(" command exited with @{[ $self->exit ]}") if $self->exit; |
|
1
|
|
|
|
|
4
|
|
29
|
4
|
100
|
|
|
|
43
|
$ctx->diag(" command killed with @{[ $self->signal ]}") if $self->signal; |
|
1
|
|
|
|
|
10
|
|
30
|
4
|
100
|
|
|
|
67
|
$ctx->diag(" @{[ $self->{fail} ]}") if $self->{fail}; |
|
2
|
|
|
|
|
17
|
|
31
|
|
|
|
|
|
|
} |
32
|
5
|
|
|
|
|
122
|
$ctx->release; |
33
|
5
|
|
|
|
|
83
|
$self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub exit_is |
38
|
|
|
|
|
|
|
{ |
39
|
4
|
|
|
4
|
1
|
4393
|
my($self, $exit, $message) = @_; |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
33
|
|
|
22
|
$message ||= "command exited with value $exit"; |
42
|
4
|
|
|
|
|
6
|
my $ok = $self->exit == $exit; |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
9
|
my $ctx = context(); |
45
|
4
|
|
|
|
|
188
|
$ctx->ok($ok, $message); |
46
|
4
|
100
|
|
|
|
263
|
$ctx->diag(" actual exit value was: @{[ $self->exit ]}") unless $ok; |
|
2
|
|
|
|
|
5
|
|
47
|
4
|
|
|
|
|
71
|
$ctx->release; |
48
|
4
|
|
|
|
|
50
|
$self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub exit_isnt |
53
|
|
|
|
|
|
|
{ |
54
|
4
|
|
|
4
|
1
|
4362
|
my($self, $exit, $message) = @_; |
55
|
|
|
|
|
|
|
|
56
|
4
|
|
33
|
|
|
22
|
$message ||= "command exited with value not $exit"; |
57
|
4
|
|
|
|
|
6
|
my $ok = $self->exit != $exit; |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
|
|
7
|
my $ctx = context(); |
60
|
4
|
|
|
|
|
182
|
$ctx->ok($ok, $message); |
61
|
4
|
100
|
|
|
|
227
|
$ctx->diag(" actual exit value was: @{[ $self->exit ]}") unless $ok; |
|
2
|
|
|
|
|
5
|
|
62
|
4
|
|
|
|
|
71
|
$ctx->release; |
63
|
4
|
|
|
|
|
53
|
$self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _like |
68
|
|
|
|
|
|
|
{ |
69
|
6
|
|
|
6
|
|
10
|
my($self, $regex, $source, $not, $message) = @_; |
70
|
|
|
|
|
|
|
|
71
|
6
|
|
|
|
|
29
|
my $ok = $self->{$source} =~ $regex; |
72
|
6
|
100
|
|
|
|
12
|
$ok = !$ok if $not; |
73
|
|
|
|
|
|
|
|
74
|
6
|
|
|
|
|
12
|
my $ctx = context(); |
75
|
6
|
|
|
|
|
291
|
$ctx->ok($ok, $message); |
76
|
6
|
100
|
|
|
|
284
|
unless($ok) |
77
|
|
|
|
|
|
|
{ |
78
|
2
|
|
|
|
|
6
|
$ctx->diag(" $source:"); |
79
|
2
|
|
|
|
|
72
|
$ctx->diag(" $_") for split /\r?\n/, $self->{$source}; |
80
|
2
|
100
|
|
|
|
69
|
$ctx->diag($not ? ' matches:' : ' does not match:'); |
81
|
2
|
|
|
|
|
64
|
$ctx->diag(" $regex"); |
82
|
|
|
|
|
|
|
} |
83
|
6
|
|
|
|
|
69
|
$ctx->release; |
84
|
|
|
|
|
|
|
|
85
|
6
|
|
|
|
|
77
|
$self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub out_like |
89
|
|
|
|
|
|
|
{ |
90
|
2
|
|
|
2
|
1
|
1692
|
my($self, $regex, $message) = @_; |
91
|
2
|
|
33
|
|
|
12
|
$message ||= "output matches $regex"; |
92
|
2
|
|
|
|
|
4
|
$self->_like($regex, 'out', 0, $message); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub out_unlike |
97
|
|
|
|
|
|
|
{ |
98
|
2
|
|
|
2
|
1
|
4594
|
my($self, $regex, $message) = @_; |
99
|
2
|
|
33
|
|
|
14
|
$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
|
845
|
my($self, $regex, $message) = @_; |
107
|
1
|
|
33
|
|
|
6
|
$message ||= "standard error matches $regex"; |
108
|
1
|
|
|
|
|
4
|
$self->_like($regex, 'err', 0, $message); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub err_unlike |
113
|
|
|
|
|
|
|
{ |
114
|
1
|
|
|
1
|
1
|
796
|
my($self, $regex, $message) = @_; |
115
|
1
|
|
33
|
|
|
6
|
$message ||= "standard error does not match $regex"; |
116
|
1
|
|
|
|
|
3
|
$self->_like($regex, 'err', 1, $message); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub note |
121
|
|
|
|
|
|
|
{ |
122
|
1
|
|
|
1
|
1
|
1880
|
my($self) = @_; |
123
|
1
|
|
|
|
|
5
|
my $ctx = context(); |
124
|
1
|
|
|
|
|
51
|
$ctx->note("[cmd]"); |
125
|
1
|
|
|
|
|
57
|
$ctx->note(" @{$self->{cmd}}"); |
|
1
|
|
|
|
|
7
|
|
126
|
1
|
50
|
|
|
|
51
|
if($self->out ne '') |
127
|
|
|
|
|
|
|
{ |
128
|
1
|
|
|
|
|
3
|
$ctx->note("[out]"); |
129
|
1
|
|
|
|
|
47
|
$ctx->note(" $_") for split /\r?\n/, $self->out; |
130
|
|
|
|
|
|
|
} |
131
|
1
|
50
|
|
|
|
47
|
if($self->err ne '') |
132
|
|
|
|
|
|
|
{ |
133
|
1
|
|
|
|
|
4
|
$ctx->note("[err]"); |
134
|
1
|
|
|
|
|
45
|
$ctx->note(" $_") for split /\r?\n/, $self->err; |
135
|
|
|
|
|
|
|
} |
136
|
1
|
|
|
|
|
44
|
$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__ |