line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Exec; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
812741
|
use strict; |
|
5
|
|
|
|
|
37
|
|
|
5
|
|
|
|
|
158
|
|
4
|
5
|
|
|
5
|
|
29
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
123
|
|
5
|
5
|
|
|
5
|
|
140
|
use 5.010; |
|
5
|
|
|
|
|
19
|
|
6
|
5
|
|
|
5
|
|
32
|
use Test2::API qw( context ); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
247
|
|
7
|
5
|
|
|
5
|
|
2025
|
use Test2::Tools::Process (); |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
143
|
|
8
|
5
|
|
|
5
|
|
34
|
use Test2::Tools::Process::ReturnMultiLevel qw( with_return ); |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
311
|
|
9
|
5
|
|
|
5
|
|
30
|
use base 'Exporter'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
1874
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Test that some code calls exec without terminating testing |
12
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw( exec_arrayref never_exec_ok ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $last; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub exec_arrayref(&) |
21
|
|
|
|
|
|
|
{ |
22
|
10
|
|
|
10
|
1
|
413
|
my($code) = @_; |
23
|
|
|
|
|
|
|
|
24
|
10
|
|
|
|
|
23
|
undef $last; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
return with_return { |
27
|
10
|
|
|
10
|
|
25
|
my($return) = @_; |
28
|
|
|
|
|
|
|
local $Test2::Tools::Process::handlers{exec} = sub { |
29
|
6
|
|
|
|
|
53
|
$last = [caller(1)]; |
30
|
6
|
|
|
|
|
31
|
$return->([@_]); |
31
|
10
|
|
|
|
|
47
|
}; |
32
|
10
|
|
|
|
|
33
|
$code->(); |
33
|
4
|
|
|
|
|
957
|
undef; |
34
|
10
|
|
|
|
|
68
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub never_exec_ok (&;$) |
39
|
|
|
|
|
|
|
{ |
40
|
3
|
|
|
3
|
1
|
53079
|
my($code, $name) = @_; |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
100
|
|
|
18
|
$name ||= 'does not call exec'; |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
3
|
|
16
|
my $ret = exec_arrayref { $code->() }; |
|
3
|
|
|
|
|
10
|
|
45
|
3
|
|
|
|
|
16
|
my $ok = !defined $ret; |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
10
|
my $ctx = context(); |
48
|
3
|
|
|
|
|
269
|
$ctx->ok($ok, $name); |
49
|
|
|
|
|
|
|
|
50
|
3
|
100
|
66
|
|
|
589
|
if(!$ok && $last) |
51
|
|
|
|
|
|
|
{ |
52
|
1
|
|
|
|
|
40
|
my(undef, $filename, $line) = @$last; |
53
|
1
|
|
|
|
|
10
|
$ctx->diag("exec at $filename line $line"); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
|
|
209
|
$ctx->release; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |