Branch Coverage

blib/lib/Shell/Cmd.pm
Criterion Covered Total %
branch 250 374 66.5


line true false branch
56 65 3 unless @opts
81 66 2 if ($all or $opts{'opts'})
159 66 2 if ($all or $opts{'commands'})
206 66 2 if $all or $opts{'env'}
208 65 3 if ($all or $opts{'out'})
223 4 2 unless defined $dire
230 59 2 unless defined $mode
237 4 12 unless @tmp
257 62 185 if ($opt eq 'mode') { }
12 173 elsif ($opt eq 'dire') { }
6 167 elsif ($opt eq 'output') { }
26 141 elsif ($opt eq 'script') { }
4 137 elsif ($opt eq 'echo') { }
13 124 elsif ($opt eq 'failure') { }
1 123 elsif ($opt =~ s/^ssh://) { }
2 121 elsif ($opt eq 'ssh_num' or $opt eq 'ssh_sleep') { }
120 1 elsif ($opt eq 'tmp_script' or $opt eq 'tmp_script_keep' or $opt eq 'ssh_script' or $opt eq 'ssh_script_keep') { }
259 61 1 if (lc($val) =~ /^(run|dry-run|script)$/)
270 5 1 if (lc($val) =~ /^(both|merged|stdout|stderr|quiet)$/)
277 25 1 if (lc($val) =~ /^(run|script|simple)$/)
284 3 1 if (lc($val) =~ /^(echo|noecho|failed)$/)
291 12 1 if (lc($val) =~ /^(exit|display|continue)$/)
337 1 181 if (ref $cmd ne '' and ref $cmd ne 'ARRAY')
345 179 2 if (@args and ref $args[0] eq 'HASH')
350 2 82 unless ($opt =~ /^(dire|noredir|retry|sleep|check|label)$/)
355 1 81 if ($opt eq 'dire') { }
366 0 179 if $err
371 7 172 if (ref $cmd eq 'ARRAY') { }
373 7 0 if ($n > $self->{'max_alt'})
394 7 172 if ref $cmd
402 6 166 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*$/) { }
22 144 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*$/) { }
408 2 4 if ($flow eq 'if') { }
2 2 elsif ($flow eq 'fi') { }
426 11 11 if ($flow eq 'while' or $flow eq 'until' or $flow eq 'for') { }
445 0 112 if (exists $self->{'cmd'}{$cmd_num}{$opt})
451 0 28 if $err
457 57 15 unless @flow
472 0 13 if ($flow ne $curr_flow)
484 0 2 if ($flow ne $curr_flow)
493 0 57 if $self->{'err'}
495 0 57 if ($curr_flow)
508 0 57 if ($self->_cmd_valid_script)
519 24 33 if $self->{'g'}{'mode'} eq 'dry-run'
526 0 33 unless ($tmp_script)
533 33 0 if ($out->open("> $tmp_script")) { }
541 29 4 if ($self->{'g'}{'mode'} eq 'run')
545 0 29 unless ($self->{'g'}{'tmp_script_keep'})
559 4 0 if ($self->{'g'}{'out'} and $self->{'g'}{'err'}) { }
0 0 elsif ($self->{'g'}{'out'}) { }
0 0 elsif ($self->{'g'}{'err'}) { }
572 0 4 unless ($self->{'g'}{'tmp_script_keep'})
576 4 0 if $stdout
577 4 0 if $stderr
607 5 52 if ($self->{'g'}{'simple'})
617 1 4 if $self->{'g'}{'simple'} eq 'simple'
640 5 56 if ($simple) { }
646 5 56 if ($simple) { }
695 56 5 unless $simple
714 5 56 if ($simple) { }
760 24 33 if ($self->{'g'}{'mode'} eq 'dry-run') { }
762 1 23 if ($self->{'g'}{'script'} eq 'simple') { }
2 21 elsif ($self->{'g'}{'s_type'} eq 'run' and $self->{'g'}{'failure'} eq 'display') { }
772 2 31 if ($self->{'g'}{'s_type'} eq 'run' and $self->{'g'}{'failure'} eq 'display') { }
785 29 28 if ($self->{'g'}{'mode'} eq 'run') { }
796 1 56 if ($self->{'g'}{'s_type'} eq 'simple') { }
815 56 1 if ($self->{'g'}{'s_type'} eq 'run' or $self->{'g'}{'s_type'} eq 'script') { }
818 52 4 if ($self->{'g'}{'output'} eq 'both') { }
1 3 elsif ($self->{'g'}{'output'} eq 'merged') { }
1 2 elsif ($self->{'g'}{'output'} eq 'stdout') { }
1 1 elsif ($self->{'g'}{'output'} eq 'stderr') { }
1 0 elsif ($self->{'g'}{'output'} eq 'quiet') { }
866 28 162 if ($self->{'cmd'}{$cmd_num}{'flow'}) { }
878 13 15 if ($type eq 'open') { }
2 13 elsif ($type eq 'cont') { }
897 6 156 if ($n > 1) { }
945 16 146 if $self->{'c'}{'c_retries'} and not $self->{'c'}{'simp'}
996 184 16 unless ($self->{'c'}{'simp'})
997 156 28 unless ($self->{'c'}{'c_flow'})
1050 28 172 if ($self->{'c'}{'c_flow'}) { }
16 156 elsif ($self->{'c'}{'simp'}) { }
1102 0 16 $label ? :
1112 0 190 $cmd_num > 200 ? :
1116 18 172 $self->{'cmd'}{$cmd_num}{'retry'} ? :
1119 0 190 $self->{'cmd'}{$cmd_num}{'sleep'} ? :
1125 182 8 $self->{'cmd'}{$cmd_num}{'noredir'} || $simple || !$self->{'g'}{'redir'} ? :
1127 8 182 $self->{'cmd'}{$cmd_num}{'check'} ? :
1131 0 190 $self->{'cmd'}{$cmd_num}{'dir'} ? :
1134 0 190 if $self->{'c'}{'c_retries'} == 1
1137 16 174 if $simple
1139 28 162 $self->{'cmd'}{$cmd_num}{'flow'} ? :
1145 0 190 if (not $cmd_num) { }
184 6 elsif ($n == 1) { }
1165 65 119 $label ? :
1213 4161 9863 if ($tagstr =~ /^(.*?)=(.*)$/) { }
1215 514 3647 if ($self->_tagval($tag) eq $req) { }
1216 68 446 if $not
1218 3131 516 unless $not
1223 968 8895 if ($self->_tagval($tag)) { }
1224 473 495 if $not
1226 4656 4239 unless $not
1237 1139 4666 unless ($cmd)
1243 897 3769 if $line_ind eq ''
1245 844 3822 if ($len > $line_ind) { }
860 2962 elsif ($len < $line_ind) { }
1263 8220 6875 if (exists $self->{'c'}{$tag}) { }
4769 2106 elsif (exists $self->{'g'}{$tag}) { }
1269 2106 12989 unless defined $val
1285 121 1798 $self->{'g'}{'ind_cur_lev'} == 0 ? :
1302 0 931 if $self->{'g'}{'ind_cur_lev'} < 0
1312 8 1 if ($ENV{'SHELL_CMD_TESTING'})
1316 1 0 $err ? :
1317 1 0 $err ? :
1380 0 28 unless ($out_hdr =~ /^\#SC CMD (\d+)\.(\d+)$/)
1389 10 56 if ($out[0] =~ /^\#SC TRY (\d+)$/) { }
12 44 elsif ($out[0] =~ /^\#SC EXIT $cmd_num\.$alt_num (\d+)$/) { }
1402 25 3 if not defined $output[$#output] or $output[$#output] eq ''
1472 12 8 if ($alt_next <= 1 and $try_next == 0)
1491 4 4 if ($cmd_next == $cmd_curr and $alt_next == $alt_curr + 1 and $try_next == $try_curr)
1506 4 0 if ($cmd_next == $cmd_curr and $alt_next <= 1 and $try_next == $try_curr + 1)
1543 0 0 unless (@hosts)
1548 0 0 if ($self->_cmd_valid_script)
1559 0 0 if $self->{'g'}{'mode'} eq 'dry-run'
1566 0 0 unless ($tmp_script)
1573 0 0 if ($out->open("> $tmp_script")) { }
1585 0 0 if ($self->{'g'}{'ssh_num'} == 1) { }
1591 0 0 unless ($self->{'g'}{'tmp_script_keep'})
1613 0 0 $self->{'g'}{'ssh_num'} ? :
1622 0 0 if $stdout
1623 0 0 if $stderr
1629 0 0 if $manager->start
1647 0 0 unless $ssh->scp_put($script_loc, $script_rem)
1653 0 0 if ($self->{'g'}{'ssh_sleep'})
1655 0 0 if ($n < 0) { }
1666 0 0 if ($self->{'g'}{'mode'} eq 'run')
1670 0 0 unless ($self->{'g'}{'ssh_script_keep'})
1682 0 0 if ($self->{'g'}{'err'}) { }
0 0 elsif ($self->{'g'}{'out'}) { }
1684 0 0 unless $self->{'g'}{'out'}
1693 0 0 unless ($self->{'g'}{'ssh_script_keep'})
1705 0 47 exists $options{'host'} ? :
1706 47 0 exists $options{'output'} ? :
1707 47 0 exists $options{'command'} ? :
1709 0 47 unless ($type =~ /^(stdout|stderr|command|num|label|exit)$/)
1718 0 47 if ($host)
1720 0 0 unless (@all)
1729 0 0 if ($host eq 'all' or $host =~ /,/)
1731 0 0 $host eq 'all' ? :
1736 0 0 unless (exists $self->{'s'}{$host})
1748 0 0 unless (exists $self->{'s'}{$host})
1770 47 0 exists $output->{'out'} ? :
1771 47 0 exists $output->{'err'} ? :
1772 0 47 $no > $ne ? :
1774 6 41 if ($cmd eq 'curr') { }
1 40 elsif ($cmd eq 'next') { }
19 21 elsif ($cmd eq 'all') { }
15 6 elsif ($cmd eq 'fail') { }
6 0 elsif ($cmd =~ /^\d+$/) { }
1788 30 0 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
0 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1789 9 21 if ($output->{'out'}[$i][1])
1795 0 0 if ($output->{'err'}[$i][1])
1806 12 0 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
0 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1807 6 6 if ($output->{'out'}[$i][0] eq $cmd)
1812 0 0 if ($output->{'err'}[$i][0] eq $cmd)
1822 0 0 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
0 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1824 0 0 if ($self->{'cmd'}{$n}{'label'} eq $cmd)
1830 0 0 if ($self->{'cmd'}{$n}{'label'} eq $cmd)
1837 6 41 unless @c
1846 14 54 if ($type eq 'stdout') { }
4 50 elsif ($type eq 'stderr') { }
14 36 elsif ($type eq 'command') { }
15 21 elsif ($type eq 'num') { }
7 14 elsif ($type eq 'label') { }
14 0 elsif ($type eq 'exit') { }
1848 14 0 if (exists $output->{'out'} and defined $output->{'out'}[$i])
1862 4 0 if (exists $output->{'err'} and defined $output->{'err'}[$i])
1876 14 0 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
0 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1885 15 0 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
0 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1894 7 0 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
0 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }
1903 14 0 if (exists $output->{'out'} and defined $output->{'out'}[$i]) { }
0 0 elsif (exists $output->{'err'} and defined $output->{'err'}[$i]) { }