Branch Coverage

blib/lib/Doit.pm
Criterion Covered Total %
branch 477 778 61.3


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 13 7 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 20 if ($^O eq 'MSWin32') { }
257 0 20 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 146 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 14 132 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 34 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 94 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
844 4 7 $info ? :
1 9 $quiet ? :
852 1 2 if (@args and ref $args[0] eq "HASH")
867 34 39 defined $instr ? :
868 34 38 if (defined $instr)
882 144 69 if ($buf eq '') { }
885 72 72 if $sel->count == 0
899 36 2 if (@args and ref $args[0] eq "HASH")
905 0 38 if %options
910 29 7 if ($errref)
914 2 34 if ($statusref) { }
917 4 30 if ($? != 0)
918 1 3 $quiet || $info ? :
927 4 34 $info ? :
23 14 $quiet ? :
935 1 2 if (@args and ref $args[0] eq "HASH")
944 0 143 unless open my $fh, "-|", @args
954 138 6 if (@args and ref $args[0] eq "HASH")
958 0 144 if %options
962 2 141 if ($statusref) { }
965 22 119 if ($? != 0)
966 20 2 $quiet || $info ? :
974 135 9 $info ? :
113 11 $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 46 92 if (@args and ref $args[0] eq "HASH")
1073 0 138 if %options
1079 17 120 if ($? != 0)
1091 2 136 $info ? :
2 136 $quiet ? :
1103 0 1 if (@args and ref $args[0] eq "HASH")
1112 28 1 if (not -e $file) { }
1114 0 28 unless open my $fh, ">>", $file
1119 0 1 unless utime time, time, $file
1133 16 2 unless (-e $file)
1135 0 16 unless open my $fh, ">>", $file
1140 15 1 if (@commands) { }
1153 25 3 if (-e $file or -l $file)
1157 18 2 if (@files_to_remove) { }
1159 0 18 unless unlink @files_to_remove
1170 1 1 if (defined $ENV{$key}) { }
1186 1 9 unless (defined $atime)
1189 1 9 unless (defined $mtime)
1196 10 4 if (@s) { }
1197 9 1 if ($s[8] != $atime or $s[9] != $mtime)
1205 9 1 if (@files_to_change) { }
1209 3 6 if ($changed_files != @files_to_change)
1210 1 2 if (@files_to_change == 1) { }
1 1 elsif ($changed_files == 0) { }
1230 2 13 if (@args != 1)
1239 12 20 if (@args and ref $args[0] eq "HASH")
1241 1 31 exists $options{'atomic'} ? :
1242 1 31 if %options
1243 1 30 if (@args != 2)
1250 13 17 if (not -e $filename) { }
12 5 elsif (-s $filename != length $content) { }
1256 0 5 unless open my $fh, "<", $filename
1261 1 4 if ($file_content ne $content)
1267 26 4 if ($doit) { }
1273 25 1 $atomic ? :
1274 1 25 unless open my $ofh, ">", $outfile
1276 13 12 if (-e $filename)
1281 0 25 unless close $ofh
1283 24 1 if ($atomic)
1284 0 24 unless rename $outfile, $filename
1291 4 22 $quiet >= 2 ? :
1292 5 17 if ($quiet) { }
1293 2 3 if ($need_diff) { }
1299 8 9 if ($need_diff) { }
1316 3 44 if (@args and ref $args[0] eq "HASH")
1319 0 47 if ($check and ref $check ne "CODE")
1320 1 46 if %options
1322 1 45 if (@args < 1)
1327 2 43 unless (-e $file)
1330 2 41 unless (-f $file)
1337 26 20 if ($_->{'add_if_missing'})
1340 10 16 if (defined $_->{'add_after'} or defined $_->{'add_after_first'} or defined $_->{'add_before'} or defined $_->{'add_before_last'}) { }
1351 0 10 if ($defines != 1)
1357 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'}) { }
1380 4 2 $reverse ? :
1381 4 2 $reverse ? :
1382 4 2 $reverse ? :
1383 11 2 $reverse ? :
1384 5 7 if ($arrayref->[$i] =~ /$add/)
1385 3 2 if ($do_after) { }
1394 1 5 if (not $found)
1407 29 17 if ($_->{'unless_match'}) { }
16 1 elsif ($_->{'match'}) { }
1408 26 3 if (ref $_->{'unless_match'} ne "Regexp")
1412 1 28 unless ($_->{'action'})
1415 1 27 if (ref $_->{'action'} ne "CODE")
1420 3 13 if (ref $_->{'match'} ne "Regexp")
1424 3 13 $_->{'action'} ? :
7 9 defined $_->{'replace'} ? :
5 11 defined $_->{'delete'} ? :
1425 1 15 if ($consequences != 1)
1428 3 12 if ($_->{'action'}) { }
7 5 elsif (defined $_->{'replace'}) { }
5 0 elsif (defined $_->{'delete'}) { }
1429 1 2 if (ref $_->{'action'} ne "CODE")
1449 0 36 unless File::Copy::copy($file, $tmpfile)
1454 0 36 unless tie my @lines, "Tie::File", $tmpfile
1461 0 44 if ($debug)
1462 18 26 if ($lines[$line_i] =~ /$match/)
1463 9 9 if (exists $match_action->{'replace'}) { }
6 3 elsif (exists $match_action->{'delete'}) { }
1465 9 0 if ($lines[$line_i] ne $replace)
1471 5 1 if ($match_action->{'delete'})
1489 8 62 if ($line =~ /$match/)
1502 25 10 if ($no_of_changes)
1505 2 22 if ($check)
1509 0 1 unless &$check($tmpfile)
1512 0 23 unless rename $tmpfile, $file
1522 25 10 if ($no_of_changes) { }
1533 8 28 if (ref $file2)
1538 7 29 unless (@diff_cmd)
1540 0 7 if ($^O eq "MSWin32")
1544 7 0 if (Doit::Util::is_in_path($diff_candidate->[0]))
1549 0 0 !$diff_error_shown++ ? :
0 7 unless @diff_cmd
1554 0 36 if ($^O eq "MSWin32" and $diff_cmd[0] eq "fc")
1556 0 0 if ($file2 eq "-")
1562 0 36 if (not $cannot_use_dash and eval { do { require IPC::Run; 1 } }) { }
1563 0 0 unless (eval { do { IPC::Run::run([@diff_cmd, $file1, $file2], defined $stdin ? ("<", \$stdin) : (), ">", \$diff, "2>", \$diff_stderr); 1 } })
1564 0 0 defined $stdin ? :
1566 0 0 !$diff_error_shown++ ? :
1570 0 36 if ($^O eq 'MSWin32' or $cannot_use_dash) { }
1572 0 0 if ($file2 eq "-")
1585 0 36 if ($@)
1586 0 0 !$diff_error_shown++ ? :
1610 43 0 if (@commands)
1618 389 214 if (exists $command->{'msg'})
1621 569 34 if (exists $command->{'code'})
1623 457 70 if (exists $command->{'rv'}) { }
1636 17 4 if (exists $command->{'msg'})
1639 20 1 if (exists $command->{'code'})
1640 17 3 if (exists $command->{'rv'}) { }
1656 0 41 if %options
1675 22 609 if ($self->{'dryrun'}) { }
1688 3 11 if ($component_or_module =~ /::/) { }
1695 2 4 if $_->{'module'} eq $module
1698 1 11 unless (eval " require $module; 1 ")
1701 0 11 unless my $o = $module->new
1718 0 11 if ($o->can("add_components"))
1749 2 4 if ($context eq 'a') { }
1754 2 4 if ($@) { }
1764 6 0 unless $sub =~ /::/
1771 2 0 unless $sub =~ /::/
1810 0 14 if (not defined $ret) { }
0 14 elsif (not $ret) { }
1816 0 14 unless read $fh, $buf, $length
1831 0 0 unless defined $pid
1832 0 0 if (eval { do { require POSIX; defined &POSIX::WNOHANG } }) { }
1833 0 0 if ($self->{'debug'})
1843 0 0 if (time - $start_time >= 2)
1849 0 0 if (not $got_pid)
1853 0 0 if (not $done_POSIX_warning++)
1869 0 0 if %opts
1873 0 0 if $ret
1875 0 0 if ($fast_tries and eval { do { require Time::HiRes; 1 } }) { }
1880 0 0 $try <= $fast_tries && defined &Time::HiRes::sleep ? :
1881 0 0 if $retry_msg_code
1899 0 1 if %options
1913 2 5 wantarray ? :
1916 2 5 if (defined $rettype and $rettype eq 'e') { }
5 0 elsif (defined $rettype and $rettype eq 'r') { }
1919 2 3 if ($context eq 'a') { }
1925 0 0 defined $self->{'label'} ? :
0 0 defined $rettype ? :
1939 0 0 if %options
1958 0 0 if ($self->{'debug'}) { }
1968 0 0 if (not $self->{'excl'} and -e $sockpath)
1972 0 0 unless my $sock = "IO::Socket::UNIX"->new("Type", SOCK_STREAM(), "Local", $sockpath, "Listen", 1)
1982 0 0 if $ready[0] != $sock
1989 0 0 if (not defined $context) { }
0 0 elsif ($data[0] =~ /^exit$/) { }
2015 0 1 if %options
2017 0 1 unless $infh
2018 0 1 unless $outfh
2032 0 7 if (not defined $context) { }
1 6 elsif ($data[0] =~ /^exit$/) { }
2038 0 6 unless open my $oldout, ">&STDOUT"
2042 0 6 unless open STDOUT, ">", "/dev/stderr"
2045 0 6 unless open STDOUT, ">&", $oldout
2067 0 0 if $^O eq "linux"
2082 0 0 unless (defined $realscript)
2083 0 0 if ($realscript ne '-e') { }
2103 0 0 unless delete $opts{'sudo_opts'}
2106 0 0 unless delete $opts{'components'}
2108 0 0 if %opts
2132 0 0 if ($? != 0)
2143 0 0 $class->_can_LANS ? :
2146 0 0 $debug ? :
0 0 $LANS_PREFIX ? :
0 0 $dry_run ? :
2157 0 0 if (not defined $worker_pid) { }
0 0 elsif ($worker_pid == 0) { }
2160 0 0 if $debug
2170 0 0 if $debug
2194 0 0 unless delete $opts{'components'}
2202 0 0 unless defined $dest_os
2204 0 0 unless $put_to_remote =~ /^(rsync_put|scp_put)$/
2208 0 0 if (defined $umask and not $umask =~ /^\d+$/)
2212 0 0 if %opts
2215 0 0 $forward_agent ? :
0 0 $tty ? :
2219 0 0 $forward_agent ? :
0 0 $master_opts ? :
2225 0 0 if (UNIVERSAL::isa($ssh_or_host, 'Net::OpenSSH')) { }
2231 0 0 if $ssh->error
2236 0 0 if (($bootstrap || '') eq "perl")
2243 0 0 if ($dest_os eq 'MSWin32') { }
2248 0 0 if ($debug)
2253 0 0 if ($FindBin::RealScript ne "-e")
2260 0 0 $dest_os ne 'MSWin32' ? :
2274 0 0 unless ($seen_dir{$target_dir})
2276 0 0 if ($dest_os eq 'MSWin32') { }
2292 0 0 $dest_os eq 'MSWin32' ? :
2299 0 0 if (defined $as)
2300 0 0 if ($as eq 'root') { }
2308 0 0 if ($dest_os eq 'MSWin32') { }
2309 0 0 $debug ? :
0 0 $dry_run ? :
2323 0 0 defined $umask ? :
0 0 $debug ? :
0 0 $dry_run ? :
2337 0 0 if $debug
2342 0 0 if ($dest_os eq 'MSWin32') { }
2357 0 0 if $debug
2370 0 0 if ($self->{'ssh'})
2371 0 0 if $self->{'ssh'}->can("disconnect")
2374 0 0 if ($self->{'rpc'})
2387 0 0 unless defined $peer
2389 0 0 if %options
2399 0 0 if ($debug) { }
2418 0 0 if $sock
2428 0 0 unless ($sock)
2437 0 0 unless read $infh, $length_buf, 4
2443 0 0 if $got == $length
2444 0 0 if $got > $length
2457 0 0 if eof $infh