line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::AsyncSubtest; |
2
|
25
|
|
|
25
|
|
877518
|
use strict; |
|
25
|
|
|
|
|
48
|
|
|
25
|
|
|
|
|
621
|
|
3
|
25
|
|
|
25
|
|
69
|
use warnings; |
|
25
|
|
|
|
|
47
|
|
|
25
|
|
|
|
|
829
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000018'; |
6
|
|
|
|
|
|
|
|
7
|
25
|
|
|
25
|
|
3311
|
use Test2::IPC; |
|
25
|
|
|
|
|
5217
|
|
|
25
|
|
|
|
|
128
|
|
8
|
25
|
|
|
25
|
|
4292
|
use Test2::AsyncSubtest; |
|
25
|
|
|
|
|
33
|
|
|
25
|
|
|
|
|
647
|
|
9
|
25
|
|
|
25
|
|
103
|
use Test2::API qw/context/; |
|
25
|
|
|
|
|
28
|
|
|
25
|
|
|
|
|
1099
|
|
10
|
25
|
|
|
25
|
|
88
|
use Carp qw/croak/; |
|
25
|
|
|
|
|
28
|
|
|
25
|
|
|
|
|
1324
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw/async_subtest fork_subtest thread_subtest/; |
13
|
25
|
|
|
25
|
|
87
|
use base 'Exporter'; |
|
25
|
|
|
|
|
28
|
|
|
25
|
|
|
|
|
8135
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub async_subtest { |
16
|
14
|
|
|
14
|
1
|
202487
|
my $name = shift; |
17
|
14
|
|
|
|
|
22
|
my ($params, $code); |
18
|
14
|
50
|
66
|
|
|
103
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
19
|
14
|
100
|
66
|
|
|
101
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
20
|
|
|
|
|
|
|
|
21
|
14
|
|
|
|
|
43
|
my $ctx = context(); |
22
|
|
|
|
|
|
|
|
23
|
14
|
|
|
|
|
32647
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
24
|
|
|
|
|
|
|
|
25
|
14
|
100
|
|
|
|
194
|
$subtest->run($code, $subtest) if $code; |
26
|
|
|
|
|
|
|
|
27
|
14
|
|
|
|
|
95
|
$ctx->release; |
28
|
14
|
|
|
|
|
232
|
return $subtest; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub fork_subtest { |
32
|
165
|
|
|
165
|
1
|
657016
|
my $name = shift; |
33
|
165
|
|
|
|
|
266
|
my ($params, $code); |
34
|
165
|
100
|
100
|
|
|
1484
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
35
|
165
|
100
|
66
|
|
|
1648
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
36
|
|
|
|
|
|
|
|
37
|
165
|
|
|
|
|
1533
|
my $ctx = context(); |
38
|
|
|
|
|
|
|
|
39
|
165
|
100
|
|
|
|
31937
|
croak "fork_subtest requires a CODE reference as the second argument" |
40
|
|
|
|
|
|
|
unless ref($code) eq 'CODE'; |
41
|
|
|
|
|
|
|
|
42
|
164
|
|
|
|
|
1795
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
43
|
|
|
|
|
|
|
|
44
|
164
|
|
|
|
|
2383
|
$subtest->run_fork($code, $subtest); |
45
|
|
|
|
|
|
|
|
46
|
143
|
|
|
|
|
3003
|
$ctx->release; |
47
|
143
|
|
|
|
|
13652
|
return $subtest; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub thread_subtest { |
51
|
1
|
|
|
1
|
1
|
455
|
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
|
|
|
4
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
4
|
my $ctx = context(); |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
161
|
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__ |