blib/lib/TAP/Parser/Iterator/Process.pm

filter: Statementstmt 100% 312 / 312 Branchbran 54.4% 61 / 112 Conditioncond 37.0% 10 / 27 MC/DCmcdc 18.7% 3 / 16 Subroutinesub 100% 104 / 104 Podpod 100% 6 / 6 totaltotal 85.9% 496 / 577 CC 89 SCAR 16.0
CC
89
Cov
85%
_initialize
21.3
_initialize
21.0
__ANON__
10.0
CRAP 5.0
« blib/lib/App/Prove/State.pm ↑ Summary blib/lib/TAP/Parser/Aggregator.pm »
1 package TAP::Parser::Iterator::Process;
2  
3 63 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 63 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 48 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 48 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 48 ▶use base 'TAP::Parser::Iterator';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 48 ▶use constant IS_WIN32 => !!( $^O =~ /^(MS)?Win32$/ );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 =head1 NAME
14  
15 TAP::Parser::Iterator::Process - Iterator for process-based TAP sources
16  
17 =head1 VERSION
18  
19 Version 3.52
20  
21 =cut
22  
23 41 our $VERSION = '3.52';
24  
25 =head1 SYNOPSIS
26  
27 use TAP::Parser::Iterator::Process;
28 my %args = (
29 command => ['python', 'setup.py', 'test'],
30 merge => 1,
31 setup => sub { ... },
32 teardown => sub { ... },
33 );
34 my $it = TAP::Parser::Iterator::Process->new(\%args);
35 my $line = $it->next;
36  
37 =head1 DESCRIPTION
38  
39 This is a simple iterator wrapper for executing external processes, used by
40 L<TAP::Parser>. Unless you're writing a plugin or subclassing, you probably
41 won't need to use this module directly.
42  
43 =head1 METHODS
44  
45 =head2 Class Methods
46  
47 =head3 C<new>
48  
49 Create an iterator. Expects one argument containing a hashref of the form:
50  
51 command => \@command_to_execute
52 merge => $attempt_merge_stderr_and_stdout?
53 setup => $callback_to_setup_command
54 teardown => $callback_to_teardown_command
55  
56 Tries to uses L<IPC::Open3> & L<IO::Select> to communicate with the spawned
57 process if they are available. Falls back onto C<open()>.
58  
59 =head2 Instance Methods
60  
61 =head3 C<next>
62  
63 Iterate through the process output, of course.
64  
65 =head3 C<next_raw>
66  
67 Iterate raw input without applying any fixes for quirky input syntax.
68  
69 =head3 C<wait>
70  
71 Get the wait status for this iterator's process.
72  
73 =head3 C<exit>
74  
75 Get the exit status for this iterator's process.
76  
77 =cut
78  
79 {
80  
81 47 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
82 # get around a catch22 in the test suite that causes failures on Win32:
83 41 local $SIG{__DIE__} = undef;
84 41 eval { require POSIX; &POSIX::WEXITSTATUS(0) };
85 41 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 38 38
86 8 ▶ *_wait2exit = sub { $_[1] >> 8 };
Subroutine __ANON__: called CC=1 SCAR=0.0
87 }
88 else {
89 256 ▶ *_wait2exit = sub { POSIX::WEXITSTATUS( $_[1] ) }
Subroutine __ANON__: called CC=1 SCAR=0.0
90 41 }
91 }
92  
93 218 ▶sub _use_open3 {
Subroutine _use_open3: called CC=5 SCAR=16.1
94 218 ▶ return unless $Config{d_fork} || IS_WIN32;
Branch: 2 branches
BranchTrueFalseTotal
unless $TAP::Parser::Iterator::Process::Config{"d_fork"} or !!0 8 202 210
unless $TAP::Parser::Iterator::Process::Config{"d_fork"} or !!0 0 0 0
Condition50%2/4
$TAP::Parser::Iterator::Process::Config{"d_fork"} or !!0
l!l
2028
$TAP::Parser::Iterator::Process::Config{"d_fork"} or !!0
l!l
00
MC/DC100%1/1
$TAP::Parser::Iterator::Process::Config{"d_fork"} or !!0
$TAP::Parser::Iterator::Process::Config{"d_fork"}
MC/DC0%0/1
$TAP::Parser::Iterator::Process::Config{"d_fork"} or !!0
$TAP::Parser::Iterator::Process::Config{"d_fork"}
Truth table100%2/2
A
A= $TAP::Parser::Iterator::Process::Config{"d_fork"}
Aresult
11
00
Truth table0%0/2
A
A= $TAP::Parser::Iterator::Process::Config{"d_fork"}
Aresult
11
00
95 210 for my $module (qw( IPC::Open3 IO::Select )) {
96 412 ▶ eval "use $module";
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
97 412 ▶ return if $@;
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 404 404
if $@ 0 0 0
98 }
99 210 return 1;
100 }
101  
102 {
103 41 my $got_unicode;
104  
105 9 ▶ sub _get_unicode {
Subroutine _get_unicode: called CC=3 SCAR=13.5
106 10 ▶ return $got_unicode if defined $got_unicode;
Branch: 2 branches
BranchTrueFalseTotal
if defined $got_unicode 1 1 2
if defined $got_unicode 0 0 0
107 9 eval 'use Encode qw(decode_utf8);';
108 8 ▶ $got_unicode = $@ ? 0 : 1;
Branch: 2 branches
BranchTrueFalseTotal
$@ ? : 0 1 1
$@ ? : 0 0 0
109  
110 }
111 }
112  
113 # new() implementation supplied by TAP::Object
114  
115 41 ▶sub _initialize {
Subroutine _initialize: called CC=14 SCAR=30.5
116 261 my ( $self, $args ) = @_;
117  
118 261 ▶ my @command = @{ delete $args->{command} || [] }
Branch: 2 branches
BranchTrueFalseTotal
my(@command) = @{delete $args->{"command"} or [];} or die "Must supply a command to execute" 253 1 254
my(@command) = @{delete $args->{"command"} or [];} or die "Must supply a command to execute" 0 0 0
Condition50%2/4
delete $args->{'command'} || []
l!l
2531
delete $args->{'command'} || []
l!l
00
MC/DC100%1/1
delete $args->{'command'} || []
delete $args->{'command'}
MC/DC0%0/1
delete $args->{'command'} || []
delete $args->{'command'}
Truth table100%2/2
A
A= delete $args->{'command'}
Aresult
11
00
Truth table0%0/2
A
A= delete $args->{'command'}
Aresult
11
00
119 or die "Must supply a command to execute";
120  
121 260 $self->{command} = [@command];
122  
123 # Private. Used to frig with chunk size during testing.
124 260 ▶ my $chunk_size = delete $args->{_chunk_size} || 65536;
Condition50%2/4
delete $args->{'_chunk_size'} || 65536
l!l
27226
delete $args->{'_chunk_size'} || 65536
l!l
00
MC/DC100%1/1
delete $args->{'_chunk_size'} || 65536
delete $args->{'_chunk_size'}
MC/DC0%0/1
delete $args->{'_chunk_size'} || 65536
delete $args->{'_chunk_size'}
Truth table100%2/2
A
A= delete $args->{'_chunk_size'}
Aresult
11
00
Truth table0%0/2
A
A= delete $args->{'_chunk_size'}
Aresult
11
00
125  
126 260 my $merge = delete $args->{merge};
127 260 my ( $pid, $err, $sel );
128  
129 260 ▶ if ( my $setup = delete $args->{setup} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $setup = delete $args->{"setup"}) 210 43 253
if (my $setup = delete $args->{"setup"}) 0 0 0
130 217 $setup->(@command);
131 }
132  
133 260 my $out = IO::Handle->new;
134  
135 260 ▶ if ( $self->_use_open3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_use_open3) { } 201 52 253
if ($self->_use_open3) { } 0 0 0
136  
137 # HOTPATCH {{{
138 207 my $xclose = \&IPC::Open3::xclose;
139 47 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
140 563 ▶ local *IPC::Open3::xclose = sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
141 562 my $fh = shift;
142 46 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
143 562 ▶ return if ( fileno($fh) == fileno(STDIN) );
Branch: 2 branches
BranchTrueFalseTotal
if fileno $fh == fileno STDIN 201 355 556
if fileno $fh == fileno STDIN 0 0 0
144 361 $xclose->($fh);
145 207 };
146  
147 # }}}
148  
149 207 if (IS_WIN32) {
150 $err = $merge ? '' : '>&STDERR';
151 eval {
152 $pid = open3(
153 '<&STDIN', $out, $merge ? '' : $err,
154 @command
155 );
156 };
157 die "Could not execute (@command): $@" if $@;
158 if ( $] >= 5.006 ) {
159 binmode($out, ":crlf");
160 }
161 }
162 else {
163 207 ▶ $err = $merge ? '' : IO::Handle->new;
Branch: 2 branches
BranchTrueFalseTotal
$merge ? : 47 154 201
$merge ? : 0 0 0
164 207 eval { $pid = open3( '<&STDIN', $out, $err, @command ); };
165 207 ▶ die "Could not execute (@command): $@" if $@;
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 201 201
if $@ 0 0 0
166 207 ▶ $sel = $merge ? undef : IO::Select->new( $out, $err );
Branch: 2 branches
BranchTrueFalseTotal
$merge ? : 47 154 201
$merge ? : 0 0 0
167 }
168 }
169 else {
170 58 $err = '';
171 58 my $exec = shift @command;
172 58 ▶ $exec = qq{"$exec"} if $exec =~ /\s/ and -x $exec;
Branch: 2 branches
BranchTrueFalseTotal
if $exec =~ /\s/ and -x $exec 0 52 52
if $exec =~ /\s/ and -x $exec 0 0 0
Condition16%1/6
$exec =~ /\s/ and -x $exec
!ll&&!rl&&r
5200
$exec =~ /\s/ and -x $exec
!ll&&!rl&&r
000
MC/DC0%0/2
$exec =~ /\s/ and -x $exec
$exec =~ /\s/ -x $exec
MC/DC0%0/2
$exec =~ /\s/ and -x $exec
$exec =~ /\s/ -x $exec
Truth table33%1/3
A and B
A= $exec =~ /\s/B= -x $exec
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $exec =~ /\s/B= -x $exec
ABresult
0X0
100
111
173 my $command
174 58 ▶ = join( ' ', $exec, map { $_ =~ /\s/ ? qq{"$_"} : $_ } @command );
Branch: 2 branches
BranchTrueFalseTotal
$_ =~ /\s/ ? : 1 67 68
$_ =~ /\s/ ? : 0 0 0
175 58 ▶ open( $out, "$command|" )
Branch: 2 branches
BranchTrueFalseTotal
open $out, "$command|" or die "Could not execute ($command): $!" 52 0 52
open $out, "$command|" or die "Could not execute ($command): $!" 0 0 0
176 or die "Could not execute ($command): $!";
177 }
178  
179 259 $self->{out} = $out;
180 259 $self->{err} = $err;
181 259 $self->{sel} = $sel;
182 259 $self->{pid} = $pid;
183 259 $self->{exit} = undef;
184 259 $self->{chunk_size} = $chunk_size;
185  
186 259 ▶ if ( my $teardown = delete $args->{teardown} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $teardown = delete $args->{"teardown"}) 210 43 253
if (my $teardown = delete $args->{"teardown"}) 0 0 0
187 213 ▶ $self->{teardown} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
188 212 $teardown->(@command);
189 216 };
190 }
191  
192 259 return $self;
193 }
194  
195 =head3 C<handle_unicode>
196  
197 Upgrade the input stream to handle UTF8.
198  
199 =cut
200  
201 20 ▶sub handle_unicode {
Subroutine handle_unicode: called CC=5 SCAR=20.2
Pod documented
202 20 ▶ my $self = shift;
Pod documented
203  
204 20 ▶ if ( $self->{sel} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'sel'}) { } 2 12 14
if ($self->{'sel'}) { } 0 0 0
205 8 ▶ if ( _get_unicode() ) {
Branch: 2 branches
BranchTrueFalseTotal
if (_get_unicode()) 2 0 2
if (_get_unicode()) 0 0 0
206  
207 # Make sure our iterator has been constructed and...
208 7 ▶ my $next = $self->{_next} ||= $self->_next;
Condition16%1/6
$self->{"_next"} ||= $self->_next
l!l&&r!l&&!r
200
$self->{"_next"} ||= $self->_next
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_next"} ||= $self->_next
$self->{"_next"} $self->_next
MC/DC0%0/2
$self->{"_next"} ||= $self->_next
$self->{"_next"} $self->_next
Truth table33%1/3
A ||= B
A= $self->{"_next"}B= $self->_next
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $self->{"_next"}B= $self->_next
ABresult
1X1
011
000
209  
210 # ...wrap it to do UTF8 casting
211 12 ▶ $self->{_next} = sub {
Subroutine __ANON__: called CC=2 SCAR=7.4
212 11 my $line = $next->();
213 11 ▶ return decode_utf8($line) if defined $line;
Branch: 2 branches
BranchTrueFalseTotal
if defined $line 4 2 6
if defined $line 0 0 0
214 7 return;
215 7 };
216 }
217 }
218 else {
219 17 ▶ if ( $] >= 5.008 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($] >= "5.008") 12 0 12
if ($] >= "5.008") 0 0 0
220 17 eval 'binmode($self->{out}, ":utf8")';
221 }
222 }
223  
224 }
225  
226 ##############################################################################
227  
228 222 ▶sub wait { shift->{wait} }
Subroutine wait: called CC=1 SCAR=0.0
Pod documented
229 225 ▶sub exit { shift->{exit} }
Subroutine exit: called CC=1 SCAR=0.0
Pod documented
230  
231 257 ▶sub _next {
Subroutine _next: called CC=3 SCAR=11.0
232 256 my $self = shift;
233  
234 256 ▶ if ( my $out = $self->{out} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $out = $self->{'out'}) { } 251 0 251
235 256 ▶ if ( my $sel = $self->{sel} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sel = $self->{'sel'}) { } 152 99 251
236 157 my $err = $self->{err};
237 157 my @buf = ();
238 157 my $partial = ''; # Partial line
239 157 my $chunk_size = $self->{chunk_size};
240 828 ▶ return sub {
Subroutine __ANON__: called CC=10 SCAR=23.0
241 827 ▶ return shift @buf if @buf;
Branch: 1 branch
BranchTrueFalseTotal
if @buf 411 411 822
242  
243 READ:
244 416 ▶ while ( my @ready = $sel->can_read ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@ready) = $sel->can_read) 414 177 591
245 844 for my $fh (@ready) {
246 973 my $got = sysread $fh, my ($chunk), $chunk_size;
247  
248 973 ▶ if ( $got == 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($got == 0) { } 300 668 968
elsif ($fh == $err) { } 9 659 668
249 304 $sel->remove($fh);
250 }
251 elsif ( $fh == $err ) {
252 13 print STDERR $chunk; # echo STDERR
253 }
254 else {
255 663 $chunk = $partial . $chunk;
256 663 $partial = '';
257  
258 # Make sure we have a complete line
259 663 ▶ unless ( substr( $chunk, -1, 1 ) eq "\n" ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (substr($chunk, -1, 1) eq "\n") 471 188 659
260 475 my $nl = rindex $chunk, "\n";
261 475 ▶ if ( $nl == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nl == -1) { } 425 46 471
262 429 $partial = $chunk;
263 429 redo READ;
264 }
265 else {
266 50 $partial = substr( $chunk, $nl + 1 );
267 50 $chunk = substr( $chunk, 0, $nl );
268 }
269 }
270  
271 238 push @buf, split /\n/, $chunk;
272 238 ▶ return shift @buf if @buf;
Branch: 1 branch
BranchTrueFalseTotal
if @buf 234 0 234
273 }
274 }
275 }
276  
277 # Return partial last line
278 181 ▶ if ( length $partial ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $partial) 27 150 177
279 31 my $last = $partial;
280 31 $partial = '';
281 31 return $last;
282 }
283  
284 154 $self->_finish;
285 154 return;
286 157 };
287 }
288 else {
289 684 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
290 682 local $/ = "\n"; # to ensure lines
291 682 ▶ if ( defined( my $line = <$out> ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $out)) 580 98 678
292 584 chomp $line;
293 584 return $line;
294 }
295 102 $self->_finish;
296 102 return;
297 104 };
298 }
299 }
300 else {
301 6 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
302 4 $self->_finish;
303 4 return;
304 5 };
305 }
306 }
307  
308 1506 ▶sub next_raw {
Subroutine next_raw: called CC=2 SCAR=7.1
Pod documented
309 1504 my $self = shift;
310 1504 ▶ return ( $self->{_next} ||= $self->_next )->();
Condition66%2/3
$self->{"_next"} ||= $self->_next
l!l&&r!l&&!r
12492510
MC/DC0%0/2
$self->{"_next"} ||= $self->_next
$self->{"_next"} $self->_next
Truth table66%2/3
A ||= B
A= $self->{"_next"}B= $self->_next
ABresult
1X1
011
000
311 }
312  
313 254 ▶sub _finish {
Subroutine _finish: called CC=7 SCAR=19.5
314 252 my $self = shift;
315  
316 252 my $status = $?;
317  
318 # Avoid circular refs
319 4 ▶ $self->{_next} = sub {return}
Subroutine __ANON__: called CC=1 SCAR=0.0
320 252 ▶ if $] >= 5.006;
Branch: 1 branch
BranchTrueFalseTotal
if $] >= "5.006" 248 0 248
321  
322 # If we have a subprocess we need to wait for it to terminate
323 252 ▶ if ( defined $self->{pid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"pid"}) 196 52 248
324 200 ▶ if ( $self->{pid} == waitpid( $self->{pid}, 0 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"pid"} == waitpid($self->{"pid"}, 0)) 196 0 196
325 200 $status = $?;
326 }
327 }
328  
329 252 ▶ ( delete $self->{out} )->close if $self->{out};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"out"} 248 0 248
330  
331 # If we have an IO::Select we also have an error handle to close.
332 252 ▶ if ( $self->{sel} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'sel'}) { } 150 98 248
333 154 ( delete $self->{err} )->close;
334 154 delete $self->{sel};
335 }
336 else {
337 102 $status = $?;
338 }
339  
340 # Sometimes we get -1 on Windows. Presumably that means status not
341 # available.
342 252 $status = 0 if IS_WIN32 && $status == -1;
343  
344 252 $self->{wait} = $status;
345 252 $self->{exit} = $self->_wait2exit($status);
346  
347 252 ▶ if ( my $teardown = $self->{teardown} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $teardown = $self->{"teardown"}) 206 42 248
348 210 $teardown->();
349 }
350  
351 252 return $self;
352 }
353  
354 =head3 C<get_select_handles>
355  
356 Return a list of filehandles that may be used upstream in a select()
357 call to signal that this Iterator is ready. Iterators that are not
358 handle based should return an empty list.
359  
360 =cut
361  
362 19 ▶sub get_select_handles {
Subroutine get_select_handles: called CC=1 SCAR=0.0
Pod documented
363 18 my $self = shift;
364 17 return grep $_, ( $self->{out}, $self->{err} );
365 }
366  
367 41 1;
368  
369 =head1 ATTRIBUTION
370  
371 Originally ripped off from L<Test::Harness>.
372  
373 =head1 SEE ALSO
374  
375 L<TAP::Object>,
376 L<TAP::Parser>,
377 L<TAP::Parser::Iterator>,
378  
379 =cut
380  
« blib/lib/App/Prove/State.pm ↑ Summary blib/lib/TAP/Parser/Aggregator.pm »