line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::AsyncSubtest; |
2
|
25
|
|
|
25
|
|
1086536
|
use strict; |
|
25
|
|
|
|
|
90
|
|
|
25
|
|
|
|
|
881
|
|
3
|
25
|
|
|
25
|
|
175
|
use warnings; |
|
25
|
|
|
|
|
50
|
|
|
25
|
|
|
|
|
1108
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000020'; |
6
|
|
|
|
|
|
|
|
7
|
25
|
|
|
25
|
|
1602
|
use Test2::IPC; |
|
25
|
|
|
|
|
3965
|
|
|
25
|
|
|
|
|
181
|
|
8
|
25
|
|
|
25
|
|
3391
|
use Test2::AsyncSubtest; |
|
25
|
|
|
|
|
75
|
|
|
25
|
|
|
|
|
932
|
|
9
|
25
|
|
|
25
|
|
189
|
use Test2::API qw/context/; |
|
25
|
|
|
|
|
49
|
|
|
25
|
|
|
|
|
1515
|
|
10
|
25
|
|
|
25
|
|
181
|
use Carp qw/croak/; |
|
25
|
|
|
|
|
68
|
|
|
25
|
|
|
|
|
1701
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw/async_subtest fork_subtest thread_subtest/; |
13
|
25
|
|
|
25
|
|
164
|
use base 'Exporter'; |
|
25
|
|
|
|
|
47
|
|
|
25
|
|
|
|
|
11832
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub async_subtest { |
16
|
14
|
|
|
14
|
1
|
164242
|
my $name = shift; |
17
|
14
|
|
|
|
|
37
|
my ($params, $code); |
18
|
14
|
50
|
66
|
|
|
92
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
19
|
14
|
100
|
66
|
|
|
78
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
20
|
|
|
|
|
|
|
|
21
|
14
|
|
|
|
|
44
|
my $ctx = context(); |
22
|
|
|
|
|
|
|
|
23
|
14
|
|
|
|
|
25934
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
24
|
|
|
|
|
|
|
|
25
|
14
|
100
|
|
|
|
228
|
$subtest->run($code, $subtest) if $code; |
26
|
|
|
|
|
|
|
|
27
|
14
|
|
|
|
|
135
|
$ctx->release; |
28
|
14
|
|
|
|
|
307
|
return $subtest; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub fork_subtest { |
32
|
165
|
|
|
165
|
1
|
1057038
|
my $name = shift; |
33
|
165
|
|
|
|
|
724
|
my ($params, $code); |
34
|
165
|
100
|
100
|
|
|
2352
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
35
|
165
|
100
|
66
|
|
|
1183
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
36
|
|
|
|
|
|
|
|
37
|
165
|
|
|
|
|
1928
|
my $ctx = context(); |
38
|
|
|
|
|
|
|
|
39
|
165
|
100
|
|
|
|
69506
|
croak "fork_subtest requires a CODE reference as the second argument" |
40
|
|
|
|
|
|
|
unless ref($code) eq 'CODE'; |
41
|
|
|
|
|
|
|
|
42
|
164
|
|
|
|
|
2701
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
43
|
|
|
|
|
|
|
|
44
|
164
|
|
|
|
|
4930
|
$subtest->run_fork($code, $subtest); |
45
|
|
|
|
|
|
|
|
46
|
143
|
|
|
|
|
5263
|
$ctx->release; |
47
|
143
|
|
|
|
|
22495
|
return $subtest; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub thread_subtest { |
51
|
1
|
|
|
1
|
1
|
450
|
my $name = shift; |
52
|
1
|
|
|
|
|
2
|
my ($params, $code); |
53
|
1
|
50
|
33
|
|
|
5
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
54
|
1
|
50
|
33
|
|
|
6
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
5
|
my $ctx = context(); |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
169
|
croak "thread_subtest requires a CODE reference as the second argument" |
59
|
|
|
|
|
|
|
unless ref($code) eq 'CODE'; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$subtest->run_thread($code, $subtest); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$ctx->release; |
66
|
0
|
|
|
|
|
|
return $subtest; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |