line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::SharedFork; |
2
|
31
|
|
|
31
|
|
537048
|
use strict; |
|
31
|
|
|
|
|
55
|
|
|
31
|
|
|
|
|
1199
|
|
3
|
31
|
|
|
31
|
|
161
|
use warnings; |
|
31
|
|
|
|
|
38
|
|
|
31
|
|
|
|
|
915
|
|
4
|
31
|
|
|
31
|
|
136
|
use base 'Test::Builder::Module'; |
|
31
|
|
|
|
|
42
|
|
|
31
|
|
|
|
|
3836
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.33'; |
6
|
31
|
|
|
31
|
|
200
|
use Test::Builder 0.32; # 0.32 or later is needed |
|
31
|
|
|
|
|
658
|
|
|
31
|
|
|
|
|
847
|
|
7
|
31
|
|
|
31
|
|
11466
|
use Test::SharedFork::Scalar; |
|
31
|
|
|
|
|
76
|
|
|
31
|
|
|
|
|
880
|
|
8
|
31
|
|
|
31
|
|
11322
|
use Test::SharedFork::Array; |
|
31
|
|
|
|
|
74
|
|
|
31
|
|
|
|
|
864
|
|
9
|
31
|
|
|
31
|
|
13198
|
use Test::SharedFork::Store; |
|
31
|
|
|
|
|
76
|
|
|
31
|
|
|
|
|
994
|
|
10
|
31
|
|
|
31
|
|
180
|
use Config; |
|
31
|
|
|
|
|
58
|
|
|
31
|
|
|
|
|
1201
|
|
11
|
31
|
|
|
31
|
|
633
|
use 5.008000; |
|
31
|
|
|
|
|
93
|
|
|
31
|
|
|
|
|
13171
|
|
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
|
|
1188
|
my $builder = shift; |
48
|
|
|
|
|
|
|
|
49
|
35
|
50
|
33
|
|
|
825
|
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
|
|
|
|
442
|
if ($builder->can("coordinate_forks")) { |
|
|
50
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Use Test::Builder's implementation. |
55
|
0
|
|
|
|
|
0
|
$builder->new->coordinate_forks(1); |
56
|
|
|
|
|
|
|
} elsif($INC{'Test/Stream/Sync.pm'}) { |
57
|
0
|
|
|
|
|
0
|
require Test::Stream::IPC; |
58
|
0
|
|
|
|
|
0
|
Test::Stream::IPC->import('poll'); |
59
|
0
|
|
|
|
|
0
|
my $stack = $builder->{Stack}; |
60
|
0
|
0
|
|
|
|
0
|
return if $stack->top->ipc; |
61
|
0
|
|
|
|
|
0
|
my ($driver) = Test::Stream::IPC->drivers; |
62
|
0
|
|
|
|
|
0
|
my $ipc = $driver->new(); |
63
|
0
|
|
|
|
|
0
|
for my $hub (@$stack) { |
64
|
0
|
|
|
|
|
0
|
$hub->set_ipc($ipc); |
65
|
0
|
|
|
|
|
0
|
$ipc->add_hub($hub->hid); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} else { |
68
|
|
|
|
|
|
|
# older Test::Builder |
69
|
|
|
|
|
|
|
$STORE = Test::SharedFork::Store->new( |
70
|
|
|
|
|
|
|
cb => sub { |
71
|
54
|
|
|
54
|
|
69
|
my $store = shift; |
72
|
54
|
|
|
|
|
926
|
tie $builder->{Curr_Test}, 'Test::SharedFork::Scalar', |
73
|
|
|
|
|
|
|
$store, 'Curr_Test'; |
74
|
54
|
|
|
|
|
226
|
tie $builder->{Is_Passing}, 'Test::SharedFork::Scalar', |
75
|
|
|
|
|
|
|
$store, 'Is_Passing'; |
76
|
54
|
|
|
|
|
93
|
tie @{ $builder->{Test_Results} }, |
|
54
|
|
|
|
|
677
|
|
77
|
|
|
|
|
|
|
'Test::SharedFork::Array', $store, 'Test_Results'; |
78
|
|
|
|
|
|
|
}, |
79
|
35
|
|
|
|
|
465
|
init => +{ |
80
|
|
|
|
|
|
|
Test_Results => $builder->{Test_Results}, |
81
|
|
|
|
|
|
|
Curr_Test => $builder->{Curr_Test}, |
82
|
|
|
|
|
|
|
Is_Passing => 1, |
83
|
|
|
|
|
|
|
}, |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# make methods atomic. |
87
|
31
|
|
|
31
|
|
162
|
no strict 'refs'; |
|
31
|
|
|
|
|
36
|
|
|
31
|
|
|
|
|
1054
|
|
88
|
31
|
|
|
31
|
|
140
|
no warnings 'redefine'; |
|
31
|
|
|
|
|
51
|
|
|
31
|
|
|
|
|
1335
|
|
89
|
31
|
|
|
31
|
|
117
|
no warnings 'uninitialized'; |
|
31
|
|
|
|
|
41
|
|
|
31
|
|
|
|
|
4925
|
|
90
|
35
|
|
|
|
|
109
|
for my $name (qw/ok skip todo_skip current_test is_passing/) { |
91
|
175
|
|
|
|
|
157
|
my $orig = *{"Test::Builder::${name}"}{CODE}; |
|
175
|
|
|
|
|
452
|
|
92
|
175
|
|
|
|
|
2493
|
*{"Test::Builder::${name}"} = sub { |
93
|
312
|
|
|
312
|
|
104788883
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
94
|
312
|
|
|
|
|
1632
|
local $Test::Builder::BLevel = $Test::Builder::BLevel + 1; |
95
|
312
|
|
|
|
|
2584
|
my $lock = $STORE->get_lock(); # RAII |
96
|
312
|
|
|
|
|
2799
|
$orig->(@_); |
97
|
175
|
|
|
|
|
443
|
}; |
98
|
|
|
|
|
|
|
}; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
BEGIN { |
103
|
31
|
|
|
31
|
|
426
|
my $builder = __PACKAGE__->builder; |
104
|
31
|
|
|
|
|
403
|
_mangle_builder($builder); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
# backward compatibility method |
109
|
1
|
|
|
1
|
0
|
689
|
sub parent { } |
110
|
1
|
|
|
1
|
0
|
831
|
sub child { } |
111
|
74
|
|
|
74
|
0
|
855752
|
sub fork { fork() } |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
__END__ |