line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::AsyncSubtest; |
2
|
27
|
|
|
27
|
|
92512
|
use strict; |
|
27
|
|
|
|
|
84
|
|
|
27
|
|
|
|
|
859
|
|
3
|
27
|
|
|
27
|
|
321
|
use warnings; |
|
27
|
|
|
|
|
55
|
|
|
27
|
|
|
|
|
1100
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
6
|
|
|
|
|
|
|
|
7
|
27
|
|
|
27
|
|
4235
|
use Test2::IPC; |
|
27
|
|
|
|
|
10035
|
|
|
27
|
|
|
|
|
146
|
|
8
|
27
|
|
|
27
|
|
6318
|
use Test2::AsyncSubtest; |
|
27
|
|
|
|
|
59
|
|
|
27
|
|
|
|
|
1160
|
|
9
|
27
|
|
|
27
|
|
176
|
use Test2::API qw/context/; |
|
27
|
|
|
|
|
51
|
|
|
27
|
|
|
|
|
1492
|
|
10
|
27
|
|
|
27
|
|
180
|
use Carp qw/croak/; |
|
27
|
|
|
|
|
99
|
|
|
27
|
|
|
|
|
2242
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw/async_subtest fork_subtest thread_subtest/; |
13
|
27
|
|
|
27
|
|
181
|
use base 'Exporter'; |
|
27
|
|
|
|
|
58
|
|
|
27
|
|
|
|
|
13512
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub async_subtest { |
16
|
16
|
|
|
16
|
1
|
58962
|
my $name = shift; |
17
|
16
|
|
|
|
|
60
|
my ($params, $code); |
18
|
16
|
50
|
66
|
|
|
155
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
19
|
16
|
100
|
66
|
|
|
185
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
20
|
|
|
|
|
|
|
|
21
|
16
|
|
|
|
|
85
|
my $ctx = context(); |
22
|
|
|
|
|
|
|
|
23
|
16
|
|
|
|
|
4268
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
24
|
|
|
|
|
|
|
|
25
|
16
|
100
|
|
|
|
423
|
$subtest->run($code, $subtest) if $code; |
26
|
|
|
|
|
|
|
|
27
|
16
|
|
|
|
|
207
|
$ctx->release; |
28
|
16
|
|
|
|
|
545
|
return $subtest; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub fork_subtest { |
32
|
165
|
|
|
165
|
1
|
92687
|
my $name = shift; |
33
|
165
|
|
|
|
|
471
|
my ($params, $code); |
34
|
165
|
100
|
100
|
|
|
3053
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
35
|
165
|
100
|
66
|
|
|
1756
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
36
|
|
|
|
|
|
|
|
37
|
165
|
|
|
|
|
3071
|
my $ctx = context(); |
38
|
|
|
|
|
|
|
|
39
|
165
|
100
|
|
|
|
92561
|
croak "fork_subtest requires a CODE reference as the second argument" |
40
|
|
|
|
|
|
|
unless ref($code) eq 'CODE'; |
41
|
|
|
|
|
|
|
|
42
|
164
|
|
|
|
|
3264
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
43
|
|
|
|
|
|
|
|
44
|
164
|
|
|
|
|
7211
|
$subtest->run_fork($code, $subtest); |
45
|
|
|
|
|
|
|
|
46
|
143
|
|
|
|
|
7969
|
$ctx->release; |
47
|
143
|
|
|
|
|
28335
|
return $subtest; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub thread_subtest { |
51
|
1
|
|
|
1
|
1
|
19
|
my $name = shift; |
52
|
1
|
|
|
|
|
4
|
my ($params, $code); |
53
|
1
|
50
|
33
|
|
|
6
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
54
|
1
|
50
|
33
|
|
|
6
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
4
|
my $ctx = context(); |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
361
|
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__ |