line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::SharedFork; |
2
|
31
|
|
|
31
|
|
615293
|
use strict; |
|
31
|
|
|
|
|
87
|
|
|
31
|
|
|
|
|
775
|
|
3
|
31
|
|
|
31
|
|
149
|
use warnings; |
|
31
|
|
|
|
|
66
|
|
|
31
|
|
|
|
|
947
|
|
4
|
31
|
|
|
31
|
|
149
|
use base 'Test::Builder::Module'; |
|
31
|
|
|
|
|
69
|
|
|
31
|
|
|
|
|
4302
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.34'; |
6
|
31
|
|
|
31
|
|
157
|
use Test::Builder 0.32; # 0.32 or later is needed |
|
31
|
|
|
|
|
648
|
|
|
31
|
|
|
|
|
643
|
|
7
|
31
|
|
|
31
|
|
15185
|
use Test::SharedFork::Scalar; |
|
31
|
|
|
|
|
79
|
|
|
31
|
|
|
|
|
793
|
|
8
|
31
|
|
|
31
|
|
14624
|
use Test::SharedFork::Array; |
|
31
|
|
|
|
|
114
|
|
|
31
|
|
|
|
|
1058
|
|
9
|
31
|
|
|
31
|
|
19651
|
use Test::SharedFork::Store; |
|
31
|
|
|
|
|
122
|
|
|
31
|
|
|
|
|
1119
|
|
10
|
31
|
|
|
31
|
|
165
|
use Config; |
|
31
|
|
|
|
|
60
|
|
|
31
|
|
|
|
|
1342
|
|
11
|
31
|
|
|
31
|
|
808
|
use 5.008000; |
|
31
|
|
|
|
|
114
|
|
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
|
|
1221
|
my $builder = shift; |
48
|
|
|
|
|
|
|
|
49
|
35
|
0
|
33
|
|
|
705
|
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
|
|
|
|
582
|
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
|
|
|
|
0
|
Test::Stream::IPC->enable_polling if Test::Stream::IPC->can('enable_polling'); |
60
|
0
|
|
|
|
|
0
|
my $stack = $builder->{Stack}; |
61
|
0
|
0
|
|
|
|
0
|
return if $stack->top->ipc; |
62
|
0
|
|
|
|
|
0
|
my ($driver) = Test::Stream::IPC->drivers; |
63
|
0
|
|
|
|
|
0
|
my $ipc = $driver->new(); |
64
|
0
|
|
|
|
|
0
|
for my $hub (@$stack) { |
65
|
0
|
|
|
|
|
0
|
$hub->set_ipc($ipc); |
66
|
0
|
|
|
|
|
0
|
$ipc->add_hub($hub->hid); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} else { |
69
|
|
|
|
|
|
|
# older Test::Builder |
70
|
|
|
|
|
|
|
$STORE = Test::SharedFork::Store->new( |
71
|
|
|
|
|
|
|
cb => sub { |
72
|
54
|
|
|
54
|
|
132
|
my $store = shift; |
73
|
54
|
|
|
|
|
1971
|
tie $builder->{Curr_Test}, 'Test::SharedFork::Scalar', |
74
|
|
|
|
|
|
|
$store, 'Curr_Test'; |
75
|
54
|
|
|
|
|
382
|
tie $builder->{Is_Passing}, 'Test::SharedFork::Scalar', |
76
|
|
|
|
|
|
|
$store, 'Is_Passing'; |
77
|
54
|
|
|
|
|
95
|
tie @{ $builder->{Test_Results} }, |
|
54
|
|
|
|
|
1368
|
|
78
|
|
|
|
|
|
|
'Test::SharedFork::Array', $store, 'Test_Results'; |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
init => +{ |
81
|
|
|
|
|
|
|
Test_Results => $builder->{Test_Results}, |
82
|
|
|
|
|
|
|
Curr_Test => $builder->{Curr_Test}, |
83
|
35
|
|
|
|
|
478
|
Is_Passing => 1, |
84
|
|
|
|
|
|
|
}, |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# make methods atomic. |
88
|
31
|
|
|
31
|
|
171
|
no strict 'refs'; |
|
31
|
|
|
|
|
68
|
|
|
31
|
|
|
|
|
1110
|
|
89
|
31
|
|
|
31
|
|
450
|
no warnings 'redefine'; |
|
31
|
|
|
|
|
65
|
|
|
31
|
|
|
|
|
1840
|
|
90
|
31
|
|
|
31
|
|
149
|
no warnings 'uninitialized'; |
|
31
|
|
|
|
|
63
|
|
|
31
|
|
|
|
|
6724
|
|
91
|
35
|
|
|
|
|
129
|
for my $name (qw/ok skip todo_skip current_test is_passing/) { |
92
|
175
|
|
|
|
|
226
|
my $orig = *{"Test::Builder::${name}"}{CODE}; |
|
175
|
|
|
|
|
745
|
|
93
|
175
|
|
|
|
|
3091
|
*{"Test::Builder::${name}"} = sub { |
94
|
312
|
|
|
312
|
|
116885476
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
95
|
312
|
|
|
|
|
2779
|
local $Test::Builder::BLevel = $Test::Builder::BLevel + 1; |
96
|
312
|
|
|
|
|
4271
|
my $lock = $STORE->get_lock(); # RAII |
97
|
312
|
|
|
|
|
4510
|
$orig->(@_); |
98
|
175
|
|
|
|
|
628
|
}; |
99
|
|
|
|
|
|
|
}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
BEGIN { |
104
|
31
|
|
|
31
|
|
504
|
my $builder = __PACKAGE__->builder; |
105
|
31
|
|
|
|
|
524
|
_mangle_builder($builder); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
{ |
109
|
|
|
|
|
|
|
# backward compatibility method |
110
|
|
|
|
1
|
0
|
|
sub parent { } |
111
|
|
|
|
1
|
0
|
|
sub child { } |
112
|
74
|
|
|
74
|
0
|
2517682
|
sub fork { fork() } |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
__END__ |