line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::SharedFork; |
2
|
31
|
|
|
31
|
|
665666
|
use strict; |
|
31
|
|
|
|
|
81
|
|
|
31
|
|
|
|
|
874
|
|
3
|
31
|
|
|
31
|
|
145
|
use warnings; |
|
31
|
|
|
|
|
72
|
|
|
31
|
|
|
|
|
919
|
|
4
|
31
|
|
|
31
|
|
148
|
use base 'Test::Builder::Module'; |
|
31
|
|
|
|
|
66
|
|
|
31
|
|
|
|
|
4060
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.35'; |
6
|
31
|
|
|
31
|
|
177
|
use Test::Builder 0.32; # 0.32 or later is needed |
|
31
|
|
|
|
|
659
|
|
|
31
|
|
|
|
|
682
|
|
7
|
31
|
|
|
31
|
|
16044
|
use Test::SharedFork::Scalar; |
|
31
|
|
|
|
|
84
|
|
|
31
|
|
|
|
|
862
|
|
8
|
31
|
|
|
31
|
|
16075
|
use Test::SharedFork::Array; |
|
31
|
|
|
|
|
110
|
|
|
31
|
|
|
|
|
1073
|
|
9
|
31
|
|
|
31
|
|
18311
|
use Test::SharedFork::Store; |
|
31
|
|
|
|
|
97
|
|
|
31
|
|
|
|
|
1027
|
|
10
|
31
|
|
|
31
|
|
159
|
use Config; |
|
31
|
|
|
|
|
60
|
|
|
31
|
|
|
|
|
1132
|
|
11
|
31
|
|
|
31
|
|
647
|
use 5.008000; |
|
31
|
|
|
|
|
152
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
package # |
15
|
|
|
|
|
|
|
Test::SharedFork::Contextual; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub call { |
18
|
0
|
|
|
0
|
|
0
|
my $code = shift; |
19
|
0
|
|
|
|
|
0
|
my $wantarray = [caller(1)]->[5]; |
20
|
0
|
0
|
|
|
|
0
|
if ($wantarray) { |
|
|
0
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
my @result = $code->(); |
22
|
0
|
|
|
|
|
0
|
bless {result => \@result, wantarray => $wantarray}, __PACKAGE__; |
23
|
|
|
|
|
|
|
} elsif (defined $wantarray) { |
24
|
0
|
|
|
|
|
0
|
my $result = $code->(); |
25
|
0
|
|
|
|
|
0
|
bless {result => $result, wantarray => $wantarray}, __PACKAGE__; |
26
|
|
|
|
|
|
|
} else { |
27
|
0
|
|
|
|
|
0
|
{ ; $code->(); } # void context |
|
0
|
|
|
|
|
0
|
|
28
|
0
|
|
|
|
|
0
|
bless {wantarray => $wantarray}, __PACKAGE__; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub result { |
33
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
34
|
0
|
0
|
|
|
|
0
|
if ($self->{wantarray}) { |
|
|
0
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
return @{ $self->{result} }; |
|
0
|
|
|
|
|
0
|
|
36
|
|
|
|
|
|
|
} elsif (defined $self->{wantarray}) { |
37
|
0
|
|
|
|
|
0
|
return $self->{result}; |
38
|
|
|
|
|
|
|
} else { |
39
|
0
|
|
|
|
|
0
|
return; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $STORE; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _mangle_builder { |
47
|
35
|
|
|
35
|
|
1363
|
my $builder = shift; |
48
|
|
|
|
|
|
|
|
49
|
35
|
0
|
33
|
|
|
645
|
if( $] >= 5.008001 && $Config{useithreads} && $INC{'threads.pm'} ) { |
|
|
|
33
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
die "# Current version of Test::SharedFork does not supports ithreads."; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
35
|
50
|
33
|
|
|
877
|
if ($builder->can("coordinate_forks")) { |
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Use Test::Builder's implementation. |
55
|
0
|
|
|
|
|
0
|
$builder->new->coordinate_forks(1); |
56
|
|
|
|
|
|
|
} elsif($INC{'Test2/Global.pm'} || $INC{'Test2/API.pm'} || $INC{'Test2/Context.pm'}) { |
57
|
0
|
|
|
|
|
0
|
require Test2::Global; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
0
|
Test2::Global::test2_ipc_enable_polling(); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Check if we already have IPC |
62
|
0
|
|
|
|
|
0
|
my $stack = $builder->{Stack}; |
63
|
0
|
0
|
|
|
|
0
|
return if $stack->top->ipc; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Find a driver |
66
|
0
|
|
|
|
|
0
|
my ($driver) = Test2::Global::test2_ipc_drivers(); |
67
|
0
|
0
|
|
|
|
0
|
unless ($driver) { |
68
|
0
|
|
|
|
|
0
|
require Test2::IPC::Driver::Files; |
69
|
0
|
|
|
|
|
0
|
$driver = 'Test2::IPC::Driver::Files'; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Add the IPC to all hubs |
73
|
0
|
|
|
|
|
0
|
my $ipc = $driver->new(); |
74
|
0
|
|
|
|
|
0
|
for my $hub (@$stack) { |
75
|
0
|
|
|
|
|
0
|
$hub->set_ipc($ipc); |
76
|
0
|
|
|
|
|
0
|
$ipc->add_hub($hub->hid); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} elsif($INC{'Test/Stream/Sync.pm'}) { |
79
|
0
|
|
|
|
|
0
|
require Test::Stream::IPC; |
80
|
0
|
|
|
|
|
0
|
Test::Stream::IPC->import('poll'); |
81
|
0
|
0
|
|
|
|
0
|
Test::Stream::IPC->enable_polling if Test::Stream::IPC->can('enable_polling'); |
82
|
0
|
|
|
|
|
0
|
my $stack = $builder->{Stack}; |
83
|
0
|
0
|
|
|
|
0
|
return if $stack->top->ipc; |
84
|
0
|
|
|
|
|
0
|
my ($driver) = Test::Stream::IPC->drivers; |
85
|
0
|
|
|
|
|
0
|
my $ipc = $driver->new(); |
86
|
0
|
|
|
|
|
0
|
for my $hub (@$stack) { |
87
|
0
|
|
|
|
|
0
|
$hub->set_ipc($ipc); |
88
|
0
|
|
|
|
|
0
|
$ipc->add_hub($hub->hid); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} else { |
91
|
|
|
|
|
|
|
# older Test::Builder |
92
|
|
|
|
|
|
|
$STORE = Test::SharedFork::Store->new( |
93
|
|
|
|
|
|
|
cb => sub { |
94
|
54
|
|
|
54
|
|
94
|
my $store = shift; |
95
|
54
|
|
|
|
|
1993
|
tie $builder->{Curr_Test}, 'Test::SharedFork::Scalar', |
96
|
|
|
|
|
|
|
$store, 'Curr_Test'; |
97
|
54
|
|
|
|
|
279
|
tie $builder->{Is_Passing}, 'Test::SharedFork::Scalar', |
98
|
|
|
|
|
|
|
$store, 'Is_Passing'; |
99
|
54
|
|
|
|
|
105
|
tie @{ $builder->{Test_Results} }, |
|
54
|
|
|
|
|
1341
|
|
100
|
|
|
|
|
|
|
'Test::SharedFork::Array', $store, 'Test_Results'; |
101
|
|
|
|
|
|
|
}, |
102
|
|
|
|
|
|
|
init => +{ |
103
|
|
|
|
|
|
|
Test_Results => $builder->{Test_Results}, |
104
|
|
|
|
|
|
|
Curr_Test => $builder->{Curr_Test}, |
105
|
35
|
|
|
|
|
462
|
Is_Passing => 1, |
106
|
|
|
|
|
|
|
}, |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# make methods atomic. |
110
|
31
|
|
|
31
|
|
182
|
no strict 'refs'; |
|
31
|
|
|
|
|
51
|
|
|
31
|
|
|
|
|
1081
|
|
111
|
31
|
|
|
31
|
|
150
|
no warnings 'redefine'; |
|
31
|
|
|
|
|
51
|
|
|
31
|
|
|
|
|
1728
|
|
112
|
31
|
|
|
31
|
|
164
|
no warnings 'uninitialized'; |
|
31
|
|
|
|
|
44
|
|
|
31
|
|
|
|
|
7001
|
|
113
|
35
|
|
|
|
|
126
|
for my $name (qw/ok skip todo_skip current_test is_passing/) { |
114
|
175
|
|
|
|
|
220
|
my $orig = *{"Test::Builder::${name}"}{CODE}; |
|
175
|
|
|
|
|
633
|
|
115
|
175
|
|
|
|
|
3013
|
*{"Test::Builder::${name}"} = sub { |
116
|
312
|
|
|
312
|
|
116074840
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
117
|
312
|
|
|
|
|
3314
|
local $Test::Builder::BLevel = $Test::Builder::BLevel + 1; |
118
|
312
|
|
|
|
|
4547
|
my $lock = $STORE->get_lock(); # RAII |
119
|
312
|
|
|
|
|
3568
|
$orig->(@_); |
120
|
175
|
|
|
|
|
645
|
}; |
121
|
|
|
|
|
|
|
}; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
BEGIN { |
126
|
31
|
|
|
31
|
|
476
|
my $builder = __PACKAGE__->builder; |
127
|
31
|
|
|
|
|
463
|
_mangle_builder($builder); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
{ |
131
|
|
|
|
|
|
|
# backward compatibility method |
132
|
|
|
|
1
|
0
|
|
sub parent { } |
133
|
|
|
|
1
|
0
|
|
sub child { } |
134
|
74
|
|
|
74
|
0
|
1232220
|
sub fork { fork() } |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
138
|
|
|
|
|
|
|
__END__ |