line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::AsyncSubtest; |
2
|
25
|
|
|
25
|
|
891971
|
use strict; |
|
25
|
|
|
|
|
32
|
|
|
25
|
|
|
|
|
596
|
|
3
|
25
|
|
|
25
|
|
100
|
use warnings; |
|
25
|
|
|
|
|
50
|
|
|
25
|
|
|
|
|
798
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000019'; # TRIAL |
6
|
|
|
|
|
|
|
|
7
|
25
|
|
|
25
|
|
1610
|
use Test2::IPC; |
|
25
|
|
|
|
|
4237
|
|
|
25
|
|
|
|
|
125
|
|
8
|
25
|
|
|
25
|
|
2874
|
use Test2::AsyncSubtest; |
|
25
|
|
|
|
|
51
|
|
|
25
|
|
|
|
|
614
|
|
9
|
25
|
|
|
25
|
|
113
|
use Test2::API qw/context/; |
|
25
|
|
|
|
|
32
|
|
|
25
|
|
|
|
|
901
|
|
10
|
25
|
|
|
25
|
|
101
|
use Carp qw/croak/; |
|
25
|
|
|
|
|
50
|
|
|
25
|
|
|
|
|
1145
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw/async_subtest fork_subtest thread_subtest/; |
13
|
25
|
|
|
25
|
|
128
|
use base 'Exporter'; |
|
25
|
|
|
|
|
50
|
|
|
25
|
|
|
|
|
8360
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub async_subtest { |
16
|
14
|
|
|
14
|
1
|
218340
|
my $name = shift; |
17
|
14
|
|
|
|
|
36
|
my ($params, $code); |
18
|
14
|
50
|
66
|
|
|
100
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
19
|
14
|
100
|
66
|
|
|
76
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
20
|
|
|
|
|
|
|
|
21
|
14
|
|
|
|
|
50
|
my $ctx = context(); |
22
|
|
|
|
|
|
|
|
23
|
14
|
|
|
|
|
29436
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
24
|
|
|
|
|
|
|
|
25
|
14
|
100
|
|
|
|
276
|
$subtest->run($code, $subtest) if $code; |
26
|
|
|
|
|
|
|
|
27
|
14
|
|
|
|
|
181
|
$ctx->release; |
28
|
14
|
|
|
|
|
364
|
return $subtest; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub fork_subtest { |
32
|
165
|
|
|
165
|
1
|
890143
|
my $name = shift; |
33
|
165
|
|
|
|
|
512
|
my ($params, $code); |
34
|
165
|
100
|
100
|
|
|
1756
|
$params = shift(@_) if @_ && ref($_[0]) eq 'HASH'; |
35
|
165
|
100
|
66
|
|
|
1018
|
$code = shift(@_) if @_ && ref($_[0]) eq 'CODE'; |
36
|
|
|
|
|
|
|
|
37
|
165
|
|
|
|
|
1357
|
my $ctx = context(); |
38
|
|
|
|
|
|
|
|
39
|
165
|
100
|
|
|
|
43090
|
croak "fork_subtest requires a CODE reference as the second argument" |
40
|
|
|
|
|
|
|
unless ref($code) eq 'CODE'; |
41
|
|
|
|
|
|
|
|
42
|
164
|
|
|
|
|
2079
|
my $subtest = Test2::AsyncSubtest->new(name => $name, context => 1, hub_init_args => $params); |
43
|
|
|
|
|
|
|
|
44
|
164
|
|
|
|
|
3303
|
$subtest->run_fork($code, $subtest); |
45
|
|
|
|
|
|
|
|
46
|
143
|
|
|
|
|
3613
|
$ctx->release; |
47
|
143
|
|
|
|
|
15594
|
return $subtest; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub thread_subtest { |
51
|
1
|
|
|
1
|
1
|
472
|
my $name = shift; |
52
|
1
|
|
|
|
|
2
|
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
|
|
|
|
|
7
|
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__ |