Branch Coverage

blib/lib/Doit.pm
Criterion Covered Total %
branch 462 732 63.1


line true false branch
41 2 43 if defined $can_coloring
46 43 0 !(($ENV{'TERM'} || '') =~ /^(|dumb)$/) && eval { do { require Term::ANSIColor; 1 } } ? :
51 43 0 if (_can_coloring()) { }
71 1 1 if (defined $label) { }
89 54 0 if ($level eq "auto")
93 0 310 unless (@stackinfo)
97 54 256 unless ($stackinfo[1] =~ m(([/\\]|^)Doit\.pm$))
113 2 29 unless defined $msg
114 29 2 unless ($msg =~ /\n\z/)
142 129 0 if ($] >= 5.014) { }
146 4 125 if ($@)
180 102 200 if (defined $dir)
183 2 100 if (not defined $pwd or $pwd eq '') { }
188 2 98 unless chdir $pwd
191 3 99 unless chdir $dir
200 6 59 ref $src eq 'ARRAY' ? :
201 0 65 unless @stat
204 22 43 exists $preserve{'ownership'} ? :
205 23 42 exists $preserve{'mode'} ? :
206 1 64 exists $preserve{'time'} ? :
208 0 65 if %preserve
210 62 3 if ($preserve_mode)
211 0 62 unless chmod $stat[2], $dest
214 62 3 if ($preserve_ownership)
216 0 62 unless (chown $stat[4], $stat[5], $dest)
223 41 24 if ($preserve_time)
224 0 41 unless utime $stat[8], $stat[9], $dest
233 0 0 if $> == 0
248 0 0 if (_has_shell_metachars($args))
265 0 0 if ($text ne '' and not $text =~ /[ \t\n\x0a\x0b\x0c\x0d\x85"]/) { }
276 0 0 if ($i > $#text) { }
0 0 elsif ($text[$i] eq '"') { }
300 0 0 if ($char eq '%') { }
0 0 elsif ($char eq q['] or $char eq '"') { }
0 0 elsif ($char eq '<' or $char eq '>' or $char eq '|') { }
303 0 0 if ($inquote) { }
304 0 0 if ($char eq $quote)
313 0 0 unless ($inquote)
365 7 31 if ($dry_run) { }
374 2 0 unless ($msg)
375 2 0 $args ? :
381 2 1 if (&$check($self, \@args, $addinfo))
395 17 16 if (@args and ref $args[0] eq "HASH")
397 0 33 if %options
402 32 4 if (@s) { }
403 29 3 if (($s[2] & 4095) != $mode)
410 30 3 if (@files_to_change) { }
414 3 24 if ($changed_files != @files_to_change)
415 1 2 if (@files_to_change == 1) { }
1 1 elsif ($changed_files == 0) { }
424 16 14 $quiet ? :
435 2 10 if (@args and ref $args[0] eq "HASH")
437 0 12 if %options
440 3 9 if (not defined $uid) { }
2 7 elsif (not $uid =~ /^-?\d+$/) { }
444 1 1 unless (defined $_uid)
455 6 5 if (not defined $gid) { }
1 4 elsif (not $gid =~ /^-?\d+$/) { }
459 1 0 unless (defined $_gid)
466 9 1 if ($uid != -1 or $gid != -1)
469 7 3 if (@s) { }
470 0 7 if ($uid != -1 and $s[4] != $uid) { }
0 12 elsif ($gid != -1 and $s[5] != $gid) { }
481 2 8 if (@files_to_change) { }
485 2 0 if ($changed_files != @files_to_change)
486 1 1 if (@files_to_change == 1) { }
1 0 elsif ($changed_files == 0) { }
495 0 2 $quiet ? :
510 1 11 if %opts
512 1 10 unless ($cmd)
515 1 9 if (ref $cmd ne "ARRAY")
520 2 7 if ($if and not &$if())
523 1 6 if ($doit and $unless and &$unless())
526 1 5 if ($doit and $creates and -e $creates)
530 5 4 if ($doit) { }
532 0 5 if (ref $cmd->[0] eq 'ARRAY') { }
548 1 5 if (not defined $oldfile) { }
1 4 elsif (not defined $newfile) { }
2 2 elsif (-l $newfile) { }
1 1 elsif (-d $newfile) { }
553 0 2 unless my $points_to = readlink $newfile
555 1 1 if ($points_to eq $oldfile)
567 2 1 if ($doit) { }
571 0 2 if $? != 0
584 1 2 if (ref $directories[-1] eq "HASH")
586 2 1 if (@directories_to_create) { }
590 0 2 unless File::Path::make_path(@directories_to_create, $options)
604 18 2 if (not -d $directory) { }
606 2 16 if (defined $mode) { }
608 1 1 unless mkdir $directory, $mode
614 1 15 unless mkdir $directory
627 1 3 if (ref $directories[-1] eq "HASH")
629 3 1 if (@directories_to_remove) { }
633 0 3 unless File::Path::remove_tree(@directories_to_remove, $options)
649 1 12 unless rename $from, $to
658 3 14 if (@args and ref $args[0] eq "HASH")
660 1 16 if %options
661 1 15 if (@args != 2)
667 4 11 if (-d $to) { }
673 11 4 if (not -e $real_to or do { require File::Compare; File::Compare::compare($from, $real_to) != 0 }) { }
677 2 9 unless File::Copy::copy($from, $to)
681 7 4 if (not -e $real_to) { }
684 1 3 if ($quiet) { }
687 0 3 if (eval { do { require IPC::Run; 1 } }) { }
689 0 0 if (eval { do { IPC::Run::run(['diff', '-u', $real_to, $from], '>', \$diff); 1 } }) { }
692 0 0 !$diff_error_shown++ ? :
714 1 1 unless File::Copy::move($from, $to)
724 1 49 if ($? == -1) { }
8 41 elsif ($? & 127) { }
732 0 8 $? & 128 ? :
750 0 46 if %opts
754 22 24 if (defined $prefix_msg)
762 42 94 if ($flag) { }
772 8 3 if (@args and ref $args[0] eq "HASH")
775 6 5 unless defined $instr
776 0 11 if %options
791 1 2 $quiet || $info ? :
3 7 unless $? == 0
798 4 7 $info ? :
1 9 $quiet ? :
806 1 2 if (@args and ref $args[0] eq "HASH")
813 36 2 if (@args and ref $args[0] eq "HASH")
819 0 38 if %options
830 26 11 defined $instr ? :
831 26 10 if (defined $instr)
845 72 33 if ($buf eq '') { }
848 36 36 if $sel->count == 0
857 29 7 if ($errref)
861 2 34 if ($statusref) { }
864 4 30 if ($? != 0)
865 1 3 $quiet || $info ? :
874 4 34 $info ? :
23 14 $quiet ? :
882 1 2 if (@args and ref $args[0] eq "HASH")
891 0 154 unless open my $fh, "-|", @args
901 138 6 if (@args and ref $args[0] eq "HASH")
905 0 144 if %options
909 2 141 if ($statusref) { }
912 22 119 if ($? != 0)
913 20 2 $quiet || $info ? :
921 135 9 $info ? :
113 11 $quiet ? :
929 131 3 if (@args and ref $args[0] eq "HASH")
936 5 1 if (-d $directory) { }
938 1 4 unless rmdir $directory
954 0 0 if (not $success)
961 0 0 if (ref $arg eq 'ARRAY') { }
976 2 1 if (not defined $ENV{$key} or $ENV{$key} ne $val) { }
979 1 1 defined $ENV{$key} ? :
991 1 1 if (-l $newfile) { }
1 0 elsif (not -e $newfile) { }
992 0 1 unless my $points_to = readlink $newfile
994 0 1 if ($points_to ne $oldfile)
1002 1 1 if ($doit) { }
1004 0 1 unless symlink $oldfile, $newfile
1016 46 92 if (@args and ref $args[0] eq "HASH")
1020 0 138 if %options
1026 17 120 if ($? != 0)
1038 2 136 $info ? :
2 136 $quiet ? :
1050 0 1 if (@args and ref $args[0] eq "HASH")
1059 28 1 if (not -e $file) { }
1061 0 28 unless open my $fh, ">>", $file
1066 0 1 unless utime time, time, $file
1080 15 2 unless (-e $file)
1082 0 15 unless open my $fh, ">>", $file
1087 14 1 if (@commands) { }
1100 25 3 if (-e $file or -l $file)
1104 18 2 if (@files_to_remove) { }
1106 0 18 unless unlink @files_to_remove
1117 1 1 if (defined $ENV{$key}) { }
1133 1 9 unless (defined $atime)
1136 1 9 unless (defined $mtime)
1143 10 4 if (@s) { }
1144 9 1 if ($s[8] != $atime or $s[9] != $mtime)
1152 9 1 if (@files_to_change) { }
1156 3 6 if ($changed_files != @files_to_change)
1157 1 2 if (@files_to_change == 1) { }
1 1 elsif ($changed_files == 0) { }
1177 12 20 if (@args and ref $args[0] eq "HASH")
1179 1 31 exists $options{'atomic'} ? :
1180 1 31 if %options
1181 1 30 if (@args != 2)
1188 13 17 if (not -e $filename) { }
12 5 elsif (-s $filename != length $content) { }
1194 0 5 unless open my $fh, "<", $filename
1199 1 4 if ($file_content ne $content)
1205 26 4 if ($doit) { }
1211 25 1 $atomic ? :
1212 1 25 unless open my $ofh, ">", $outfile
1214 13 12 if (-e $filename)
1219 0 25 unless close $ofh
1221 24 1 if ($atomic)
1222 0 24 unless rename $outfile, $filename
1229 4 22 $quiet >= 2 ? :
1230 5 17 if ($quiet) { }
1231 2 3 if ($need_diff) { }
1237 8 9 if ($need_diff) { }
1238 0 8 if (eval { do { require IPC::Run; 1 } }) { }
1240 0 0 if (eval { do { IPC::Run::run(['diff', '-u', $filename, '-'], '<', \$content, '>', \$diff); 1 } }) { }
1243 0 0 !$diff_error_shown++ ? :
1247 8 0 if (eval { do { require File::Temp; 1 } }) { }
1250 8 0 if (close $tempfh) { }
1254 8 0 if (length $diff) { }
1282 3 44 if (@args and ref $args[0] eq "HASH")
1285 0 47 if ($check and ref $check ne "CODE")
1286 1 46 if %options
1288 1 45 if (@args < 1)
1293 2 43 unless (-e $file)
1296 2 41 unless (-f $file)
1303 26 20 if ($_->{'add_if_missing'})
1306 10 16 if (defined $_->{'add_after'} or defined $_->{'add_after_first'} or defined $_->{'add_before'} or defined $_->{'add_before_last'}) { }
1317 0 10 if ($defines != 1)
1323 4 6 if (defined $_->{'add_after'}) { }
2 4 elsif (defined $_->{'add_after_first'}) { }
2 2 elsif (defined $_->{'add_before'}) { }
2 0 elsif (defined $_->{'add_before_last'}) { }
1346 4 2 $reverse ? :
1347 4 2 $reverse ? :
1348 4 2 $reverse ? :
1349 11 2 $reverse ? :
1350 5 7 if ($arrayref->[$i] =~ /$add/)
1351 3 2 if ($do_after) { }
1360 1 5 if (not $found)
1373 29 17 if ($_->{'unless_match'}) { }
16 1 elsif ($_->{'match'}) { }
1374 26 3 if (ref $_->{'unless_match'} ne "Regexp")
1378 1 28 unless ($_->{'action'})
1381 1 27 if (ref $_->{'action'} ne "CODE")
1386 3 13 if (ref $_->{'match'} ne "Regexp")
1390 3 13 $_->{'action'} ? :
7 9 defined $_->{'replace'} ? :
5 11 defined $_->{'delete'} ? :
1391 1 15 if ($consequences != 1)
1394 3 12 if ($_->{'action'}) { }
7 5 elsif (defined $_->{'replace'}) { }
5 0 elsif (defined $_->{'delete'}) { }
1395 1 2 if (ref $_->{'action'} ne "CODE")
1415 0 36 unless File::Copy::copy($file, $tmpfile)
1420 0 36 unless tie my @lines, "Tie::File", $tmpfile
1427 0 44 if ($debug)
1428 18 26 if ($lines[$line_i] =~ /$match/)
1429 9 9 if (exists $match_action->{'replace'}) { }
6 3 elsif (exists $match_action->{'delete'}) { }
1431 9 0 if ($lines[$line_i] ne $replace)
1437 5 1 if ($match_action->{'delete'})
1455 8 62 if ($line =~ /$match/)
1468 25 10 if ($no_of_changes)
1471 2 22 if ($check)
1475 0 1 unless &$check($tmpfile)
1478 0 23 unless rename $tmpfile, $file
1483 0 25 if (eval { do { require IPC::Run; 1 } }) { }
1484 0 0 unless (eval { do { IPC::Run::run(["diff", "-u", $file, $tmpfile], ">", \$diff); 1 } })
1485 0 0 !$diff_error_shown++ ? :
1496 25 10 if ($no_of_changes) { }
1520 42 0 if (@commands)
1528 387 201 if (exists $command->{'msg'})
1531 554 34 if (exists $command->{'code'})
1533 442 70 if (exists $command->{'rv'}) { }
1546 17 4 if (exists $command->{'msg'})
1549 20 1 if (exists $command->{'code'})
1550 17 3 if (exists $command->{'rv'}) { }
1566 0 38 if %options
1585 22 592 if ($self->{'dryrun'}) { }
1598 3 11 if ($component_or_module =~ /::/) { }
1605 2 4 if $_->{'module'} eq $module
1608 1 11 unless (eval " require $module; 1 ")
1611 0 11 unless my $o = $module->new
1628 0 11 if ($o->can("add_components"))
1658 2 4 if ($context eq 'a') { }
1663 2 4 if ($@) { }
1673 6 0 unless $sub =~ /::/
1680 2 0 unless $sub =~ /::/
1719 0 14 if (not defined $ret) { }
0 14 elsif (not $ret) { }
1725 0 14 unless read $fh, $buf, $length
1740 0 0 unless defined $pid
1741 0 0 if (eval { do { require POSIX; defined &POSIX::WNOHANG } }) { }
1742 0 0 if ($self->{'debug'})
1752 0 0 if (time - $start_time >= 2)
1758 0 0 if (not $got_pid)
1762 0 0 if (not $done_POSIX_warning++)
1778 0 0 if %opts
1782 0 0 if $ret
1784 0 0 if ($fast_tries and eval { do { require Time::HiRes; 1 } }) { }
1789 0 0 $try <= $fast_tries && defined &Time::HiRes::sleep ? :
1790 0 0 if $retry_msg_code
1808 0 1 if %options
1822 2 5 wantarray ? :
1825 2 5 if (defined $rettype and $rettype eq 'e') { }
5 0 elsif (defined $rettype and $rettype eq 'r') { }
1828 2 3 if ($context eq 'a') { }
1834 0 0 defined $self->{'label'} ? :
0 0 defined $rettype ? :
1848 0 0 if %options
1867 0 0 if ($self->{'debug'}) { }
1877 0 0 if (not $self->{'excl'} and -e $sockpath)
1881 0 0 unless my $sock = "IO::Socket::UNIX"->new("Type", SOCK_STREAM(), "Local", $sockpath, "Listen", 1)
1891 0 0 if $ready[0] != $sock
1898 0 0 if (not defined $context) { }
0 0 elsif ($data[0] =~ /^exit$/) { }
1924 0 1 if %options
1926 0 1 unless $infh
1927 0 1 unless $outfh
1941 0 7 if (not defined $context) { }
1 6 elsif ($data[0] =~ /^exit$/) { }
1947 0 6 unless open my $oldout, ">&STDOUT"
1951 0 6 unless open STDOUT, ">", "/dev/stderr"
1954 0 6 unless open STDOUT, ">&", $oldout
1976 0 0 if $^O eq "linux"
1991 0 0 unless (defined $realscript)
1992 0 0 if ($realscript ne '-e') { }
2012 0 0 unless delete $opts{'sudo_opts'}
2015 0 0 unless delete $opts{'components'}
2017 0 0 if %opts
2041 0 0 if ($? != 0)
2052 0 0 $class->_can_LANS ? :
2055 0 0 $debug ? :
0 0 $LANS_PREFIX ? :
0 0 $dry_run ? :
2066 0 0 if (not defined $worker_pid) { }
0 0 elsif ($worker_pid == 0) { }
2069 0 0 if $debug
2079 0 0 if $debug
2103 0 0 unless delete $opts{'components'}
2111 0 0 unless defined $dest_os
2113 0 0 unless $put_to_remote =~ /^(rsync_put|scp_put)$/
2117 0 0 if (defined $umask and not $umask =~ /^\d+$/)
2121 0 0 if %opts
2124 0 0 $forward_agent ? :
0 0 $tty ? :
2128 0 0 $forward_agent ? :
0 0 $master_opts ? :
2134 0 0 if (UNIVERSAL::isa($ssh_or_host, 'Net::OpenSSH')) { }
2140 0 0 if $ssh->error
2145 0 0 if (($bootstrap || '') eq "perl")
2152 0 0 if ($dest_os eq 'MSWin32') { }
2157 0 0 if ($debug)
2162 0 0 if ($FindBin::RealScript ne "-e")
2169 0 0 $dest_os ne 'MSWin32' ? :
2183 0 0 unless ($seen_dir{$target_dir})
2185 0 0 if ($dest_os eq 'MSWin32') { }
2201 0 0 $dest_os eq 'MSWin32' ? :
2208 0 0 if (defined $as)
2209 0 0 if ($as eq 'root') { }
2217 0 0 if ($dest_os eq 'MSWin32') { }
2218 0 0 $debug ? :
0 0 $dry_run ? :
2232 0 0 defined $umask ? :
0 0 $debug ? :
0 0 $dry_run ? :
2246 0 0 if $debug
2251 0 0 if ($dest_os eq 'MSWin32') { }
2266 0 0 if $debug
2279 0 0 if ($self->{'ssh'})
2280 0 0 if $self->{'ssh'}->can("disconnect")
2283 0 0 if ($self->{'rpc'})
2296 0 0 unless defined $peer
2298 0 0 if %options
2308 0 0 if ($debug) { }
2327 0 0 if $sock
2337 0 0 unless ($sock)
2346 0 0 unless read $infh, $length_buf, 4
2352 0 0 if $got == $length
2353 0 0 if $got > $length
2366 0 0 if eof $infh