Branch Coverage

lib/IPC/Cmd.pm
Criterion Covered Total %
branch 180 404 44.5


line true false branch
7 0 2 $^O eq 'VMS' ? :
8 0 2 $^O eq 'MSWin32' ? :
45 0 2 if ($@) { }
147 1 0 unless can_load('modules', {'IPC::Run', '0.55'}, 'verbose', $IPC::Cmd::WARN && $verbose)
175 0 141 unless can_load('modules', {map({$_, '0.0';} 'IPC::Open3', 'IO::Select', 'Symbol')}, 'verbose', $IPC::Cmd::WARN && $verbose)
192 0 200 if $IPC::Cmd::USE_IPC_RUN and $self->can_use_ipc_run
193 100 100 if $IPC::Cmd::USE_IPC_OPEN3 and $self->can_use_ipc_open3
228 0 7 if ($^O eq 'VMS')
231 0 0 if scalar $syms->getsym(uc $command)
239 1 6 if ('File::Spec'->file_name_is_absolute($command)) { }
247 6 48 unless $dir and -d $dir
249 5 43 if $abs = 'MM'->maybe_command($abs)
252 0 0 if wantarray and $IPC::Cmd::INSTANCES
358 160 240 if @_ > 1
369 6941 0 if ($IPC::Cmd::HAVE_MONOTONIC) { }
382 6721 0 if $IPC::Cmd::HAVE_MONOTONIC
386 0 0 unless $previous
395 0 0 if ($time_diff > 5 or $time_diff < 0)
397 0 0 if (defined $$ref_var)
405 108 0 unless defined $IPC::Cmd::{'__old_signals'}
420 0 0 unless defined $available_signals{$s}
421 0 0 if not ref $handler_code or ref $handler_code ne 'CODE'
425 0 0 unless defined $IPC::Cmd::{'__old_signals'}
449 0 0 if ($called_sig_name eq $signal_name)
455 0 0 if (ref $previous_handler)
471 2 2 unless $opts
472 2 2 unless defined $opts->{'wait_time'}
473 2 2 unless $opts->{'first_kill_type'}
474 2 2 unless $opts->{'final_kill_type'}
476 2 2 if ($opts->{'first_kill_type'} eq 'just_process') { }
2 0 elsif ($opts->{'first_kill_type'} eq 'process_group') { }
496 0 8 if ($now > $wait_start_time + $opts->{'wait_time'})
503 4 4 if ($waitpid eq -1)
512 0 4 if (not $child_finished)
513 0 0 if ($opts->{'final_kill_type'} eq 'just_process') { }
0 0 elsif ($opts->{'final_kill_type'} eq 'process_group') { }
525 0 0 unless $opts
540 0 0 if ($opts->{'parent_info'})
545 0 0 if ($child_in and $child_out->opened and $opts->{'child_stdin'})
587 0 0 if $s eq '__WARN__' or $s eq '__DIE__'
605 0 0 if (getppid eq '1')
623 0 0 if ($waitpid ne 0 and $waitpid ne -1)
628 0 0 if ($waitpid eq -1)
641 0 0 unless $str
646 0 0 if ($count) { }
0 0 elsif ($count eq 0) { }
647 0 0 if ($str->{'parent_socket'}) { }
663 0 0 if $child_finished
672 0 0 if ($opts->{'parent_info'})
676 0 0 if ($real_exit & 127)
683 0 0 if ($opts->{'parent_stdout'} or $opts->{'parent_stderr'}) { }
822 0 108 unless (can_use_run_forked())
830 1 107 if (ref $cmd eq 'ARRAY')
834 0 108 unless ($cmd)
839 104 4 unless $opts
840 106 2 unless $opts->{'timeout'}
841 108 0 unless defined $opts->{'terminate_wait_time'}
844 108 0 unless defined $opts->{'clean_up_children'}
858 0 108 unless socketpair $child_stdout_socket, $parent_stdout_socket, &Socket::AF_UNIX, &Socket::SOCK_STREAM, &Socket::PF_UNSPEC
860 0 108 unless socketpair $child_stderr_socket, $parent_stderr_socket, &Socket::AF_UNIX, &Socket::SOCK_STREAM, &Socket::PF_UNSPEC
862 0 108 unless socketpair $child_info_socket, $parent_info_socket, &Socket::AF_UNIX, &Socket::SOCK_STREAM, &Socket::PF_UNSPEC
875 108 0 if ($pid = fork) { }
888 0 108 unless fcntl $child_stdout_socket, 4, $flags
892 0 108 unless fcntl $child_stderr_socket, 4, $flags
896 0 108 unless fcntl $child_info_socket, 4, $flags
940 0 108 if ($opts->{'terminate_on_signal'})
954 0 6713 if ($opts->{'terminate_on_parent_sudden_death'})
956 0 0 if ($now > $last_parent_check + 5)
957 0 0 if (getppid eq '1')
971 296 6417 if ($opts->{'timeout'})
972 2 294 if ($now > $start_time + $opts->{'timeout'})
985 205 6508 if ($got_sig_child)
986 0 205 if ($now > $got_sig_child + 10)
993 0 6713 if ($got_sig_quit)
1005 106 6607 if ($waitpid ne 0 and $waitpid ne -1)
1009 108 6605 if ($waitpid eq -1)
1021 0 7546 unless $str
1026 7222 324 if ($count) { }
324 0 elsif ($count eq 0) { }
1028 7222 0 if ($data =~ /(.+\n)([^\n]*)/so) { }
1040 0 324 if ($str->{'scalar_buffer'})
1051 322 7224 if ($str->{'protocol'} eq 'info')
1052 107 215 if ($data =~ /^spawned ([0-9]+?)\n(.*?)/so)
1056 105 217 if ($data =~ /^reaped ([0-9]+?)\n(.*?)/so)
1060 2 320 if ($data =~ /^[\d]+ killed with ([0-9]+?)\n(.*?)/so)
1067 0 322 if ($data)
1071 7113 433 if ($str->{'protocol'} eq 'stdout')
1072 7109 4 unless ($opts->{'discard_output'})
1077 2 7111 if ($opts->{'stdout_handler'} and ref $opts->{'stdout_handler'} eq 'CODE')
1081 111 7435 if ($str->{'protocol'} eq 'stderr')
1082 108 3 unless ($opts->{'discard_output'})
1087 2 109 if ($opts->{'stderr_handler'} and ref $opts->{'stderr_handler'} eq 'CODE')
1099 1109 6437 if $child_finished
1102 0 6713 if ($opts->{'wait_loop_callback'} and ref $opts->{'wait_loop_callback'} eq 'CODE')
1121 2 106 if ($child_child_pid)
1138 108 0 if ($opts->{'clean_up_children'})
1152 2 106 $child_timedout ? :
1161 2 106 if ($o->{'exit_code'})
1164 2 106 if ($o->{'timeout'})
1167 0 108 if ($o->{'parent_died'})
1170 103 5 if ($o->{'stdout'} and not $opts->{'non_empty_stdout_ok'})
1173 2 106 if ($o->{'stderr'})
1176 2 106 if ($o->{'killed_by_signal'})
1181 0 108 if ($orig_sig_child) { }
1193 0 0 unless defined $pid
1201 0 0 unless POSIX::setsid()
1203 0 0 if ($opts->{'child_BEGIN'} and ref $opts->{'child_BEGIN'} eq 'CODE')
1215 0 0 if (not ref $cmd) { }
0 0 elsif (ref $cmd eq 'CODE') { }
1246 0 0 if ($opts->{'child_END'} and ref $opts->{'child_END'} eq 'CODE')
1269 40 40 unless not ref $_[0]
1274 0 80 unless (check($tmpl, \%hash, $IPC::Cmd::VERBOSE))
1283 0 80 if ($IPC::Cmd::ALLOW_NULL_ARGS) { }
1284 0 0 if ref $cmd
1287 144 0 if defined $_
40 40 if ref $cmd
1290 40 40 ref $cmd ? :
1291 0 80 if $verbose
1305 0 32 unless defined $buf
1307 0 32 if $verbose
1315 0 8 unless defined $buf
1317 0 8 if $verbose
1324 40 40 $self->can_capture_buffer ? :
1339 0 80 if $timeout
1340 80 0 unless alarm $timeout
1343 0 80 if ($IPC::Cmd::USE_IPC_RUN and $self->can_use_ipc_run(1)) { }
40 40 elsif ($IPC::Cmd::USE_IPC_OPEN3 and $self->can_use_ipc_open3(1)) { }
1346 0 0 if $IPC::Cmd::DEBUG
1355 0 40 if $IPC::Cmd::DEBUG
1369 0 40 if $IPC::Cmd::DEBUG
1379 80 0 if $self->_fds
1382 0 80 unless ($ok)
1384 0 0 if ($@ and ref $@ and $@->isa('IPC::Cmd::TimeOut')) { }
1394 40 40 if @buffer
1399 20 20 $have_buffer ? :
40 40 wantarray ? :
1416 0 0 unless socketpair $_[0], $_[1], &Socket::AF_UNIX, &Socket::SOCK_STREAM, &Socket::PF_UNSPEC
1428 0 0 unless &$pipe(*TO_CHLD_R, *TO_CHLD_W)
1429 0 0 unless &$pipe(*FR_CHLD_R, *FR_CHLD_W)
1430 0 0 unless &$pipe(*FR_CHLD_ERR_R, *FR_CHLD_ERR_W)
1437 0 0 if defined $_
0 0 if ref $cmd
1440 0 0 ref $cmd ? :
1462 0 0 if (not $bytes_read) { }
1477 0 0 if ($?) { }
1524 12 28 ref $cmd ? :
1533 0 40 if ($@ and $@ =~ /^open3:/)
1549 40 0 if UNIVERSAL::can($kidout, 'autoflush')
1550 40 0 if UNIVERSAL::can($kiderror, 'autoflush')
1566 0 120 unless (defined $len)
1574 32 88 if $len and $h == $kidout
1575 8 112 if $len and $h == $kiderror
1579 40 80 if $h == $kidout and $len == 0
1580 40 80 if $h == $kiderror and $len == 0
1581 40 80 if $stdout_done and $stderr_done
1593 0 40 if ($?) { }
1638 0 0 if (ref $cmd) { }
1641 0 0 if ($item =~ /$re/) { }
1651 0 0 if ($_ =~ /$re/) { }
1655 0 0 /[ ]/ ? :
1689 0 0 if ($ok) { }
1698 0 0 if ($@ and not UNIVERSAL::isa($@, 'IPC::Cmd::TimeOut')) { }
0 0 elsif ($@) { }
1724 0 40 $verbose ? :
1730 12 28 ref $cmd ? :
0 40 unless (system(ref $cmd ? @$cmd : $cmd) == 0)
1738 0 40 unless $self->ok
1750 16 64 if (ref $cmd and grep {$sc_lookup{$_};} @$cmd)
1755 8 80 / / ? :
1757 0 16 if $IPC::Cmd::DEBUG and $fixed
1779 0 0 scalar @args == 1 && UNIVERSAL::isa($args[0], 'ARRAY') ? :
1784 0 0 unless $got_arrayref or scalar @args > 1
1786 0 0 $got_arrayref ? :
1789 0 0 if (m[^[^/\"]])
1794 0 0 $got_arrayref ? :
1798 0 0 $got_arrayref ? :
1800 0 0 $got_arrayref ? :
1820 0 0 unless defined $_ and length $_
1830 0 0 if ($ch eq '\\' and $next_ch eq '"') { }
0 0 elsif ($ch eq '\\' and $next_ch eq '\\') { }
0 0 elsif ($ch eq '"' and $next_ch eq '"' and $quote_mode) { }
0 0 elsif ($ch eq '"' and $next_ch eq '"' and not $quote_mode and $i + 2 == length $_ || substr($_, $i + 2, 1) eq ' ') { }
0 0 elsif ($ch eq '"') { }
0 0 elsif ($ch eq ' ' and not $quote_mode) { }
1850 0 0 if defined $arg and length $arg
1860 0 0 if defined $arg and length $arg
1880 0 80 if $IPC::Cmd::DEBUG
1883 0 120 unless my($redir, $fh, $glob) = @{$Map{$name};}
1889 0 120 unless open $glob, $redir . fileno($fh)
1898 80 40 if ($redir eq '>&')
1899 0 80 unless open $fh, '>' . 'File::Spec'->devnull
1914 0 80 if $IPC::Cmd::DEBUG
1917 0 120 unless my($redir, $fh, $glob) = @{$Map{$name};}
1923 0 120 unless open $fh, $redir . fileno($glob)
1938 0 0 unless my $msg = shift()
1949 0 0 unless my $cmd = shift()
1950 0 0 unless my $ce = shift()
1951 0 0 ref $cmd ? :
1955 0 0 if ($ce == -1) { }
0 0 elsif ($ce & 127) { }
1963 0 0 $ce & 128 ? :
1971 0 0 if $IPC::Cmd::DEBUG