Branch Coverage

lib/Shell/Cmd.pm
Criterion Covered Total %
branch 293 370 80.2


line true false branch
59 85 4 unless @opts
84 86 3 if ($all or $opts{'opts'})
162 86 3 if ($all or $opts{'commands'})
209 86 3 if $all or $opts{'env'}
211 86 3 if ($all or $opts{'out'})
226 4 2 unless defined $dire
233 73 2 unless defined $mode
240 4 15 unless @tmp
260 75 237 if ($opt eq 'mode') { }
18 219 elsif ($opt eq 'dire') { }
11 208 elsif ($opt eq 'output') { }
27 181 elsif ($opt eq 'script') { }
4 177 elsif ($opt eq 'echo') { }
13 164 elsif ($opt eq 'failure') { }
1 163 elsif ($opt =~ s/^ssh://) { }
2 161 elsif ($opt eq 'ssh_num' or $opt eq 'ssh_sleep') { }
160 1 elsif ($opt eq 'tmp_script' or $opt eq 'tmp_script_keep' or $opt eq 'ssh_script' or $opt eq 'ssh_script_keep') { }
262 74 1 if (lc($val) =~ /^(run|dry-run|script)$/)
273 10 1 if (lc($val) =~ /^(both|merged|stdout|stderr|quiet)$/)
280 26 1 if (lc($val) =~ /^(run|script|simple)$/)
287 3 1 if (lc($val) =~ /^(echo|noecho|failed)$/)
294 12 1 if (lc($val) =~ /^(exit|display|continue)$/)
340 1 483 if (ref $cmd ne '' and ref $cmd ne 'ARRAY')
348 106 377 if (@args and ref $args[0] eq 'HASH')
353 2 112 unless ($opt =~ /^(dire|noredir|retry|sleep|check|label)$/)
358 3 109 if ($opt eq 'dire') { }
369 6 475 if $err
374 10 465 if (ref $cmd eq 'ARRAY') { }
376 9 1 if ($n > $self->{'max_alt'})
397 10 471 if ref $cmd
405 17 454 if ($cmd =~ /^\s*(if)\s+.*?;\s*then\s*$/ or $cmd =~ /^\s*(elif)\s+.*?;\s*then\s*$/ or $cmd =~ /^\s*(else)\s*$/ or $cmd =~ /^\s*(fi)\s*$/) { }
24 430 elsif ($cmd =~ /^\s*(while)\s+.*?;\s*do\s*$/ or $cmd =~ /^\s*(until)\s+.*?;\s*do\s*$/ or $cmd =~ /^\s*(for)\s+.*?;\s*do\s*$/ or $cmd =~ /^\s*(done)\s*$/) { }
411 7 10 if ($flow eq 'if') { }
3 7 elsif ($flow eq 'fi') { }
429 13 11 if ($flow eq 'while' or $flow eq 'until' or $flow eq 'for') { }
448 4 154 if (exists $self->{'cmd'}{$cmd_num}{$opt})
454 2 35 if $err
461 69 22 unless @flow
476 1 13 if ($flow ne $curr_flow)
488 1 6 if ($flow ne $curr_flow)
497 1 70 if $self->{'err'}
499 1 69 if ($curr_flow)
512 2 69 if ($self->_cmd_valid_script)
523 26 43 if $self->{'g'}{'mode'} eq 'dry-run'
530 1 42 unless ($tmp_script)
537 41 1 if ($out->open("> $tmp_script")) { }
546 33 8 if ($self->{'g'}{'mode'} eq 'run')
550 1 32 unless ($self->{'g'}{'tmp_script_keep'})
568 5 3 if ($self->{'g'}{'out'} and $self->{'g'}{'err'}) { }
1 2 elsif ($self->{'g'}{'err'}) { }
578 1 7 unless ($self->{'g'}{'tmp_script_keep'})
582 7 1 if $stdout
583 6 2 if $stderr
613 6 63 if ($self->{'g'}{'simple'})
623 2 4 if $self->{'g'}{'simple'} eq 'simple'
646 6 67 if ($simple) { }
652 6 67 if ($simple) { }
701 67 6 unless $simple
720 6 67 if ($simple) { }
766 26 43 if ($self->{'g'}{'mode'} eq 'dry-run') { }
767 25 1 $self->{'g'}{'script'} ? :
768 2 24 if ($self->{'g'}{'script'} eq 'simple') { }
2 22 elsif ($self->{'g'}{'s_type'} eq 'run' and $self->{'g'}{'failure'} eq 'display') { }
778 2 41 if ($self->{'g'}{'s_type'} eq 'run' and $self->{'g'}{'failure'} eq 'display') { }
791 35 34 if ($self->{'g'}{'mode'} eq 'run') { }
802 2 67 if ($self->{'g'}{'s_type'} eq 'simple') { }
821 67 2 if ($self->{'g'}{'s_type'} eq 'run' or $self->{'g'}{'s_type'} eq 'script') { }
824 59 8 if ($self->{'g'}{'output'} eq 'both') { }
1 7 elsif ($self->{'g'}{'output'} eq 'merged') { }
2 5 elsif ($self->{'g'}{'output'} eq 'stdout') { }
2 3 elsif ($self->{'g'}{'output'} eq 'stderr') { }
877 30 442 if ($self->{'cmd'}{$cmd_num}{'flow'}) { }
889 13 17 if ($type eq 'open') { }
4 13 elsif ($type eq 'cont') { }
908 9 433 if ($n > 1) { }
956 18 424 if $self->{'c'}{'c_retries'} and not $self->{'c'}{'simp'}
1007 469 18 unless ($self->{'c'}{'simp'})
1008 439 30 unless ($self->{'c'}{'c_flow'})
1062 30 457 if ($self->{'c'}{'c_flow'}) { }
18 439 elsif ($self->{'c'}{'simp'}) { }
1115 2 22 $label ? :
1125 50 422 $cmd_num > 200 ? :
1129 23 449 $self->{'cmd'}{$cmd_num}{'retry'} ? :
1132 1 471 $self->{'cmd'}{$cmd_num}{'sleep'} ? :
1138 456 16 $self->{'cmd'}{$cmd_num}{'noredir'} || $simple || !$self->{'g'}{'redir'} ? :
1140 8 464 $self->{'cmd'}{$cmd_num}{'check'} ? :
1144 1 471 $self->{'cmd'}{$cmd_num}{'dire'} ? :
1147 3 469 if $self->{'c'}{'c_retries'} == 1
1150 18 454 if $simple
1152 30 442 $self->{'cmd'}{$cmd_num}{'flow'} ? :
1158 463 9 if ($n == 1)
1166 81 382 $label ? :
1214 11902 25857 if ($tagstr =~ /^(.*?)=(.*)$/) { }
1216 731 11171 if ($self->_tagval($tag) eq $req) { }
1217 68 663 if $not
1219 9543 1628 unless $not
1224 1168 24689 if ($self->_tagval($tag)) { }
1225 544 624 if $not
1227 12632 12057 unless $not
1238 2867 11638 unless ($cmd)
1244 2069 9569 if $line_ind eq ''
1246 2278 9360 if ($len > $line_ind) { }
2296 7064 elsif ($len < $line_ind) { }
1264 22070 18241 if (exists $self->{'c'}{$tag}) { }
12495 5746 elsif (exists $self->{'g'}{$tag}) { }
1270 5746 34565 unless defined $val
1286 144 4685 $self->{'g'}{'ind_cur_lev'} == 0 ? :
1312 8 5 if ($ENV{'SHELL_CMD_TESTING'})
1379 0 50 unless ($out_hdr =~ /^\#SC CMD (\d+)\.(\d+)$/)
1390 20 94 if ($out[0] =~ /^\#SC TRY (\d+)$/) { }
20 74 elsif ($out[0] =~ /^\#SC EXIT $cmd_num\.$alt_num (\d+)$/) { }
1403 44 6 if not defined $output[$#output] or $output[$#output] eq ''
1477 21 16 if ($alt_next <= 1 and $try_next == 0)
1492 0 16 if ($cmd_next != $cmd_curr)
1502 8 8 if ($alt_next == $alt_curr + 1)
1505 0 8 if ($try_next != $try_curr)
1523 0 8 if ($alt_next > 1)
1529 0 8 if ($try_next != $try_curr + 1)
1569 0 0 unless (@hosts)
1574 0 0 if ($self->_cmd_valid_script)
1585 0 0 if $self->{'g'}{'mode'} eq 'dry-run'
1592 0 0 unless ($tmp_script)
1599 0 0 if ($out->open("> $tmp_script")) { }
1612 0 0 if ($self->{'g'}{'ssh_num'} == 1) { }
1618 0 0 unless ($self->{'g'}{'tmp_script_keep'})
1640 0 0 $self->{'g'}{'ssh_num'} ? :
1649 0 0 if defined $stdout
1651 0 0 if defined $stderr
1658 0 0 if $manager->start
1676 0 0 unless $ssh->scp_put($script_loc, $script_rem)
1682 0 0 if ($self->{'g'}{'ssh_sleep'})
1684 0 0 if ($n < 0) { }
1695 0 0 if ($self->{'g'}{'mode'} eq 'run')
1699 0 0 unless ($self->{'g'}{'ssh_script_keep'})
1711 0 0 if ($self->{'g'}{'err'}) { }
0 0 elsif ($self->{'g'}{'out'}) { }
1713 0 0 unless $self->{'g'}{'out'}
1722 0 0 unless ($self->{'g'}{'ssh_script_keep'})
1734 0 141 exists $options{'host'} ? :
1735 141 0 exists $options{'output'} ? :
1736 141 0 exists $options{'command'} ? :
1738 0 141 unless ($type =~ /^(stdout|stderr|command|num|label|exit)$/)
1747 0 141 if ($host)
1749 0 0 unless (@all)
1758 0 0 if ($host eq 'all' or $host =~ /,/)
1760 0 0 $host eq 'all' ? :
1765 0 0 unless (exists $self->{'s'}{$host})
1777 0 0 unless (exists $self->{'s'}{$host})
1799 116 25 exists $output->{'out'} ? :
1800 91 50 exists $output->{'err'} ? :
1801 50 91 $no > $ne ? :
1803 26 115 if ($cmd eq 'curr') { }
5 110 elsif ($cmd eq 'next') { }
43 67 elsif ($cmd eq 'all') { }
38 29 elsif ($cmd eq 'fail') { }
29 0 elsif ($cmd =~ /^\d+$/) { }
1817 74 12 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
12 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1818 9 65 if ($output->{'out'}[$i][1])
1824 0 12 if ($output->{'err'}[$i][1])
1835 56 12 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
12 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1836 23 33 if ($output->{'out'}[$i][0] eq $cmd)
1841 6 6 if ($output->{'err'}[$i][0] eq $cmd)
1851 0 0 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
0 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1853 0 0 if ($self->{'cmd'}{$n}{'label'} eq $cmd)
1859 0 0 if ($self->{'cmd'}{$n}{'label'} eq $cmd)
1866 29 112 unless @c
1875 31 144 if ($type eq 'stdout') { }
21 123 elsif ($type eq 'stderr') { }
31 92 elsif ($type eq 'command') { }
37 55 elsif ($type eq 'num') { }
23 32 elsif ($type eq 'label') { }
32 0 elsif ($type eq 'exit') { }
1877 27 4 if (exists $output->{'out'} and defined $output->{'out'}[$i])
1891 13 8 if (exists $output->{'err'} and defined $output->{'err'}[$i])
1905 27 4 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
4 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1914 32 5 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
5 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1923 19 4 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
4 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1932 28 4 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
4 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }