line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::AsyncSubtest; |
2
|
27
|
|
|
27
|
|
85925
|
use strict; |
|
27
|
|
|
|
|
101
|
|
|
27
|
|
|
|
|
809
|
|
3
|
27
|
|
|
27
|
|
133
|
use warnings; |
|
27
|
|
|
|
|
74
|
|
|
27
|
|
|
|
|
1091
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
6
|
|
|
|
|
|
|
|
7
|
27
|
|
|
27
|
|
4151
|
use Test2::IPC; |
|
27
|
|
|
|
|
8910
|
|
|
27
|
|
|
|
|
183
|
|
8
|
27
|
|
|
27
|
|
5986
|
use Test2::AsyncSubtest; |
|
27
|
|
|
|
|
324
|
|
|
27
|
|
|
|
|
819
|
|
9
|
27
|
|
|
27
|
|
181
|
use Test2::API qw/context/; |
|
27
|
|
|
|
|
99
|
|
|
27
|
|
|
|
|
1510
|
|
10
|
27
|
|
|
27
|
|
201
|
use Carp qw/croak/; |
|
27
|
|
|
|
|
61
|
|
|
27
|
|
|
|
|
1824
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw/async_subtest fork_subtest thread_subtest/; |
13
|
27
|
|
|
27
|
|
217
|
use base 'Exporter'; |
|
27
|
|
|
|
|
60
|
|
|
27
|
|
|
|
|
12701
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub async_subtest { |
16
|
16
|
|
|
16
|
1
|
42583
|
my $name = shift; |
17
|
16
|
|
|
|
|
48
|
my ($params, $code); |
18
|
16
|
50
|
66
|
|
|
128
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
19
|
16
|
100
|
66
|
|
|
111
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
20
|
|
|
|
|
|
|
|
21
|
16
|
|
|
|
|
100
|
my $ctx = context(); |
22
|
|
|
|
|
|
|
|
23
|
16
|
|
|
|
|
3842
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
24
|
|
|
|
|
|
|
|
25
|
16
|
100
|
|
|
|
435
|
$subtest->run($code, $subtest) if $code; |
26
|
|
|
|
|
|
|
|
27
|
16
|
|
|
|
|
363
|
$ctx->release; |
28
|
16
|
|
|
|
|
457
|
return $subtest; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub fork_subtest { |
32
|
165
|
|
|
165
|
1
|
97454
|
my $name = shift; |
33
|
165
|
|
|
|
|
479
|
my ($params, $code); |
34
|
165
|
100
|
100
|
|
|
3080
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
35
|
165
|
100
|
66
|
|
|
1269
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
36
|
|
|
|
|
|
|
|
37
|
165
|
|
|
|
|
3049
|
my $ctx = context(); |
38
|
|
|
|
|
|
|
|
39
|
165
|
100
|
|
|
|
100614
|
croak "fork_subtest requires a CODE reference as the second argument" |
40
|
|
|
|
|
|
|
unless ref($code) eq 'CODE'; |
41
|
|
|
|
|
|
|
|
42
|
164
|
|
|
|
|
3571
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
43
|
|
|
|
|
|
|
|
44
|
164
|
|
|
|
|
6997
|
$subtest->run_fork($code, $subtest); |
45
|
|
|
|
|
|
|
|
46
|
143
|
|
|
|
|
8481
|
$ctx->release; |
47
|
143
|
|
|
|
|
29108
|
return $subtest; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub thread_subtest { |
51
|
1
|
|
|
1
|
1
|
14
|
my $name = shift; |
52
|
1
|
|
|
|
|
6
|
my ($params, $code); |
53
|
1
|
50
|
33
|
|
|
5
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
54
|
1
|
50
|
33
|
|
|
10
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
7
|
my $ctx = context(); |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
352
|
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__ |