line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::ParallelSubtest::Capture; |
2
|
10
|
|
|
10
|
|
70
|
use strict; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
415
|
|
3
|
10
|
|
|
10
|
|
72
|
use warnings; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
2197
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
6
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
package Test::ParallelSubtest::CaptureFH; |
10
|
10
|
|
|
10
|
|
10594
|
use IO::WrapTie; |
|
10
|
|
|
|
|
12661
|
|
|
10
|
|
|
|
|
489
|
|
11
|
10
|
|
|
10
|
|
9363
|
use Tie::FileHandle::Base; |
|
10
|
|
|
|
|
7103
|
|
|
10
|
|
|
|
|
3734
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(IO::WrapTie::Slave Tie::FileHandle::Base); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub TIEHANDLE { |
15
|
18
|
|
|
18
|
|
1997
|
my ($pkg, $bufref, $prefix) = @_; |
16
|
|
|
|
|
|
|
|
17
|
18
|
|
33
|
|
|
242
|
return bless { |
18
|
|
|
|
|
|
|
BufRef => $bufref, |
19
|
|
|
|
|
|
|
Prefix => $prefix, |
20
|
|
|
|
|
|
|
}, ref($pkg)||$pkg; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub PRINT { |
24
|
17
|
|
|
17
|
|
5041387
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
17
|
|
|
|
|
191
|
my $text = join '', @_; |
27
|
17
|
50
|
|
|
|
460
|
if (length $text) { |
28
|
|
|
|
|
|
|
# Append to the buffer the prefix that identifies this |
29
|
|
|
|
|
|
|
# filehandle, followed by the data length and then the data. |
30
|
17
|
|
|
|
|
33
|
${ $self->{BufRef} } .= $self->{Prefix} |
|
17
|
|
|
|
|
1163
|
|
31
|
|
|
|
|
|
|
. pack('N', length $text) . $text; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
10
|
|
|
10
|
|
73
|
use Carp; |
|
10
|
|
|
|
|
38
|
|
|
10
|
|
|
|
|
5093
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
39
|
22
|
|
|
22
|
1
|
148
|
my ($pkg, $bufref) = @_; |
40
|
|
|
|
|
|
|
|
41
|
22
|
100
|
|
|
|
100
|
if ($bufref) { |
42
|
16
|
50
|
|
|
|
101
|
ref $bufref eq 'SCALAR' or croak 'new() arg must be a scalar ref'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
6
|
|
|
|
|
103
|
my $buf = ''; |
46
|
6
|
|
|
|
|
25
|
$bufref = \$buf; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
22
|
|
33
|
|
|
581
|
return bless { |
50
|
|
|
|
|
|
|
BufRef => $bufref, |
51
|
|
|
|
|
|
|
}, ref($pkg)||$pkg; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub install { |
55
|
6
|
|
|
6
|
1
|
15
|
my ($self, $builder) = @_; |
56
|
|
|
|
|
|
|
|
57
|
6
|
|
|
|
|
19
|
my %fh; |
58
|
6
|
|
|
|
|
250
|
foreach my $prefix (qw( o f t )) { |
59
|
18
|
|
|
|
|
760
|
$fh{$prefix} = Test::ParallelSubtest::CaptureFH->new_tie( |
60
|
|
|
|
|
|
|
$self->{BufRef}, $prefix); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
6
|
|
|
|
|
140
|
$builder->output( $fh{'o'}); |
64
|
6
|
|
|
|
|
790
|
$builder->failure_output($fh{'f'}); |
65
|
6
|
|
|
|
|
143
|
$builder->todo_output( $fh{'t'}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub as_string_ref { |
69
|
6
|
|
|
6
|
1
|
18
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
6
|
|
|
|
|
173
|
return $self->{BufRef}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub replay_writes { |
75
|
16
|
|
|
16
|
1
|
45
|
my ($self, $out_dest, $fail_dest, $todo_dest) = @_; |
76
|
|
|
|
|
|
|
|
77
|
16
|
|
|
|
|
181
|
my %fh = ( |
78
|
|
|
|
|
|
|
'o' => $out_dest, |
79
|
|
|
|
|
|
|
'f' => $fail_dest, |
80
|
|
|
|
|
|
|
't' => $todo_dest, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
16
|
|
|
|
|
29
|
my $buf = ${ $self->{BufRef} }; |
|
16
|
|
|
|
|
67
|
|
84
|
16
|
|
|
|
|
60
|
while (length $buf) { |
85
|
37
|
50
|
|
|
|
233
|
$buf =~ s/^([oft])// or return; |
86
|
37
|
|
|
|
|
92
|
my $fh = $fh{$1}; |
87
|
37
|
|
|
|
|
113
|
my $packed_len = substr $buf, 0, 4, ''; |
88
|
37
|
50
|
|
|
|
116
|
return if length($packed_len) != 4; |
89
|
37
|
|
|
|
|
144
|
my $len = unpack 'N', $packed_len; |
90
|
37
|
50
|
33
|
|
|
250
|
return if $len < 1 or $len > length $buf; |
91
|
37
|
|
|
|
|
21323
|
print $fh substr $buf, 0, $len, ''; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
16
|
|
|
|
|
122
|
return 1; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |