line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::AsyncSubtest; |
2
|
27
|
|
|
27
|
|
83942
|
use strict; |
|
27
|
|
|
|
|
67
|
|
|
27
|
|
|
|
|
688
|
|
3
|
27
|
|
|
27
|
|
115
|
use warnings; |
|
27
|
|
|
|
|
54
|
|
|
27
|
|
|
|
|
901
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
6
|
|
|
|
|
|
|
|
7
|
27
|
|
|
27
|
|
3570
|
use Test2::IPC; |
|
27
|
|
|
|
|
8207
|
|
|
27
|
|
|
|
|
125
|
|
8
|
27
|
|
|
27
|
|
5265
|
use Test2::AsyncSubtest; |
|
27
|
|
|
|
|
56
|
|
|
27
|
|
|
|
|
805
|
|
9
|
27
|
|
|
27
|
|
244
|
use Test2::API qw/context/; |
|
27
|
|
|
|
|
69
|
|
|
27
|
|
|
|
|
1220
|
|
10
|
27
|
|
|
27
|
|
137
|
use Carp qw/croak/; |
|
27
|
|
|
|
|
55
|
|
|
27
|
|
|
|
|
1462
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw/async_subtest fork_subtest thread_subtest/; |
13
|
27
|
|
|
27
|
|
160
|
use base 'Exporter'; |
|
27
|
|
|
|
|
148
|
|
|
27
|
|
|
|
|
10456
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub async_subtest { |
16
|
16
|
|
|
16
|
1
|
42401
|
my $name = shift; |
17
|
16
|
|
|
|
|
50
|
my ($params, $code); |
18
|
16
|
50
|
66
|
|
|
131
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
19
|
16
|
100
|
66
|
|
|
108
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
20
|
|
|
|
|
|
|
|
21
|
16
|
|
|
|
|
58
|
my $ctx = context(); |
22
|
|
|
|
|
|
|
|
23
|
16
|
|
|
|
|
3548
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
24
|
|
|
|
|
|
|
|
25
|
16
|
100
|
|
|
|
409
|
$subtest->run($code, $subtest) if $code; |
26
|
|
|
|
|
|
|
|
27
|
16
|
|
|
|
|
171
|
$ctx->release; |
28
|
16
|
|
|
|
|
467
|
return $subtest; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub fork_subtest { |
32
|
165
|
|
|
165
|
1
|
72687
|
my $name = shift; |
33
|
165
|
|
|
|
|
399
|
my ($params, $code); |
34
|
165
|
100
|
100
|
|
|
2078
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
35
|
165
|
100
|
66
|
|
|
1751
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
36
|
|
|
|
|
|
|
|
37
|
165
|
|
|
|
|
2171
|
my $ctx = context(); |
38
|
|
|
|
|
|
|
|
39
|
165
|
100
|
|
|
|
70458
|
croak "fork_subtest requires a CODE reference as the second argument" |
40
|
|
|
|
|
|
|
unless ref($code) eq 'CODE'; |
41
|
|
|
|
|
|
|
|
42
|
164
|
|
|
|
|
2475
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
43
|
|
|
|
|
|
|
|
44
|
164
|
|
|
|
|
6839
|
$subtest->run_fork($code, $subtest); |
45
|
|
|
|
|
|
|
|
46
|
143
|
|
|
|
|
6608
|
$ctx->release; |
47
|
143
|
|
|
|
|
21600
|
return $subtest; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub thread_subtest { |
51
|
1
|
|
|
1
|
1
|
15
|
my $name = shift; |
52
|
1
|
|
|
|
|
3
|
my ($params, $code); |
53
|
1
|
50
|
33
|
|
|
6
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
54
|
1
|
50
|
33
|
|
|
7
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
6
|
my $ctx = context(); |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
332
|
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__ |