Branch Coverage

lib/Mail/Toaster/Utility.pm
Criterion Covered Total %
branch 202 694 29.1


line true false branch
40 0 0 unless ($self->is_interactive)
45 0 0 unless $question =~ /\A \p{Any}* \z/msx
50 0 0 if defined $p{'test_ok'}
54 0 0 if $default and not $pass
57 0 0 if $pass
59 0 0 if ($p{'timeout'}) { }
66 0 0 if ($Mail::Toaster::Utility::EVAL_ERROR)
67 0 0 $Mail::Toaster::Utility::EVAL_ERROR eq "alarm\n" ? :
74 0 0 if ($pass)
77 0 0 unless ($response eq $response2)
87 0 0 if $response
88 0 0 if $default
94 0 5 unless my $file = shift()
105 1 4 unless -e $file
110 0 4 if ($p{'destdir'} and -d $p{'destdir'})
116 4 0 if ($self->is_writable($file, %args) and $self->is_writable($archive, %args))
121 4 0 if (-e $archive)
123 0 4 if $p{'mode'}
129 0 0 if $p{'sudo'} and $< != 0
131 0 0 unless -e $archive
134 0 0 if $p{'mode'}
147 0 0 if ($sudo and $cp)
171 0 3 unless my $file = $p{'file'} || $p{'file_or_dir'} || $p{'dir'}
173 0 3 if ($p{'sudo'})
176 0 0 unless $self->syscmd("$sudo $chmod $mode $file", 'verbose', 0)
181 0 3 unless CORE::chmod oct $mode, $file
201 0 3 unless $file
202 0 3 unless -e $file
207 0 3 if $sudo
215 0 3 if ($uid =~ /\A[0-9]+\z/) { }
221 1 2 unless defined $nuid
225 0 2 if ($gid =~ /\A[0-9\-]+\z/) { }
231 0 2 unless defined $ngid
235 0 2 unless CORE::chown $nuid, $ngid, $file
255 0 1 unless $dir
258 0 1 if $recurse
260 0 1 if $group
265 0 1 unless $self->syscmd($cmd, %args)
269 0 1 if $recurse
278 0 2 unless my $dir = shift()
285 0 2 unless chdir $dir
288 0 4 unless $_
294 3 1 if (-f $file) { }
1 0 elsif (-d $file) { }
295 0 3 unless unlink $file
299 0 1 unless rmtree($file)
312 0 2 unless my $dir = shift()
323 0 2 if -e $dir and not -d $dir
327 1 1 unless (-d $dir)
331 0 1 unless (-d $dir)
335 0 0 unless (-d $dir)
337 0 0 unless $self->mkdir_system('dir', $dir, 'sudo', 1, %args)
343 0 2 unless chdir $dir
349 0 1 unless mkpath($dir, 0, 493)
357 0 2 unless my $archive = shift()
368 1 1 unless (-e $archive)
370 6 0 unless -e "$archive.$ext"
375 1 1 unless -e $archive
379 0 0 $archive =~ /xz$/ ? :
1 0 $archive =~ /gz$/ ? :
0 1 $archive =~ /bz2$/ ? :
391 0 1 unless grep /$types{$type}{'content'}/, `$file $archive`
396 0 1 unless $self->syscmd("$bin -c $archive | $tar -xf -")
404 0 6 unless my $file = shift()
413 1 5 unless -e $file
415 5 0 if (-w $file)
418 0 5 unless unlink $file
424 0 0 unless ($p{'sudo'})
425 0 0 -e $file ? :
432 0 0 if ($< != 0)
438 0 0 unless $self->syscmd($rm_command, %args)
441 0 0 -e $file ? :
465 1 1 if $stat2 > $stat1
478 0 11 unless my $file = shift()
490 0 11 unless -e $file
491 0 11 unless -r $file
493 0 11 unless open my $FILE, '<', $file
498 11 0 unless ($max_lines)
508 0 0 if ($max_length) { }
510 0 0 unless $line
511 0 0 if eof $FILE
531 0 1 unless -e $file
549 0 10 unless my $file = shift()
563 0 10 if -d $file
564 0 10 unless $self->is_writable($file, %args)
570 3 7 if ($append)
573 3 0 if (-f $file)
574 0 3 unless copy($file, "$file.tmp")
579 1 9 unless open my $HANDLE, $write_mode, "$file.tmp"
584 0 9 unless close $HANDLE
588 0 9 unless move("$file.tmp", $file)
593 0 9 if $p{'mode'}
612 0 5 unless (-e $f1 and -e $f2)
617 2 3 if $type ne 'text'
638 0 2 if $Mail::Toaster::Utility::EVAL_ERROR
649 2 2 if (-f "$f.md5")
655 3 1 if (not -f "$f.md5" && $sum =~ /[0-9a-f]+/i or $self->file_is_newer('f1', "$f.md5", 'f2', $f, %$args))
669 3 1 if $changed
672 1 1 if $md5sums[0] eq $md5sums[1]
678 0 39 unless my $bin = shift()
688 0 39 if ($bin =~ m[^/] and -x $bin)
694 0 39 if $p{'dir'}
703 36 215 if (-x "$prefix/$bin")
704 36 0 if $found = "$prefix/$bin"
708 36 3 if ($found)
718 0 11 unless my $file = shift()
725 0 11 if ($p{'verbose'} > 1)
734 1 10 if $etcdir and -d $etcdir
739 2 9 if ($r)
745 7 2 if (-r "./$file-dist")
756 9 49 unless my $dir = shift()
759 2 47 if (-r "$dir/$file")
764 19 28 unless (-d $dir)
769 0 28 unless (-r $dir)
775 0 28 if (-e "$dir/$file")
786 0 1 if ($Mail::Toaster::Utility::OSNAME eq 'darwin')
791 0 1 unless (-e $fstab)
792 0 0 if $p{'verbose'}
859 0 3 unless my $dir = shift()
866 0 3 unless -d $dir
869 0 3 unless opendir D, $dir
872 6 137 if $f =~ /^\.\.?$/
916 0 0 if $p{'exclude_ipv6'}
917 0 0 if $p{'exclude_localhost'}
919 0 0 if $p{'exclude_internals'}
922 0 0 if (@ips < 1 or $ips[0] eq '')
926 0 0 if $once < 2
931 0 0 if $only eq 'first'
932 0 0 if $only eq 'last'
951 1 4 if $bump
953 1 4 if $time != $offset_time
957 5 0 unless ($Mail::Toaster::Utility::EVAL_ERROR)
998 0 1 unless -x $mount
1006 31 0 if ($m and $m =~ m[^/])
1030 0 0 if ($Mail::Toaster::Utility::EVAL_ERROR)
1036 0 0 if $@
1041 0 0 if $dir
1045 0 0 if $Mail::Toaster::Utility::EVAL_ERROR
1047 0 0 if ($response)
1048 0 0 if ($response == 404) { }
0 0 elsif ($response == 304) { }
0 0 elsif ($response == 200) { }
1062 0 0 unless -e $file_path
1082 0 0 if ($Mail::Toaster::Utility::OSNAME eq 'freebsd') { }
0 0 elsif ($Mail::Toaster::Utility::OSNAME eq 'darwin') { }
1084 0 0 if ($fetchbin and -x $fetchbin)
1086 0 0 unless $verbose
1091 0 0 if ($fetchbin and -x $fetchbin)
1093 0 0 unless $verbose
1097 0 0 unless ($found)
1099 0 0 if $fetchbin and -x $fetchbin
1102 0 0 unless $found
1108 0 0 unless ($timeout)
1109 0 0 unless $self->syscmd($fetchcmd, %args)
1111 0 0 if $@
1115 0 0 if (-e $file and $dir and -d $dir)
1130 0 0 if ($Mail::Toaster::Utility::EVAL_ERROR)
1131 0 0 if $Mail::Toaster::Utility::EVAL_ERROR eq "alarm\n"
1135 0 0 unless $r
1144 0 16 $ver ? :
1173 0 1 unless ($newfile =~ m[/])
1180 0 1 unless -e $newfile
1183 0 1 unless -f $newfile
1187 0 1 unless ($self->is_writable($existing, 'fatal', 0) and $self->is_writable($newfile, 'fatal', 0))
1191 0 0 if $Mail::Toaster::Utility::UID == 0
1193 0 0 if ($sudo)
1194 0 0 unless $sudo = $self->find_bin('sudo', %args)
1200 1 0 if (-f $existing)
1205 1 0 unless ($diffie = $self->files_diff(%args, 'f1', $newfile, 'f2', $existing, 'type', 'text'))
1207 0 1 if $p{'clean'}
1214 0 0 if $uid and $gid
1223 0 0 if -e $existing and $mode
1232 0 0 if -e $existing and $p{'archive'}
1235 0 0 if $uid and $gid
1242 0 0 if $mode
1259 0 0 if ($sudo) { }
1263 0 0 if -e $existing
1267 0 0 if ($clean) { }
1278 0 0 if -e $existing
1280 0 0 if ($clean) { }
1281 0 0 unless move($newfile, $existing)
1285 0 0 unless copy($newfile, $existing)
1295 0 0 unless $notify
1296 0 0 unless -f $existing
1302 0 0 if $Mail::Toaster::Utility::EVAL_ERROR
1333 2 0 if defined $p{'test_ok'}
1342 0 0 if $p{'source_sub_dir'}
1344 0 0 if ($bintest and $self->find_bin($bintest, 'fatal', 0, 'verbose', 0))
1345 0 0 unless $self->yes_or_no("$bintest exists, suggesting that " . "$package is installed. Do you want to reinstall?", 'timeout', 60)
1357 0 0 unless $self->install_from_source_cleanup($package, $srcdir)
1358 0 0 unless $self->install_from_source_get_files($package, $site, $url, $p{'patch_url'}, $patches)
1359 0 0 unless $self->extract_archive($package)
1363 0 0 if (-d $package) { }
1364 0 0 unless chdir $package
1374 0 0 if $sub_path
1375 0 0 unless -d $sub_path and chdir $sub_path
1379 0 0 unless $self->install_from_source_apply_patches($srcdir, $patches, $patch_args)
1382 0 0 unless (@$targets[0])
1394 0 0 if ($target =~ /^cd (.*)$/)
1396 0 0 unless chdir $1
1400 0 0 unless $self->syscmd($target, %args)
1406 0 0 if -d $package
1408 0 0 if (defined $sub_path and -d "$package/$sub_path")
1420 0 0 unless $patches
1421 0 0 unless $patches->[0]
1425 0 0 unless $self->syscmd("$patchbin $patch_args < $src/$patch")
1436 0 0 unless -d $package
1438 0 0 unless $self->source_warning('package', $package, 'clean', 1, 'src', $src)
1446 0 0 unless File::Path::rmtree($dir)
1456 0 0 unless $self->sources_get('package', $package, 'site', $site, 'path', $url)
1462 0 0 unless ($patches and $patches->[0])
1467 0 0 unless $patch_url
1471 0 0 unless $patch
1472 0 0 if -e $patch
1482 0 0 if (lc $Mail::Toaster::Utility::OSNAME eq 'freebsd')
1485 0 0 unless my $portname = $info->{'port'}
1489 0 0 if ($freebsd->is_port_installed($app))
1497 0 0 unless -d $portdir and chdir $portdir
1500 0 0 if system 'make install clean'
1505 0 0 if (lc $Mail::Toaster::Utility::OSNAME eq 'linux')
1506 0 0 unless my $rpm = $info->{'rpm'}
1508 0 0 unless -x $yum
1519 0 0 if (lc $Mail::Toaster::Utility::OSNAME eq 'darwin') { }
0 0 elsif (lc $Mail::Toaster::Utility::OSNAME eq 'freebsd') { }
0 0 elsif (lc $Mail::Toaster::Utility::OSNAME eq 'linux') { }
1520 0 0 if $self->install_module_darwin($module)
1523 0 0 if $self->install_module_freebsd($module, \%info)
1526 0 0 if $self->install_module_linux($module, \%info)
1532 0 0 unless ($Mail::Toaster::Utility::EVAL_ERROR)
1552 0 0 if ($module eq 'Provision::Unix' and $version)
1564 0 0 unless -x $dport
1569 0 0 unless system "sudo $dport install $port"
1578 0 0 unless ($portname)
1583 0 0 if $self->freebsd->is_port_installed($portname)
1584 0 0 if $self->freebsd->install_package($portname)
1587 0 0 unless $portdir
1588 0 0 unless -d $portdir
1615 0 0 if (-d $module)
1616 0 0 unless ($self->source_warning('package', $module, 'src', $src, %args))
1620 0 0 unless File::Path::rmtree("$module")
1626 0 0 unless $self->sources_get('site', $site, 'path', $url, 'package', $p{'archive'} || $module, %args)
1630 0 0 unless $self->extract_archive($module)
1636 0 0 unless -d $file
1637 0 0 unless $file =~ /$module/
1643 0 0 unless (@$targets[0] and @$targets[0] ne '')
1650 0 0 unless $self->syscmd('cmd', $_, %args)
1655 0 0 unless File::Path::rmtree($file)
1666 0 0 if ($rpm)
1670 0 0 if -x $yum
1682 0 0 unless -t $out_handle
1685 0 0 if (&openhandle(*ARGV))
1688 0 0 if defined $ARGV and $ARGV eq '-'
1691 0 0 if eof ARGV
1708 0 13 if (lc($Mail::Toaster::Utility::OSNAME) =~ /solaris/i) { }
0 13 elsif (lc($Mail::Toaster::Utility::OSNAME) =~ /irix/i) { }
13 0 elsif (lc($Mail::Toaster::Utility::OSNAME) =~ /linux/i) { }
1720 0 2 unless my $file = shift()
1725 1 1 unless -e $file
1726 0 1 unless -r $file
1735 0 23 unless my $file = shift()
1741 0 23 if $ENV{'GATEWAY_INTERFACE'}
1743 9 14 unless (-e $file)
1747 0 9 if -e $path and not -w $path
1753 0 14 unless -w $file
1761 0 3 unless my $file = shift()
1774 0 3 unless open my $LOG_FILE, '>>', $file
1808 0 2 if -d $dir
1810 0 2 unless my $mkdir = $self->find_bin('mkdir', %args)
1813 2 0 if ($< == 0)
1814 0 2 unless $self->syscmd("$mkdir -p $dir", %args)
1815 0 2 if $mode
1817 2 0 if -d $dir
1821 0 0 if ($p{'sudo'})
1831 0 0 if $mode
1833 0 0 -d $dir ? :
1839 0 0 unless $self->syscmd("$mkdir -p $dir", %args)
1841 0 0 if $mode
1843 0 0 if -d $dir
1853 0 3 unless $file
1854 1 2 if -e $file and not -f $file
1859 0 2 unless ($self->is_writable($file, %args))
1866 1 1 unless (-e $file)
1868 1 0 if $self->file_write($file, 'lines', [$Mail::Toaster::Utility::PROCESS_ID], %args)
1873 1 0 if ($age < 1200) { }
0 0 elsif ($age < 3600) { }
1892 0 8 unless my $file = shift()
1901 8 0 unless (-f $file)
1903 1 7 unless ($file and -r $file)
1912 444 2695 unless $_
1914 806 1889 if $_ =~ /^#/
1915 0 1889 if $_ =~ /^[\s+]?$/
1919 79 1810 unless $key
1951 903 990 if ($strip and $val and $val =~ /#/)
1980 0 1 if ($pbp)
1981 0 0 if ($string =~ /($exp)/msx) { }
1982 0 0 if $verbose
1986 0 0 if $verbose
1991 1 0 if ($string =~ /($exp)/)
1992 0 1 if $verbose
1996 0 0 if $verbose
2018 0 0 unless my $filet = $self->find_bin('file', %args)
2019 0 0 unless my $grep = $self->find_bin('grep', %args)
2024 0 0 unless -e $tarball
2025 0 0 if -e $tarball
2027 0 0 if (`$filet $tarball | $grep compress`)
2028 0 0 if $self->yes_or_no("$tarball exists, shall I use it?: ")
2040 0 0 unless $self->get_url("$site$path/$tarball", 'fatal', 0)
2043 0 0 unless -e $tarball
2047 0 0 if (`$filet $tarball | $grep zip`)
2078 1 0 unless -d $package
2080 0 0 if (-e $package)
2085 0 0 unless $p{'clean'}
2088 0 0 unless ($self->yes_or_no("\n\tMay I remove the sources for you?", 'timeout', $p{'timeout'}))
2096 0 0 unless rmtree("$src/$package")
2106 1 0 if ($Mail::Toaster::Utility::REAL_USER_ID == 0)
2115 0 0 if ($path_to_sudo and -x $path_to_sudo)
2123 0 0 unless ($self->yes_or_no('may I try to install sudo?', 'timeout', 20))
2128 0 0 unless -x $self->find_bin('sudo', 'fatal', 0)
2141 0 0 unless (-x $path_to_sudo)
2151 0 13 unless my $cmd = shift()
2166 13 0 if ($cmd =~ /\s+/mx) { }
2175 0 0 unless ($cmd =~ m[\./])
2178 0 13 if ($is_safe and not $bin)
2183 13 0 if $bin
2184 13 0 if $is_safe
2187 5 8 if ($bin and not -e $bin)
2188 0 5 unless $bin = $self->find_bin($bin, 'fatal', 0, 'verbose', 0)
2194 0 13 if &Scalar::Util::tainted($cmd)
2201 0 13 if $tainted and not $is_safe
2204 13 0 if ($is_safe)
2206 0 13 if -d '/opt/local'
2212 1 12 if (defined $p{'timeout'})
2218 1 12 if defined $p{'timeout'}
2221 0 13 if ($Mail::Toaster::Utility::EVAL_ERROR)
2222 0 0 if ($Mail::Toaster::Utility::EVAL_ERROR eq "alarm\n") { }
2242 9 4 if $exit_code == 0
2247 0 4 if ($err == -1) { }
0 4 elsif ($err & 127) { }
2251 0 0 $? & 128 ? :
2271 1 0 if $question eq 'test'
2274 0 0 unless ($p{'force'} or $self->is_interactive)
2281 0 0 if $p{'timeout'}
2298 0 0 if ($p{'timeout'})
2310 0 0 if ($@)
2311 0 0 $@ eq "alarm\n" ? :
2314 0 0 $response && $response eq 'y' ? :
2323 0 0 $response eq 'y' ? :