Branch Coverage

blib/lib/Doit.pm
Criterion Covered Total %
branch 471 760 61.9


line true false branch
41 2 44 if defined $can_coloring
46 44 0 !(($ENV{'TERM'} || '') =~ /^(|dumb)$/) && eval { do { require Term::ANSIColor; 1 } } ? :
51 44 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
240 9 5 unless (defined &Doit::Util::_file_name_is_absolute)
241 0 9 if (eval { do { require File::Spec; defined &File::Spec::file_name_is_absolute } }) { }
247 0 14 if ($^O eq 'MSWin32') { }
257 0 14 if (_file_name_is_absolute($prog))
258 0 0 if ($^O eq 'MSWin32') { }
259 0 0 if -f $prog and -x $prog
260 0 0 if -f "$prog.bat" and -x "$prog.bat"
261 0 0 if -f "$prog.com" and -x "$prog.com"
262 0 0 if -f "$prog.exe" and -x "$prog.exe"
263 0 0 if -f "$prog.cmd" and -x "$prog.cmd"
265 0 0 if -f $prog and -x $prog
272 0 110 if ($^O eq 'MSWin32') { }
274 0 0 if -f "$_\\$prog" and -x "$_\\$prog"
275 0 0 if -f "$_\\$prog.bat" and -x "$_\\$prog.bat"
276 0 0 if -f "$_\\$prog.com" and -x "$_\\$prog.com"
277 0 0 if -f "$_\\$prog.exe" and -x "$_\\$prog.exe"
278 0 0 if -f "$_\\$prog.cmd" and -x "$_\\$prog.cmd"
280 8 102 if -x "$_/$prog" and not -d "$_/$prog"
296 0 0 if (_has_shell_metachars($args))
313 0 0 if ($text ne '' and not $text =~ /[ \t\n\x0a\x0b\x0c\x0d\x85"]/) { }
324 0 0 if ($i > $#text) { }
0 0 elsif ($text[$i] eq '"') { }
348 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 '|') { }
351 0 0 if ($inquote) { }
352 0 0 if ($char eq $quote)
361 0 0 unless ($inquote)
413 7 34 if ($dry_run) { }
422 2 0 unless ($msg)
423 2 0 $args ? :
429 2 1 if (&$check($self, \@args, $addinfo))
443 17 17 if (@args and ref $args[0] eq "HASH")
445 0 34 if %options
450 33 4 if (@s) { }
451 30 3 if (($s[2] & 4095) != $mode)
458 31 3 if (@files_to_change) { }
462 3 25 if ($changed_files != @files_to_change)
463 1 2 if (@files_to_change == 1) { }
1 1 elsif ($changed_files == 0) { }
472 16 15 $quiet ? :
483 2 10 if (@args and ref $args[0] eq "HASH")
485 0 12 if %options
488 3 9 if (not defined $uid) { }
2 7 elsif (not $uid =~ /^-?\d+$/) { }
492 1 1 unless (defined $_uid)
503 6 5 if (not defined $gid) { }
1 4 elsif (not $gid =~ /^-?\d+$/) { }
507 1 0 unless (defined $_gid)
514 9 1 if ($uid != -1 or $gid != -1)
517 7 3 if (@s) { }
518 0 7 if ($uid != -1 and $s[4] != $uid) { }
0 12 elsif ($gid != -1 and $s[5] != $gid) { }
529 2 8 if (@files_to_change) { }
533 2 0 if ($changed_files != @files_to_change)
534 1 1 if (@files_to_change == 1) { }
1 0 elsif ($changed_files == 0) { }
543 0 2 $quiet ? :
558 1 11 if %opts
560 1 10 unless ($cmd)
563 1 9 if (ref $cmd ne "ARRAY")
568 2 7 if ($if and not &$if())
571 1 6 if ($doit and $unless and &$unless())
574 1 5 if ($doit and $creates and -e $creates)
578 5 4 if ($doit) { }
580 0 5 if (ref $cmd->[0] eq 'ARRAY') { }
596 1 5 if (not defined $oldfile) { }
1 4 elsif (not defined $newfile) { }
2 2 elsif (-l $newfile) { }
1 1 elsif (-d $newfile) { }
601 0 2 unless my $points_to = readlink $newfile
603 1 1 if ($points_to eq $oldfile)
615 2 1 if ($doit) { }
619 0 2 if $? != 0
632 1 2 if (ref $directories[-1] eq "HASH")
634 2 1 if (@directories_to_create) { }
638 0 2 unless File::Path::make_path(@directories_to_create, $options)
652 18 2 if (not -d $directory) { }
654 2 16 if (defined $mode) { }
656 1 1 unless mkdir $directory, $mode
662 1 15 unless mkdir $directory
675 1 3 if (ref $directories[-1] eq "HASH")
677 3 1 if (@directories_to_remove) { }
681 0 3 unless File::Path::remove_tree(@directories_to_remove, $options)
697 1 12 unless rename $from, $to
706 3 14 if (@args and ref $args[0] eq "HASH")
708 1 16 if %options
709 1 15 if (@args != 2)
715 4 11 if (-d $to) { }
721 11 4 if (not -e $real_to or do { require File::Compare; File::Compare::compare($from, $real_to) != 0 }) { }
725 2 9 unless File::Copy::copy($from, $to)
729 7 4 if (not -e $real_to) { }
732 1 3 if ($quiet) { }
752 1 1 unless File::Copy::move($from, $to)
762 1 49 if ($? == -1) { }
8 41 elsif ($? & 127) { }
770 0 8 $? & 128 ? :
788 0 46 if %opts
792 22 24 if (defined $prefix_msg)
800 42 94 if ($flag) { }
828 8 3 if (@args and ref $args[0] eq "HASH")
831 6 5 unless defined $instr
832 0 11 if %options
836 1 2 $quiet || $info ? :
3 7 unless $? == 0
843 4 7 $info ? :
1 9 $quiet ? :
851 1 2 if (@args and ref $args[0] eq "HASH")
866 34 39 defined $instr ? :
867 34 38 if (defined $instr)
881 144 69 if ($buf eq '') { }
884 72 72 if $sel->count == 0
898 36 2 if (@args and ref $args[0] eq "HASH")
904 0 38 if %options
909 29 7 if ($errref)
913 2 34 if ($statusref) { }
916 4 30 if ($? != 0)
917 1 3 $quiet || $info ? :
926 4 34 $info ? :
23 14 $quiet ? :
934 1 2 if (@args and ref $args[0] eq "HASH")
943 0 143 unless open my $fh, "-|", @args
953 138 6 if (@args and ref $args[0] eq "HASH")
957 0 144 if %options
961 2 141 if ($statusref) { }
964 22 119 if ($? != 0)
965 20 2 $quiet || $info ? :
973 135 9 $info ? :
113 11 $quiet ? :
981 131 3 if (@args and ref $args[0] eq "HASH")
988 5 1 if (-d $directory) { }
990 1 4 unless rmdir $directory
1006 0 0 if (not $success)
1013 0 0 if (ref $arg eq 'ARRAY') { }
1028 2 1 if (not defined $ENV{$key} or $ENV{$key} ne $val) { }
1031 1 1 defined $ENV{$key} ? :
1043 1 1 if (-l $newfile) { }
1 0 elsif (not -e $newfile) { }
1044 0 1 unless my $points_to = readlink $newfile
1046 0 1 if ($points_to ne $oldfile)
1054 1 1 if ($doit) { }
1056 0 1 unless symlink $oldfile, $newfile
1068 46 92 if (@args and ref $args[0] eq "HASH")
1072 0 138 if %options
1078 17 120 if ($? != 0)
1090 2 136 $info ? :
2 136 $quiet ? :
1102 0 1 if (@args and ref $args[0] eq "HASH")
1111 28 1 if (not -e $file) { }
1113 0 28 unless open my $fh, ">>", $file
1118 0 1 unless utime time, time, $file
1132 16 2 unless (-e $file)
1134 0 16 unless open my $fh, ">>", $file
1139 15 1 if (@commands) { }
1152 25 3 if (-e $file or -l $file)
1156 18 2 if (@files_to_remove) { }
1158 0 18 unless unlink @files_to_remove
1169 1 1 if (defined $ENV{$key}) { }
1185 1 9 unless (defined $atime)
1188 1 9 unless (defined $mtime)
1195 10 4 if (@s) { }
1196 9 1 if ($s[8] != $atime or $s[9] != $mtime)
1204 9 1 if (@files_to_change) { }
1208 3 6 if ($changed_files != @files_to_change)
1209 1 2 if (@files_to_change == 1) { }
1 1 elsif ($changed_files == 0) { }
1229 2 14 if (@args != 1)
1238 12 20 if (@args and ref $args[0] eq "HASH")
1240 1 31 exists $options{'atomic'} ? :
1241 1 31 if %options
1242 1 30 if (@args != 2)
1249 13 17 if (not -e $filename) { }
12 5 elsif (-s $filename != length $content) { }
1255 0 5 unless open my $fh, "<", $filename
1260 1 4 if ($file_content ne $content)
1266 26 4 if ($doit) { }
1272 25 1 $atomic ? :
1273 1 25 unless open my $ofh, ">", $outfile
1275 13 12 if (-e $filename)
1280 0 25 unless close $ofh
1282 24 1 if ($atomic)
1283 0 24 unless rename $outfile, $filename
1290 4 22 $quiet >= 2 ? :
1291 5 17 if ($quiet) { }
1292 2 3 if ($need_diff) { }
1298 8 9 if ($need_diff) { }
1315 3 44 if (@args and ref $args[0] eq "HASH")
1318 0 47 if ($check and ref $check ne "CODE")
1319 1 46 if %options
1321 1 45 if (@args < 1)
1326 2 43 unless (-e $file)
1329 2 41 unless (-f $file)
1336 26 20 if ($_->{'add_if_missing'})
1339 10 16 if (defined $_->{'add_after'} or defined $_->{'add_after_first'} or defined $_->{'add_before'} or defined $_->{'add_before_last'}) { }
1350 0 10 if ($defines != 1)
1356 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'}) { }
1379 4 2 $reverse ? :
1380 4 2 $reverse ? :
1381 4 2 $reverse ? :
1382 11 2 $reverse ? :
1383 5 7 if ($arrayref->[$i] =~ /$add/)
1384 3 2 if ($do_after) { }
1393 1 5 if (not $found)
1406 29 17 if ($_->{'unless_match'}) { }
16 1 elsif ($_->{'match'}) { }
1407 26 3 if (ref $_->{'unless_match'} ne "Regexp")
1411 1 28 unless ($_->{'action'})
1414 1 27 if (ref $_->{'action'} ne "CODE")
1419 3 13 if (ref $_->{'match'} ne "Regexp")
1423 3 13 $_->{'action'} ? :
7 9 defined $_->{'replace'} ? :
5 11 defined $_->{'delete'} ? :
1424 1 15 if ($consequences != 1)
1427 3 12 if ($_->{'action'}) { }
7 5 elsif (defined $_->{'replace'}) { }
5 0 elsif (defined $_->{'delete'}) { }
1428 1 2 if (ref $_->{'action'} ne "CODE")
1448 0 36 unless File::Copy::copy($file, $tmpfile)
1453 0 36 unless tie my @lines, "Tie::File", $tmpfile
1460 0 44 if ($debug)
1461 18 26 if ($lines[$line_i] =~ /$match/)
1462 9 9 if (exists $match_action->{'replace'}) { }
6 3 elsif (exists $match_action->{'delete'}) { }
1464 9 0 if ($lines[$line_i] ne $replace)
1470 5 1 if ($match_action->{'delete'})
1488 8 62 if ($line =~ /$match/)
1501 25 10 if ($no_of_changes)
1504 2 22 if ($check)
1508 0 1 unless &$check($tmpfile)
1511 0 23 unless rename $tmpfile, $file
1521 25 10 if ($no_of_changes) { }
1532 8 28 if (ref $file2)
1538 0 36 if (eval { do { require IPC::Run; 1 } }) { }
1539 0 0 defined $stdin ? :
1541 0 36 if ($^O eq 'MSWin32') { }
1543 0 0 if ($file2 eq "-")
1556 0 36 if ($@)
1557 0 0 !$diff_error_shown++ ? :
1581 43 0 if (@commands)
1589 389 215 if (exists $command->{'msg'})
1592 570 34 if (exists $command->{'code'})
1594 458 70 if (exists $command->{'rv'}) { }
1607 17 4 if (exists $command->{'msg'})
1610 20 1 if (exists $command->{'code'})
1611 17 3 if (exists $command->{'rv'}) { }
1627 0 41 if %options
1646 22 610 if ($self->{'dryrun'}) { }
1659 3 11 if ($component_or_module =~ /::/) { }
1666 2 4 if $_->{'module'} eq $module
1669 1 11 unless (eval " require $module; 1 ")
1672 0 11 unless my $o = $module->new
1689 0 11 if ($o->can("add_components"))
1720 2 4 if ($context eq 'a') { }
1725 2 4 if ($@) { }
1735 6 0 unless $sub =~ /::/
1742 2 0 unless $sub =~ /::/
1781 0 14 if (not defined $ret) { }
0 14 elsif (not $ret) { }
1787 0 14 unless read $fh, $buf, $length
1802 0 0 unless defined $pid
1803 0 0 if (eval { do { require POSIX; defined &POSIX::WNOHANG } }) { }
1804 0 0 if ($self->{'debug'})
1814 0 0 if (time - $start_time >= 2)
1820 0 0 if (not $got_pid)
1824 0 0 if (not $done_POSIX_warning++)
1840 0 0 if %opts
1844 0 0 if $ret
1846 0 0 if ($fast_tries and eval { do { require Time::HiRes; 1 } }) { }
1851 0 0 $try <= $fast_tries && defined &Time::HiRes::sleep ? :
1852 0 0 if $retry_msg_code
1870 0 1 if %options
1884 2 5 wantarray ? :
1887 2 5 if (defined $rettype and $rettype eq 'e') { }
5 0 elsif (defined $rettype and $rettype eq 'r') { }
1890 2 3 if ($context eq 'a') { }
1896 0 0 defined $self->{'label'} ? :
0 0 defined $rettype ? :
1910 0 0 if %options
1929 0 0 if ($self->{'debug'}) { }
1939 0 0 if (not $self->{'excl'} and -e $sockpath)
1943 0 0 unless my $sock = "IO::Socket::UNIX"->new("Type", SOCK_STREAM(), "Local", $sockpath, "Listen", 1)
1953 0 0 if $ready[0] != $sock
1960 0 0 if (not defined $context) { }
0 0 elsif ($data[0] =~ /^exit$/) { }
1986 0 1 if %options
1988 0 1 unless $infh
1989 0 1 unless $outfh
2003 0 7 if (not defined $context) { }
1 6 elsif ($data[0] =~ /^exit$/) { }
2009 0 6 unless open my $oldout, ">&STDOUT"
2013 0 6 unless open STDOUT, ">", "/dev/stderr"
2016 0 6 unless open STDOUT, ">&", $oldout
2038 0 0 if $^O eq "linux"
2053 0 0 unless (defined $realscript)
2054 0 0 if ($realscript ne '-e') { }
2074 0 0 unless delete $opts{'sudo_opts'}
2077 0 0 unless delete $opts{'components'}
2079 0 0 if %opts
2103 0 0 if ($? != 0)
2114 0 0 $class->_can_LANS ? :
2117 0 0 $debug ? :
0 0 $LANS_PREFIX ? :
0 0 $dry_run ? :
2128 0 0 if (not defined $worker_pid) { }
0 0 elsif ($worker_pid == 0) { }
2131 0 0 if $debug
2141 0 0 if $debug
2165 0 0 unless delete $opts{'components'}
2173 0 0 unless defined $dest_os
2175 0 0 unless $put_to_remote =~ /^(rsync_put|scp_put)$/
2179 0 0 if (defined $umask and not $umask =~ /^\d+$/)
2183 0 0 if %opts
2186 0 0 $forward_agent ? :
0 0 $tty ? :
2190 0 0 $forward_agent ? :
0 0 $master_opts ? :
2196 0 0 if (UNIVERSAL::isa($ssh_or_host, 'Net::OpenSSH')) { }
2202 0 0 if $ssh->error
2207 0 0 if (($bootstrap || '') eq "perl")
2214 0 0 if ($dest_os eq 'MSWin32') { }
2219 0 0 if ($debug)
2224 0 0 if ($FindBin::RealScript ne "-e")
2231 0 0 $dest_os ne 'MSWin32' ? :
2245 0 0 unless ($seen_dir{$target_dir})
2247 0 0 if ($dest_os eq 'MSWin32') { }
2263 0 0 $dest_os eq 'MSWin32' ? :
2270 0 0 if (defined $as)
2271 0 0 if ($as eq 'root') { }
2279 0 0 if ($dest_os eq 'MSWin32') { }
2280 0 0 $debug ? :
0 0 $dry_run ? :
2294 0 0 defined $umask ? :
0 0 $debug ? :
0 0 $dry_run ? :
2308 0 0 if $debug
2313 0 0 if ($dest_os eq 'MSWin32') { }
2328 0 0 if $debug
2341 0 0 if ($self->{'ssh'})
2342 0 0 if $self->{'ssh'}->can("disconnect")
2345 0 0 if ($self->{'rpc'})
2358 0 0 unless defined $peer
2360 0 0 if %options
2370 0 0 if ($debug) { }
2389 0 0 if $sock
2399 0 0 unless ($sock)
2408 0 0 unless read $infh, $length_buf, 4
2414 0 0 if $got == $length
2415 0 0 if $got > $length
2428 0 0 if eof $infh