Branch Coverage

blib/lib/Doit.pm
Criterion Covered Total %
branch 509 790 64.4


line true false branch
41 2 51 if defined $can_coloring
46 51 0 !(($ENV{'TERM'} || '') =~ /^(|dumb)$/) && eval { do { require Term::ANSIColor; 1 } } ? :
51 51 0 if (_can_coloring()) { }
71 1 1 if (defined $label) { }
89 58 0 if ($level eq "auto")
93 0 312 unless (@stackinfo)
97 58 254 unless ($stackinfo[1] =~ m(([/\\]|^)Doit\.pm$))
113 2 33 unless defined $msg
114 33 2 unless ($msg =~ /\n\z/)
142 131 0 if ($] >= 5.014) { }
146 4 127 if ($@)
180 104 206 if (defined $dir)
183 2 102 if (not defined $pwd or $pwd eq '') { }
188 2 100 unless chdir $pwd
191 3 101 unless chdir $dir
200 6 60 ref $src eq 'ARRAY' ? :
201 0 66 unless @stat
204 23 43 exists $preserve{'ownership'} ? :
205 24 42 exists $preserve{'mode'} ? :
206 1 65 exists $preserve{'time'} ? :
208 0 66 if %preserve
210 63 3 if ($preserve_mode)
211 0 63 unless chmod $stat[2], $dest
214 63 3 if ($preserve_ownership)
216 0 63 unless (chown $stat[4], $stat[5], $dest)
223 41 25 if ($preserve_time)
224 0 41 unless utime $stat[8], $stat[9], $dest
233 0 0 if $> == 0
240 15 6 unless (defined &Doit::Util::_file_name_is_absolute)
241 0 15 if (eval { do { require File::Spec; defined &File::Spec::file_name_is_absolute } }) { }
247 0 21 if ($^O eq 'MSWin32') { }
257 0 21 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 165 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 15 150 if -x "$_/$prog" and not -d "$_/$prog"
292 1 9 if %opts
293 7 2 if ($refresh or not $cached_os_release_per_file{$file})
294 6 1 if (open my $fh, "<", $file)
297 74 2 if (my($k, $v) = $_ =~ /^(.*?)="?(.*?)"?$/)
318 0 0 if (_has_shell_metachars($args))
335 0 0 if ($text ne '' and not $text =~ /[ \t\n\x0a\x0b\x0c\x0d\x85"]/) { }
346 0 0 if ($i > $#text) { }
0 0 elsif ($text[$i] eq '"') { }
370 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 '|') { }
373 0 0 if ($inquote) { }
374 0 0 if ($char eq $quote)
383 0 0 unless ($inquote)
436 7 44 if ($dry_run) { }
445 2 0 unless ($msg)
446 2 0 $args ? :
452 2 1 if (&$check($self, \@args, $addinfo))
466 17 17 if (@args and ref $args[0] eq "HASH")
468 0 34 if %options
473 33 4 if (@s) { }
474 30 3 if (($s[2] & 4095) != $mode)
481 31 3 if (@files_to_change) { }
485 3 25 if ($changed_files != @files_to_change)
486 1 2 if (@files_to_change == 1) { }
1 1 elsif ($changed_files == 0) { }
495 16 15 $quiet ? :
506 2 10 if (@args and ref $args[0] eq "HASH")
508 0 12 if %options
511 3 9 if (not defined $uid) { }
2 7 elsif (not $uid =~ /^-?\d+$/) { }
515 1 1 unless (defined $_uid)
526 6 5 if (not defined $gid) { }
1 4 elsif (not $gid =~ /^-?\d+$/) { }
530 1 0 unless (defined $_gid)
537 9 1 if ($uid != -1 or $gid != -1)
540 7 3 if (@s) { }
541 0 7 if ($uid != -1 and $s[4] != $uid) { }
0 12 elsif ($gid != -1 and $s[5] != $gid) { }
552 2 8 if (@files_to_change) { }
556 2 0 if ($changed_files != @files_to_change)
557 1 1 if (@files_to_change == 1) { }
1 0 elsif ($changed_files == 0) { }
566 0 2 $quiet ? :
581 1 13 if %opts
583 1 12 unless ($cmd)
586 1 11 if (ref $cmd ne "ARRAY")
591 1 10 if ($if and not &$if())
594 1 9 if ($doit and $unless and &$unless())
597 2 7 if ($doit and $creates and -e $creates)
601 7 4 if ($doit) { }
603 1 6 if (ref $cmd->[0] eq 'ARRAY') { }
619 1 5 if (not defined $oldfile) { }
1 4 elsif (not defined $newfile) { }
2 2 elsif (-l $newfile) { }
1 1 elsif (-d $newfile) { }
624 0 2 unless my $points_to = readlink $newfile
626 1 1 if ($points_to eq $oldfile)
638 2 1 if ($doit) { }
642 0 2 if $? != 0
655 1 2 if (ref $directories[-1] eq "HASH")
657 2 1 if (@directories_to_create) { }
661 0 2 unless File::Path::make_path(@directories_to_create, $options)
675 18 2 if (not -d $directory) { }
677 2 16 if (defined $mode) { }
679 1 1 unless mkdir $directory, $mode
685 1 15 unless mkdir $directory
698 1 3 if (ref $directories[-1] eq "HASH")
700 3 1 if (@directories_to_remove) { }
704 0 3 unless File::Path::remove_tree(@directories_to_remove, $options)
720 1 12 unless rename $from, $to
729 3 14 if (@args and ref $args[0] eq "HASH")
731 1 16 if %options
732 1 15 if (@args != 2)
738 4 11 if (-d $to) { }
744 11 4 if (not -e $real_to or do { require File::Compare; File::Compare::compare($from, $real_to) != 0 }) { }
748 2 9 unless File::Copy::copy($from, $to)
752 7 4 if (not -e $real_to) { }
755 1 3 if ($quiet) { }
775 1 1 unless File::Copy::move($from, $to)
785 1 53 if ($? == -1) { }
10 43 elsif ($? & 127) { }
793 0 10 $? & 128 ? :
811 0 50 if %opts
815 22 28 if (defined $prefix_msg)
823 42 99 if ($flag) { }
851 8 3 if (@args and ref $args[0] eq "HASH")
854 6 5 unless defined $instr
855 0 11 if %options
859 1 2 $quiet || $info ? :
3 7 unless $? == 0
865 4 7 $info ? :
1 10 $quiet ? :
874 1 2 if (@args and ref $args[0] eq "HASH")
889 27 11 defined $instr ? :
890 27 10 if (defined $instr)
904 74 34 if ($buf eq '') { }
907 37 37 if $sel->count == 0
921 37 2 if (@args and ref $args[0] eq "HASH")
927 0 39 if %options
932 30 7 if ($errref)
936 2 35 if ($statusref) { }
939 4 31 if ($? != 0)
940 1 3 $quiet || $info ? :
948 4 35 $info ? :
24 15 $quiet ? :
957 1 2 if (@args and ref $args[0] eq "HASH")
966 0 147 unless open my $fh, "-|", @args
976 141 7 if (@args and ref $args[0] eq "HASH")
980 0 148 if %options
984 2 145 if ($statusref) { }
987 22 123 if ($? != 0)
988 20 2 $quiet || $info ? :
995 138 10 $info ? :
135 13 $quiet ? :
1004 134 3 if (@args and ref $args[0] eq "HASH")
1011 5 1 if (-d $directory) { }
1013 1 4 unless rmdir $directory
1029 3 5 if (not $success)
1036 6 8 if (ref $arg eq 'ARRAY') { }
1051 2 1 if (not defined $ENV{$key} or $ENV{$key} ne $val) { }
1054 1 1 defined $ENV{$key} ? :
1066 1 1 if (-l $newfile) { }
1 0 elsif (not -e $newfile) { }
1067 0 1 unless my $points_to = readlink $newfile
1069 0 1 if ($points_to ne $oldfile)
1077 1 1 if ($doit) { }
1079 0 1 unless symlink $oldfile, $newfile
1091 47 96 if (@args and ref $args[0] eq "HASH")
1095 0 143 if %options
1101 18 124 if ($? != 0)
1107 3 140 $info ? :
2 141 $quiet ? :
1118 0 2 if (@args and ref $args[0] eq "HASH")
1127 28 1 if (not -e $file) { }
1129 0 28 unless open my $fh, ">>", $file
1134 0 1 unless utime time, time, $file
1148 16 2 unless (-e $file)
1150 0 16 unless open my $fh, ">>", $file
1155 15 1 if (@commands) { }
1168 25 3 if (-e $file or -l $file)
1172 18 2 if (@files_to_remove) { }
1174 0 18 unless unlink @files_to_remove
1185 1 1 if (defined $ENV{$key}) { }
1201 1 9 unless (defined $atime)
1204 1 9 unless (defined $mtime)
1211 10 4 if (@s) { }
1212 10 0 if ($s[8] != $atime or $s[9] != $mtime)
1220 10 0 if (@files_to_change) { }
1224 3 7 if ($changed_files != @files_to_change)
1225 1 2 if (@files_to_change == 1) { }
1 1 elsif ($changed_files == 0) { }
1245 2 13 if (@args != 1)
1254 15 22 if (@args and ref $args[0] eq "HASH")
1256 1 36 exists $options{'atomic'} ? :
1257 1 36 if %options
1258 1 35 if (@args != 2)
1265 17 18 if (not -e $filename) { }
13 5 elsif (-s $filename != length $content) { }
1271 0 5 unless open my $fh, "<", $filename
1276 1 4 if ($file_content ne $content)
1282 31 4 if ($doit) { }
1288 30 1 $atomic ? :
1289 1 30 unless open my $ofh, ">", $outfile
1291 14 16 if (-e $filename)
1296 0 30 unless close $ofh
1298 29 1 if ($atomic)
1299 0 29 unless rename $outfile, $filename
1306 4 27 $quiet >= 2 ? :
1307 8 19 if ($quiet) { }
1308 2 6 if ($need_diff) { }
1314 9 10 if ($need_diff) { }
1331 3 44 if (@args and ref $args[0] eq "HASH")
1334 0 47 if ($check and ref $check ne "CODE")
1335 1 46 if %options
1337 1 45 if (@args < 1)
1342 2 43 unless (-e $file)
1345 2 41 unless (-f $file)
1352 26 20 if ($_->{'add_if_missing'})
1355 10 16 if (defined $_->{'add_after'} or defined $_->{'add_after_first'} or defined $_->{'add_before'} or defined $_->{'add_before_last'}) { }
1366 0 10 if ($defines != 1)
1372 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'}) { }
1395 4 2 $reverse ? :
1396 4 2 $reverse ? :
1397 4 2 $reverse ? :
1398 11 2 $reverse ? :
1399 5 7 if ($arrayref->[$i] =~ /$add/)
1400 3 2 if ($do_after) { }
1409 1 5 if (not $found)
1422 29 17 if ($_->{'unless_match'}) { }
16 1 elsif ($_->{'match'}) { }
1423 26 3 if (ref $_->{'unless_match'} ne "Regexp")
1427 1 28 unless ($_->{'action'})
1430 1 27 if (ref $_->{'action'} ne "CODE")
1435 3 13 if (ref $_->{'match'} ne "Regexp")
1439 3 13 $_->{'action'} ? :
7 9 defined $_->{'replace'} ? :
5 11 defined $_->{'delete'} ? :
1440 1 15 if ($consequences != 1)
1443 3 12 if ($_->{'action'}) { }
7 5 elsif (defined $_->{'replace'}) { }
5 0 elsif (defined $_->{'delete'}) { }
1444 1 2 if (ref $_->{'action'} ne "CODE")
1464 0 36 unless File::Copy::copy($file, $tmpfile)
1469 0 36 unless tie my @lines, "Tie::File", $tmpfile
1476 0 44 if ($debug)
1477 18 26 if ($lines[$line_i] =~ /$match/)
1478 9 9 if (exists $match_action->{'replace'}) { }
6 3 elsif (exists $match_action->{'delete'}) { }
1480 9 0 if ($lines[$line_i] ne $replace)
1486 5 1 if ($match_action->{'delete'})
1504 8 62 if ($line =~ /$match/)
1517 25 10 if ($no_of_changes)
1520 2 22 if ($check)
1524 0 1 unless &$check($tmpfile)
1527 0 23 unless rename $tmpfile, $file
1537 25 10 if ($no_of_changes) { }
1548 9 28 if (ref $file2)
1553 8 29 unless (@diff_cmd)
1555 0 8 if ($^O eq "MSWin32")
1559 8 0 if (Doit::Util::is_in_path($diff_candidate->[0]))
1564 0 0 !$diff_error_shown++ ? :
0 8 unless @diff_cmd
1569 0 37 if ($^O eq "MSWin32" and $diff_cmd[0] eq "fc")
1571 0 0 if ($file2 eq "-")
1577 37 0 if (not $cannot_use_dash and eval { do { require IPC::Run; 1 } }) { }
1578 0 37 unless (eval { do { IPC::Run::run([@diff_cmd, $file1, $file2], defined $stdin ? ("<", \$stdin) : (), ">", \$diff, "2>", \$diff_stderr); 1 } })
1579 9 28 defined $stdin ? :
1581 0 0 !$diff_error_shown++ ? :
1585 0 0 if ($^O eq 'MSWin32' or $cannot_use_dash) { }
1587 0 0 if ($file2 eq "-")
1600 0 0 if ($@)
1601 0 0 !$diff_error_shown++ ? :
1625 45 0 if (@commands)
1633 411 236 if (exists $command->{'msg'})
1636 613 34 if (exists $command->{'code'})
1638 355 190 if (exists $command->{'rv'}) { }
1651 18 4 if (exists $command->{'msg'})
1652 9 9 $command->{'run_always'} ? :
1654 21 1 if (exists $command->{'code'})
1656 9 12 if ($command->{'run_always'})
1659 12 9 if (exists $command->{'rv'}) { }
1675 0 51 if %options
1694 23 631 if ($self->{'dryrun'}) { }
1707 3 14 if ($component_or_module =~ /::/) { }
1714 2 4 if $_->{'module'} eq $module
1717 1 14 unless (eval " require $module; 1 ")
1720 0 14 unless my $o = $module->new
1737 0 14 if ($o->can("add_components"))
1768 2 8 if ($context eq 'a') { }
1773 2 8 if ($@) { }
1783 6 0 unless $sub =~ /::/
1790 5 0 unless $sub =~ /::/
1837 0 23 if (not defined $ret) { }
1 22 elsif (not $ret) { }
1843 0 22 unless read $fh, $buf, $length
1858 0 0 unless defined $pid
1859 0 0 if (eval { do { require POSIX; defined &POSIX::WNOHANG } }) { }
1860 0 0 if ($self->{'debug'})
1870 0 0 if (time - $start_time >= 2)
1876 0 0 if (not $got_pid)
1880 0 0 if (not $done_POSIX_warning++)
1896 0 0 if %opts
1900 0 0 if $ret
1902 0 0 if ($fast_tries and eval { do { require Time::HiRes; 1 } }) { }
1907 0 0 $try <= $fast_tries && defined &Time::HiRes::sleep ? :
1908 0 0 if $retry_msg_code
1926 0 2 if %options
1940 2 9 wantarray ? :
1943 2 9 if (defined $rettype and $rettype eq 'e') { }
9 0 elsif (defined $rettype and $rettype eq 'r') { }
1946 2 7 if ($context eq 'a') { }
1952 0 0 defined $self->{'label'} ? :
0 0 defined $rettype ? :
1966 0 0 if %options
1985 0 0 if ($self->{'debug'}) { }
1995 0 0 if (not $self->{'excl'} and -e $sockpath)
1999 0 0 unless my $sock = "IO::Socket::UNIX"->new("Type", SOCK_STREAM(), "Local", $sockpath, "Listen", 1)
2009 0 0 if $ready[0] != $sock
2016 0 0 if (not defined $context) { }
0 0 elsif ($data[0] =~ /^exit$/) { }
2042 0 1 if %options
2044 0 1 unless $infh
2045 0 1 unless $outfh
2059 0 7 if (not defined $context) { }
1 6 elsif ($data[0] =~ /^exit$/) { }
2065 0 6 unless open my $oldout, ">&STDOUT"
2069 0 6 unless open STDOUT, ">", "/dev/stderr"
2072 0 6 unless open STDOUT, ">&", $oldout
2094 0 0 if $^O eq "linux"
2109 0 0 unless (defined $realscript)
2110 0 0 if ($realscript ne '-e') { }
2130 0 0 unless delete $opts{'sudo_opts'}
2133 0 0 unless delete $opts{'components'}
2135 0 0 if %opts
2159 0 0 if ($? != 0)
2170 0 0 $class->_can_LANS ? :
2173 0 0 $debug ? :
0 0 $LANS_PREFIX ? :
0 0 $dry_run ? :
2184 0 0 if (not defined $worker_pid) { }
0 0 elsif ($worker_pid == 0) { }
2187 0 0 if $debug
2197 0 0 if $debug
2221 0 6 unless delete $opts{'components'}
2229 6 0 unless defined $dest_os
2231 1 5 unless $put_to_remote =~ /^(rsync_put|scp_put)$/
2235 1 4 if (defined $umask and not $umask =~ /^\d+$/)
2239 0 4 if %opts
2242 0 4 $forward_agent ? :
0 4 $tty ? :
2246 0 4 $forward_agent ? :
4 0 $master_opts ? :
2252 0 4 if (UNIVERSAL::isa($ssh_or_host, 'Net::OpenSSH')) { }
2258 4 0 if $ssh->error
2263 0 0 if (($bootstrap || '') eq "perl")
2270 0 0 if ($dest_os eq 'MSWin32') { }
2275 0 0 if ($debug)
2280 0 0 if ($FindBin::RealScript ne "-e")
2287 0 0 $dest_os ne 'MSWin32' ? :
2301 0 0 unless ($seen_dir{$target_dir})
2303 0 0 if ($dest_os eq 'MSWin32') { }
2319 0 0 $dest_os eq 'MSWin32' ? :
2326 0 0 if (defined $as)
2327 0 0 if ($as eq 'root') { }
2335 0 0 if ($dest_os eq 'MSWin32') { }
2336 0 0 $debug ? :
0 0 $dry_run ? :
2350 0 0 defined $umask ? :
0 0 $debug ? :
0 0 $dry_run ? :
2364 0 0 if $debug
2369 0 0 if ($dest_os eq 'MSWin32') { }
2384 0 0 if $debug
2397 0 4 if ($self->{'ssh'})
2398 0 0 if $self->{'ssh'}->can("disconnect")
2401 0 4 if ($self->{'rpc'})
2414 0 0 unless defined $peer
2416 0 0 if %options
2426 0 0 if ($debug) { }
2445 0 0 if $sock
2455 0 0 unless ($sock)
2464 0 0 unless read $infh, $length_buf, 4
2470 0 0 if $got == $length
2471 0 0 if $got > $length
2484 0 0 if eof $infh