Branch Coverage

blib/lib/Doit.pm
Criterion Covered Total %
branch 482 782 61.6


line true false branch
41 2 46 if defined $can_coloring
46 46 0 !(($ENV{'TERM'} || '') =~ /^(|dumb)$/) && eval { do { require Term::ANSIColor; 1 } } ? :
51 46 0 if (_can_coloring()) { }
71 1 1 if (defined $label) { }
89 54 0 if ($level eq "auto")
93 0 288 unless (@stackinfo)
97 54 234 unless ($stackinfo[1] =~ m(([/\\]|^)Doit\.pm$))
113 2 29 unless defined $msg
114 29 2 unless ($msg =~ /\n\z/)
142 130 0 if ($] >= 5.014) { }
146 4 126 if ($@)
180 103 200 if (defined $dir)
183 2 101 if (not defined $pwd or $pwd eq '') { }
188 2 99 unless chdir $pwd
191 3 100 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 13 5 unless (defined &Doit::Util::_file_name_is_absolute)
241 0 13 if (eval { do { require File::Spec; defined &File::Spec::file_name_is_absolute } }) { }
247 0 18 if ($^O eq 'MSWin32') { }
257 0 18 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 134 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 12 122 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)
414 7 37 if ($dry_run) { }
423 2 0 unless ($msg)
424 2 0 $args ? :
430 2 1 if (&$check($self, \@args, $addinfo))
444 17 17 if (@args and ref $args[0] eq "HASH")
446 0 34 if %options
451 33 4 if (@s) { }
452 30 3 if (($s[2] & 4095) != $mode)
459 31 3 if (@files_to_change) { }
463 3 25 if ($changed_files != @files_to_change)
464 1 2 if (@files_to_change == 1) { }
1 1 elsif ($changed_files == 0) { }
473 16 15 $quiet ? :
484 2 10 if (@args and ref $args[0] eq "HASH")
486 0 12 if %options
489 3 9 if (not defined $uid) { }
2 7 elsif (not $uid =~ /^-?\d+$/) { }
493 1 1 unless (defined $_uid)
504 6 5 if (not defined $gid) { }
1 4 elsif (not $gid =~ /^-?\d+$/) { }
508 1 0 unless (defined $_gid)
515 9 1 if ($uid != -1 or $gid != -1)
518 7 3 if (@s) { }
519 0 7 if ($uid != -1 and $s[4] != $uid) { }
0 12 elsif ($gid != -1 and $s[5] != $gid) { }
530 2 8 if (@files_to_change) { }
534 2 0 if ($changed_files != @files_to_change)
535 1 1 if (@files_to_change == 1) { }
1 0 elsif ($changed_files == 0) { }
544 0 2 $quiet ? :
559 1 11 if %opts
561 1 10 unless ($cmd)
564 1 9 if (ref $cmd ne "ARRAY")
569 2 7 if ($if and not &$if())
572 1 6 if ($doit and $unless and &$unless())
575 1 5 if ($doit and $creates and -e $creates)
579 5 4 if ($doit) { }
581 0 5 if (ref $cmd->[0] eq 'ARRAY') { }
597 1 5 if (not defined $oldfile) { }
1 4 elsif (not defined $newfile) { }
2 2 elsif (-l $newfile) { }
1 1 elsif (-d $newfile) { }
602 0 2 unless my $points_to = readlink $newfile
604 1 1 if ($points_to eq $oldfile)
616 2 1 if ($doit) { }
620 0 2 if $? != 0
633 1 2 if (ref $directories[-1] eq "HASH")
635 2 1 if (@directories_to_create) { }
639 0 2 unless File::Path::make_path(@directories_to_create, $options)
653 18 2 if (not -d $directory) { }
655 2 16 if (defined $mode) { }
657 1 1 unless mkdir $directory, $mode
663 1 15 unless mkdir $directory
676 1 3 if (ref $directories[-1] eq "HASH")
678 3 1 if (@directories_to_remove) { }
682 0 3 unless File::Path::remove_tree(@directories_to_remove, $options)
698 1 12 unless rename $from, $to
707 3 14 if (@args and ref $args[0] eq "HASH")
709 1 16 if %options
710 1 15 if (@args != 2)
716 4 11 if (-d $to) { }
722 11 4 if (not -e $real_to or do { require File::Compare; File::Compare::compare($from, $real_to) != 0 }) { }
726 2 9 unless File::Copy::copy($from, $to)
730 7 4 if (not -e $real_to) { }
733 1 3 if ($quiet) { }
753 1 1 unless File::Copy::move($from, $to)
763 1 49 if ($? == -1) { }
8 41 elsif ($? & 127) { }
771 0 8 $? & 128 ? :
789 0 46 if %opts
793 22 24 if (defined $prefix_msg)
801 42 95 if ($flag) { }
829 8 3 if (@args and ref $args[0] eq "HASH")
832 6 5 unless defined $instr
833 0 11 if %options
837 1 2 $quiet || $info ? :
3 7 unless $? == 0
843 4 7 $info ? :
1 10 $quiet ? :
852 1 2 if (@args and ref $args[0] eq "HASH")
867 35 39 defined $instr ? :
868 35 38 if (defined $instr)
882 146 70 if ($buf eq '') { }
885 73 73 if $sel->count == 0
899 37 2 if (@args and ref $args[0] eq "HASH")
905 0 39 if %options
910 30 7 if ($errref)
914 2 35 if ($statusref) { }
917 4 31 if ($? != 0)
918 1 3 $quiet || $info ? :
926 4 35 $info ? :
24 15 $quiet ? :
935 1 2 if (@args and ref $args[0] eq "HASH")
944 0 144 unless open my $fh, "-|", @args
954 138 7 if (@args and ref $args[0] eq "HASH")
958 0 145 if %options
962 2 142 if ($statusref) { }
965 22 120 if ($? != 0)
966 20 2 $quiet || $info ? :
973 135 10 $info ? :
132 13 $quiet ? :
982 131 3 if (@args and ref $args[0] eq "HASH")
989 5 1 if (-d $directory) { }
991 1 4 unless rmdir $directory
1007 0 0 if (not $success)
1014 0 0 if (ref $arg eq 'ARRAY') { }
1029 2 1 if (not defined $ENV{$key} or $ENV{$key} ne $val) { }
1032 1 1 defined $ENV{$key} ? :
1044 1 1 if (-l $newfile) { }
1 0 elsif (not -e $newfile) { }
1045 0 1 unless my $points_to = readlink $newfile
1047 0 1 if ($points_to ne $oldfile)
1055 1 1 if ($doit) { }
1057 0 1 unless symlink $oldfile, $newfile
1069 47 92 if (@args and ref $args[0] eq "HASH")
1073 0 139 if %options
1079 17 121 if ($? != 0)
1085 3 136 $info ? :
2 137 $quiet ? :
1096 0 2 if (@args and ref $args[0] eq "HASH")
1105 28 1 if (not -e $file) { }
1107 0 28 unless open my $fh, ">>", $file
1112 0 1 unless utime time, time, $file
1126 16 2 unless (-e $file)
1128 0 16 unless open my $fh, ">>", $file
1133 15 1 if (@commands) { }
1146 25 3 if (-e $file or -l $file)
1150 18 2 if (@files_to_remove) { }
1152 0 18 unless unlink @files_to_remove
1163 1 1 if (defined $ENV{$key}) { }
1179 1 9 unless (defined $atime)
1182 1 9 unless (defined $mtime)
1189 10 4 if (@s) { }
1190 9 1 if ($s[8] != $atime or $s[9] != $mtime)
1198 9 1 if (@files_to_change) { }
1202 3 6 if ($changed_files != @files_to_change)
1203 1 2 if (@files_to_change == 1) { }
1 1 elsif ($changed_files == 0) { }
1223 2 11 if (@args != 1)
1232 12 20 if (@args and ref $args[0] eq "HASH")
1234 1 31 exists $options{'atomic'} ? :
1235 1 31 if %options
1236 1 30 if (@args != 2)
1243 13 17 if (not -e $filename) { }
12 5 elsif (-s $filename != length $content) { }
1249 0 5 unless open my $fh, "<", $filename
1254 1 4 if ($file_content ne $content)
1260 26 4 if ($doit) { }
1266 25 1 $atomic ? :
1267 1 25 unless open my $ofh, ">", $outfile
1269 13 12 if (-e $filename)
1274 0 25 unless close $ofh
1276 24 1 if ($atomic)
1277 0 24 unless rename $outfile, $filename
1284 4 22 $quiet >= 2 ? :
1285 5 17 if ($quiet) { }
1286 2 3 if ($need_diff) { }
1292 8 9 if ($need_diff) { }
1309 3 44 if (@args and ref $args[0] eq "HASH")
1312 0 47 if ($check and ref $check ne "CODE")
1313 1 46 if %options
1315 1 45 if (@args < 1)
1320 2 43 unless (-e $file)
1323 2 41 unless (-f $file)
1330 26 20 if ($_->{'add_if_missing'})
1333 10 16 if (defined $_->{'add_after'} or defined $_->{'add_after_first'} or defined $_->{'add_before'} or defined $_->{'add_before_last'}) { }
1344 0 10 if ($defines != 1)
1350 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'}) { }
1373 4 2 $reverse ? :
1374 4 2 $reverse ? :
1375 4 2 $reverse ? :
1376 11 2 $reverse ? :
1377 5 7 if ($arrayref->[$i] =~ /$add/)
1378 3 2 if ($do_after) { }
1387 1 5 if (not $found)
1400 29 17 if ($_->{'unless_match'}) { }
16 1 elsif ($_->{'match'}) { }
1401 26 3 if (ref $_->{'unless_match'} ne "Regexp")
1405 1 28 unless ($_->{'action'})
1408 1 27 if (ref $_->{'action'} ne "CODE")
1413 3 13 if (ref $_->{'match'} ne "Regexp")
1417 3 13 $_->{'action'} ? :
7 9 defined $_->{'replace'} ? :
5 11 defined $_->{'delete'} ? :
1418 1 15 if ($consequences != 1)
1421 3 12 if ($_->{'action'}) { }
7 5 elsif (defined $_->{'replace'}) { }
5 0 elsif (defined $_->{'delete'}) { }
1422 1 2 if (ref $_->{'action'} ne "CODE")
1442 0 36 unless File::Copy::copy($file, $tmpfile)
1447 0 36 unless tie my @lines, "Tie::File", $tmpfile
1454 0 44 if ($debug)
1455 18 26 if ($lines[$line_i] =~ /$match/)
1456 9 9 if (exists $match_action->{'replace'}) { }
6 3 elsif (exists $match_action->{'delete'}) { }
1458 9 0 if ($lines[$line_i] ne $replace)
1464 5 1 if ($match_action->{'delete'})
1482 8 62 if ($line =~ /$match/)
1495 25 10 if ($no_of_changes)
1498 2 22 if ($check)
1502 0 1 unless &$check($tmpfile)
1505 0 23 unless rename $tmpfile, $file
1515 25 10 if ($no_of_changes) { }
1526 8 28 if (ref $file2)
1531 7 29 unless (@diff_cmd)
1533 0 7 if ($^O eq "MSWin32")
1537 7 0 if (Doit::Util::is_in_path($diff_candidate->[0]))
1542 0 0 !$diff_error_shown++ ? :
0 7 unless @diff_cmd
1547 0 36 if ($^O eq "MSWin32" and $diff_cmd[0] eq "fc")
1549 0 0 if ($file2 eq "-")
1555 0 36 if (not $cannot_use_dash and eval { do { require IPC::Run; 1 } }) { }
1556 0 0 unless (eval { do { IPC::Run::run([@diff_cmd, $file1, $file2], defined $stdin ? ("<", \$stdin) : (), ">", \$diff, "2>", \$diff_stderr); 1 } })
1557 0 0 defined $stdin ? :
1559 0 0 !$diff_error_shown++ ? :
1563 0 36 if ($^O eq 'MSWin32' or $cannot_use_dash) { }
1565 0 0 if ($file2 eq "-")
1578 0 36 if ($@)
1579 0 0 !$diff_error_shown++ ? :
1603 43 0 if (@commands)
1611 393 232 if (exists $command->{'msg'})
1614 591 34 if (exists $command->{'code'})
1616 340 187 if (exists $command->{'rv'}) { }
1629 18 4 if (exists $command->{'msg'})
1630 9 9 $command->{'run_always'} ? :
1632 21 1 if (exists $command->{'code'})
1634 9 12 if ($command->{'run_always'})
1637 12 9 if (exists $command->{'rv'}) { }
1653 0 44 if %options
1672 23 609 if ($self->{'dryrun'}) { }
1685 3 13 if ($component_or_module =~ /::/) { }
1692 2 4 if $_->{'module'} eq $module
1695 1 13 unless (eval " require $module; 1 ")
1698 0 13 unless my $o = $module->new
1715 0 13 if ($o->can("add_components"))
1746 2 8 if ($context eq 'a') { }
1751 2 8 if ($@) { }
1761 6 0 unless $sub =~ /::/
1768 5 0 unless $sub =~ /::/
1815 0 23 if (not defined $ret) { }
1 22 elsif (not $ret) { }
1821 0 22 unless read $fh, $buf, $length
1836 0 0 unless defined $pid
1837 0 0 if (eval { do { require POSIX; defined &POSIX::WNOHANG } }) { }
1838 0 0 if ($self->{'debug'})
1848 0 0 if (time - $start_time >= 2)
1854 0 0 if (not $got_pid)
1858 0 0 if (not $done_POSIX_warning++)
1874 0 0 if %opts
1878 0 0 if $ret
1880 0 0 if ($fast_tries and eval { do { require Time::HiRes; 1 } }) { }
1885 0 0 $try <= $fast_tries && defined &Time::HiRes::sleep ? :
1886 0 0 if $retry_msg_code
1904 0 2 if %options
1918 2 9 wantarray ? :
1921 2 9 if (defined $rettype and $rettype eq 'e') { }
9 0 elsif (defined $rettype and $rettype eq 'r') { }
1924 2 7 if ($context eq 'a') { }
1930 0 0 defined $self->{'label'} ? :
0 0 defined $rettype ? :
1944 0 0 if %options
1963 0 0 if ($self->{'debug'}) { }
1973 0 0 if (not $self->{'excl'} and -e $sockpath)
1977 0 0 unless my $sock = "IO::Socket::UNIX"->new("Type", SOCK_STREAM(), "Local", $sockpath, "Listen", 1)
1987 0 0 if $ready[0] != $sock
1994 0 0 if (not defined $context) { }
0 0 elsif ($data[0] =~ /^exit$/) { }
2020 0 1 if %options
2022 0 1 unless $infh
2023 0 1 unless $outfh
2037 0 7 if (not defined $context) { }
1 6 elsif ($data[0] =~ /^exit$/) { }
2043 0 6 unless open my $oldout, ">&STDOUT"
2047 0 6 unless open STDOUT, ">", "/dev/stderr"
2050 0 6 unless open STDOUT, ">&", $oldout
2072 0 0 if $^O eq "linux"
2087 0 0 unless (defined $realscript)
2088 0 0 if ($realscript ne '-e') { }
2108 0 0 unless delete $opts{'sudo_opts'}
2111 0 0 unless delete $opts{'components'}
2113 0 0 if %opts
2137 0 0 if ($? != 0)
2148 0 0 $class->_can_LANS ? :
2151 0 0 $debug ? :
0 0 $LANS_PREFIX ? :
0 0 $dry_run ? :
2162 0 0 if (not defined $worker_pid) { }
0 0 elsif ($worker_pid == 0) { }
2165 0 0 if $debug
2175 0 0 if $debug
2199 0 0 unless delete $opts{'components'}
2207 0 0 unless defined $dest_os
2209 0 0 unless $put_to_remote =~ /^(rsync_put|scp_put)$/
2213 0 0 if (defined $umask and not $umask =~ /^\d+$/)
2217 0 0 if %opts
2220 0 0 $forward_agent ? :
0 0 $tty ? :
2224 0 0 $forward_agent ? :
0 0 $master_opts ? :
2230 0 0 if (UNIVERSAL::isa($ssh_or_host, 'Net::OpenSSH')) { }
2236 0 0 if $ssh->error
2241 0 0 if (($bootstrap || '') eq "perl")
2248 0 0 if ($dest_os eq 'MSWin32') { }
2253 0 0 if ($debug)
2258 0 0 if ($FindBin::RealScript ne "-e")
2265 0 0 $dest_os ne 'MSWin32' ? :
2279 0 0 unless ($seen_dir{$target_dir})
2281 0 0 if ($dest_os eq 'MSWin32') { }
2297 0 0 $dest_os eq 'MSWin32' ? :
2304 0 0 if (defined $as)
2305 0 0 if ($as eq 'root') { }
2313 0 0 if ($dest_os eq 'MSWin32') { }
2314 0 0 $debug ? :
0 0 $dry_run ? :
2328 0 0 defined $umask ? :
0 0 $debug ? :
0 0 $dry_run ? :
2342 0 0 if $debug
2347 0 0 if ($dest_os eq 'MSWin32') { }
2362 0 0 if $debug
2375 0 0 if ($self->{'ssh'})
2376 0 0 if $self->{'ssh'}->can("disconnect")
2379 0 0 if ($self->{'rpc'})
2392 0 0 unless defined $peer
2394 0 0 if %options
2404 0 0 if ($debug) { }
2423 0 0 if $sock
2433 0 0 unless ($sock)
2442 0 0 unless read $infh, $length_buf, 4
2448 0 0 if $got == $length
2449 0 0 if $got > $length
2462 0 0 if eof $infh