Branch Coverage

lib/IPC/Cmd.pm
Criterion Covered Total %
branch 181 406 44.5


line true false branch
7 0 2 $^O eq 'VMS' ? :
8 0 2 $^O eq 'MSWin32' ? :
9 0 2 $^O eq 'hpux' ? :
46 0 2 if ($@) { }
148 1 0 unless can_load('modules', {'IPC::Run', '0.55'}, 'verbose', $IPC::Cmd::WARN && $verbose)
176 0 141 unless can_load('modules', {map({$_, '0.0';} 'IPC::Open3', 'IO::Select', 'Symbol')}, 'verbose', $IPC::Cmd::WARN && $verbose)
193 0 200 if $IPC::Cmd::USE_IPC_RUN and $self->can_use_ipc_run
194 100 100 if $IPC::Cmd::USE_IPC_OPEN3 and $self->can_use_ipc_open3
229 0 7 if ($^O eq 'VMS')
232 0 0 if scalar $syms->getsym(uc $command)
240 1 6 if ('File::Spec'->file_name_is_absolute($command)) { }
248 6 48 unless $dir and -d $dir
250 5 43 if $abs = 'MM'->maybe_command($abs)
253 0 0 if wantarray and $IPC::Cmd::INSTANCES
359 160 240 if @_ > 1
370 6778 0 if ($IPC::Cmd::HAVE_MONOTONIC) { }
383 6558 0 if $IPC::Cmd::HAVE_MONOTONIC
387 0 0 unless $previous
396 0 0 if ($time_diff > 5 or $time_diff < 0)
398 0 0 if (defined $$ref_var)
406 108 0 unless defined $IPC::Cmd::{'__old_signals'}
421 0 0 unless defined $available_signals{$s}
422 0 0 if not ref $handler_code or ref $handler_code ne 'CODE'
426 0 0 unless defined $IPC::Cmd::{'__old_signals'}
450 0 0 if ($called_sig_name eq $signal_name)
456 0 0 if (ref $previous_handler)
472 2 2 unless $opts
473 2 2 unless defined $opts->{'wait_time'}
474 2 2 unless $opts->{'first_kill_type'}
475 2 2 unless $opts->{'final_kill_type'}
477 2 2 if ($opts->{'first_kill_type'} eq 'just_process') { }
2 0 elsif ($opts->{'first_kill_type'} eq 'process_group') { }
497 0 8 if ($now > $wait_start_time + $opts->{'wait_time'})
504 4 4 if ($waitpid eq -1)
513 0 4 if (not $child_finished)
514 0 0 if ($opts->{'final_kill_type'} eq 'just_process') { }
0 0 elsif ($opts->{'final_kill_type'} eq 'process_group') { }
526 0 0 unless $opts
545 0 0 if ($opts->{'parent_info'})
550 0 0 if ($child_in and $child_out->opened and $opts->{'child_stdin'})
592 0 0 if $s eq '__WARN__' or $s eq '__DIE__'
610 0 0 if (getppid != $original_ppid)
628 0 0 if ($waitpid ne 0 and $waitpid ne -1)
633 0 0 if ($waitpid eq -1)
646 0 0 unless $str
651 0 0 if ($count) { }
0 0 elsif ($count eq 0) { }
652 0 0 if ($str->{'parent_socket'}) { }
668 0 0 if $child_finished
677 0 0 if ($opts->{'parent_info'})
681 0 0 if ($real_exit & 127)
688 0 0 if ($opts->{'parent_stdout'} or $opts->{'parent_stderr'}) { }
827 0 108 unless (can_use_run_forked())
835 1 107 if (ref $cmd eq 'ARRAY')
839 0 108 unless ($cmd)
844 104 4 unless $opts
845 106 2 unless $opts->{'timeout'}
846 108 0 unless defined $opts->{'terminate_wait_time'}
849 108 0 unless defined $opts->{'clean_up_children'}
863 0 108 unless socketpair $child_stdout_socket, $parent_stdout_socket, &Socket::AF_UNIX, &Socket::SOCK_STREAM, &Socket::PF_UNSPEC
865 0 108 unless socketpair $child_stderr_socket, $parent_stderr_socket, &Socket::AF_UNIX, &Socket::SOCK_STREAM, &Socket::PF_UNSPEC
867 0 108 unless socketpair $child_info_socket, $parent_info_socket, &Socket::AF_UNIX, &Socket::SOCK_STREAM, &Socket::PF_UNSPEC
881 108 0 if ($pid = fork) { }
894 0 108 unless fcntl $child_stdout_socket, 4, $flags
898 0 108 unless fcntl $child_stderr_socket, 4, $flags
902 0 108 unless fcntl $child_info_socket, 4, $flags
946 0 108 if ($opts->{'terminate_on_signal'})
960 0 6550 if ($opts->{'terminate_on_parent_sudden_death'})
962 0 0 if ($now > $last_parent_check + 5)
963 0 0 if (getppid eq '1')
977 292 6258 if ($opts->{'timeout'})
978 2 290 if ($now > $start_time + $opts->{'timeout'})
991 203 6347 if ($got_sig_child)
992 0 203 if ($now > $got_sig_child + 10)
999 0 6550 if ($got_sig_quit)
1011 106 6444 if ($waitpid ne 0 and $waitpid ne -1)
1015 108 6442 if ($waitpid eq -1)
1027 0 7546 unless $str
1032 7222 324 if ($count) { }
324 0 elsif ($count eq 0) { }
1034 7222 0 if ($data =~ /(.+\n)([^\n]*)/so) { }
1046 0 324 if ($str->{'scalar_buffer'})
1057 322 7224 if ($str->{'protocol'} eq 'info')
1058 107 215 if ($data =~ /^spawned ([0-9]+?)\n(.*?)/so)
1062 105 217 if ($data =~ /^reaped ([0-9]+?)\n(.*?)/so)
1066 2 320 if ($data =~ /^[\d]+ killed with ([0-9]+?)\n(.*?)/so)
1073 0 322 if ($data)
1077 7113 433 if ($str->{'protocol'} eq 'stdout')
1078 7109 4 unless ($opts->{'discard_output'})
1083 2 7111 if ($opts->{'stdout_handler'} and ref $opts->{'stdout_handler'} eq 'CODE')
1087 111 7435 if ($str->{'protocol'} eq 'stderr')
1088 108 3 unless ($opts->{'discard_output'})
1093 2 109 if ($opts->{'stderr_handler'} and ref $opts->{'stderr_handler'} eq 'CODE')
1105 1153 6393 if $child_finished
1108 0 6550 if ($opts->{'wait_loop_callback'} and ref $opts->{'wait_loop_callback'} eq 'CODE')
1127 2 106 if ($child_child_pid)
1144 108 0 if ($opts->{'clean_up_children'})
1158 2 106 $child_timedout ? :
1167 2 106 if ($o->{'exit_code'})
1170 2 106 if ($o->{'timeout'})
1173 0 108 if ($o->{'parent_died'})
1176 103 5 if ($o->{'stdout'} and not $opts->{'non_empty_stdout_ok'})
1179 2 106 if ($o->{'stderr'})
1182 2 106 if ($o->{'killed_by_signal'})
1187 0 108 if ($orig_sig_child) { }
1199 0 0 unless defined $pid
1207 0 0 if POSIX::setsid() == -1
1209 0 0 if ($opts->{'child_BEGIN'} and ref $opts->{'child_BEGIN'} eq 'CODE')
1221 0 0 if (not ref $cmd) { }
0 0 elsif (ref $cmd eq 'CODE') { }
1253 0 0 if ($opts->{'child_END'} and ref $opts->{'child_END'} eq 'CODE')
1276 40 40 unless not ref $_[0]
1281 0 80 unless (check($tmpl, \%hash, $IPC::Cmd::VERBOSE))
1290 0 80 if ($IPC::Cmd::ALLOW_NULL_ARGS) { }
1291 0 0 if ref $cmd
1294 144 0 if defined $_
40 40 if ref $cmd
1297 40 40 ref $cmd ? :
1298 0 80 if $verbose
1312 0 32 unless defined $buf
1314 0 32 if $verbose
1322 0 8 unless defined $buf
1324 0 8 if $verbose
1331 40 40 $self->can_capture_buffer ? :
1346 0 80 if $timeout
1347 80 0 unless alarm $timeout
1350 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)) { }
1353 0 0 if $IPC::Cmd::DEBUG
1362 0 40 if $IPC::Cmd::DEBUG
1376 0 40 if $IPC::Cmd::DEBUG
1386 80 0 if $self->_fds
1389 0 80 unless ($ok)
1391 0 0 if ($@ and ref $@ and $@->isa('IPC::Cmd::TimeOut')) { }
1401 40 40 if @buffer
1406 20 20 $have_buffer ? :
40 40 wantarray ? :
1423 0 0 unless socketpair $_[0], $_[1], &Socket::AF_UNIX, &Socket::SOCK_STREAM, &Socket::PF_UNSPEC
1435 0 0 unless &$pipe(*TO_CHLD_R, *TO_CHLD_W)
1436 0 0 unless &$pipe(*FR_CHLD_R, *FR_CHLD_W)
1437 0 0 unless &$pipe(*FR_CHLD_ERR_R, *FR_CHLD_ERR_W)
1444 0 0 if defined $_
0 0 if ref $cmd
1447 0 0 ref $cmd ? :
1469 0 0 if (not $bytes_read) { }
1484 0 0 if ($?) { }
1531 12 28 ref $cmd ? :
1540 0 40 if ($@ and $@ =~ /^open3:/)
1556 40 0 if UNIVERSAL::can($kidout, 'autoflush')
1557 40 0 if UNIVERSAL::can($kiderror, 'autoflush')
1573 0 120 unless (defined $len)
1581 32 88 if $len and $h == $kidout
1582 8 112 if $len and $h == $kiderror
1586 40 80 if $h == $kidout and $len == 0
1587 40 80 if $h == $kiderror and $len == 0
1588 40 80 if $stdout_done and $stderr_done
1600 0 40 if ($?) { }
1645 0 0 if (ref $cmd) { }
1648 0 0 if ($item =~ /$re/) { }
1658 0 0 if ($_ =~ /$re/) { }
1662 0 0 /[ ]/ ? :
1696 0 0 if ($ok) { }
1705 0 0 if ($@ and not UNIVERSAL::isa($@, 'IPC::Cmd::TimeOut')) { }
0 0 elsif ($@) { }
1731 0 40 $verbose ? :
1737 12 28 ref $cmd ? :
0 40 unless (system(ref $cmd ? @$cmd : $cmd) == 0)
1745 0 40 unless $self->ok
1757 16 64 if (ref $cmd and grep {$sc_lookup{$_};} @$cmd)
1762 8 80 / / ? :
1764 0 16 if $IPC::Cmd::DEBUG and $fixed
1786 0 0 scalar @args == 1 && UNIVERSAL::isa($args[0], 'ARRAY') ? :
1791 0 0 unless $got_arrayref or scalar @args > 1
1793 0 0 $got_arrayref ? :
1796 0 0 if (m[^[^/\"]])
1801 0 0 $got_arrayref ? :
1805 0 0 $got_arrayref ? :
1807 0 0 $got_arrayref ? :
1827 0 0 unless defined $_ and length $_
1837 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) { }
1857 0 0 if defined $arg and length $arg
1867 0 0 if defined $arg and length $arg
1887 0 80 if $IPC::Cmd::DEBUG
1890 0 120 unless my($redir, $fh, $glob) = @{$Map{$name};}
1896 0 120 unless open $glob, $redir . fileno($fh)
1905 80 40 if ($redir eq '>&')
1906 0 80 unless open $fh, '>' . 'File::Spec'->devnull
1921 0 80 if $IPC::Cmd::DEBUG
1924 0 120 unless my($redir, $fh, $glob) = @{$Map{$name};}
1930 0 120 unless open $fh, $redir . fileno($glob)
1945 0 0 unless my $msg = shift()
1956 0 0 unless my $cmd = shift()
1957 0 0 unless my $ce = shift()
1958 0 0 ref $cmd ? :
1962 0 0 if ($ce == -1) { }
0 0 elsif ($ce & 127) { }
1970 0 0 $ce & 128 ? :
1978 0 0 if $IPC::Cmd::DEBUG