Branch Coverage

blib/lib/App/Fetchware/Util.pm
Criterion Covered Total %
branch 108 230 46.9


line true false branch
81 2162 2 if (not defined $fetchware::quiet && $fetchware::quiet > 0) { }
84 92 2070 if ($_[$#_] =~ /\w*\n\w*\z/) { }
104 4557 2 if (not defined $fetchware::quiet && $fetchware::quiet > 0) { }
106 3844 713 if (defined $fetchware::verbose and $fetchware::verbose > 0)
109 1174 2670 if ($_[$#_] =~ /\w*\n\w*\z/) { }
135 284 0 if ($arg =~ /(.*)/) { }
152 160 2 if (not defined $fetchware::quiet && $fetchware::quiet > 0) { }
157 0 160 unless system($program, @args) == 0
167 2 0 if (not is_os_type('Windows', $^O)) { }
168 0 2 unless open my $fh, '-|', "$program", @args
180 0 0 unless open my $fh, '-|', "$program @args"
209 3 0 if (@_ == 1) { }
0 0 elsif (@_ == 2) { }
215 0 0 unless (exists $opts{'PATH'} or defined $opts{'PATH'})
230 0 3 if not config('mirror') and exists $opts{'PATH'}
250 3 0 if ($scheme ne 'file')
253 0 3 if (exists $opts{'PATH'} and defined $opts{'PATH'} and $opts{'PATH'}) { }
3 0 elsif (defined $url and $url) { }
280 6 3 if ($path eq '') { }
312 0 3 if ($@)
319 3 0 if (defined $dirlist)
325 0 3 unless defined $dirlist
341 0 3 if ($url =~ m[^ftp://.*$]) { }
0 3 elsif ($url =~ m[^http://.*$]) { }
3 0 elsif ($url =~ m[^file://.*$]) { }
371 0 0 unless $ftp = 'Net::FTP'->new($site)
378 0 0 unless $ftp->login('anonymous', '-anonymous@')
385 0 0 unless my(@dir_listing) = $ftp->dir($path)
403 0 0 if @_ % 2 == 0
406 0 0 if config('user_agent')
419 0 0 unless $$response{'success'}
428 0 0 ref $v eq 'ARRAY' ? :
432 0 0 unless length $$response{'content'}
449 0 9 unless (file_name_is_absolute($local_lookup_url))
454 2 7 unless -e $local_lookup_url
462 0 7 unless opendir my $dh, $local_lookup_url
469 230 14 unless ($filename eq '.' or $filename eq '..')
487 2 5 if $pc_local_lookup_url->stat and not $pc_local_lookup_url->children
506 2 3 if (@_ == 1) { }
3 0 elsif (@_ == 2) { }
512 0 0 unless (exists $opts{'PATH'} or defined $opts{'PATH'})
527 0 5 if (not config('mirror') and exists $opts{'PATH'} and not config('lookup_url') =~ m[^file://])
542 3 2 if (exists $opts{'PATH'} and config('lookup_url') =~ m[^file://]) { }
0 2 elsif (defined config('lookup_url')) { }
555 0 5 if (exists $opts{'PATH'} and defined $opts{'PATH'} and $opts{'PATH'}) { }
5 0 elsif (defined $url and $url) { }
569 0 0 if $path eq $opts{'PATH'}
570 0 0 if ($path eq '') { }
594 0 0 if (not $path =~ m[/$]) { }
623 5 5 if $path eq $url_path
624 5 0 if ($path eq '') { }
648 0 0 if (not $path =~ m[/$]) { }
670 0 5 if ($@)
677 5 0 if (defined $filename)
683 0 5 unless defined $filename
699 0 5 if ($url =~ m[^ftp://]) { }
0 5 elsif ($url =~ m[^http://]) { }
5 0 elsif ($url =~ m[^file://]) { }
731 0 0 unless my $ftp = 'Net::FTP'->new($site)
738 0 0 unless $ftp->login('anonymous', '-anonymous@')
745 0 0 unless $ftp->binary
753 0 0 unless $ftp->cwd($directories)
762 0 0 unless $ftp->get($file)
783 0 0 if @_ % 2 == 0
786 0 0 if config('user_agent')
807 0 0 unless $$response{'success'}
817 0 0 unless length $$response{'content'}
835 0 0 unless open my $fh, '>', $filename
842 0 0 unless close $fh
863 0 5 unless file_name_is_absolute($url)
881 0 5 unless cp($untainted_url, $untainted_cwd)
913 162 1 if (not exists $opts{'MODE'} && defined $opts{'MODE'}) { }
914 0 162 unless open $fh, '<', $file_to_check
916 0 1 unless open $fh, $opts{'MODE'}, $file_to_check
923 0 163 if ($info->uid != 0 and $info->uid != $<)
936 2 161 if ($info->mode & 18)
980 0 642 if ($info->uid != 0 and $info->uid != $<)
993 161 481 if ($info->mode & 18)
995 2 159 unless $info->mode & 512 and S_ISDIR($info->mode)
1034 0 2 unless open my $output_fh, '>', \$output
1040 0 2 unless close $output_fh
1049 2 125 if (config('stay_root'))
1056 125 0 if (is_os_type('Unix') and $< == 0 || $> == 0) { }
1070 6 119 unless file(cwd())->basename =~ /^fetchware-$$/
1072 0 6 unless (exists $opts{'SkipTempDirCreation'} and defined $opts{'SkipTempDirCreation'} and $opts{'SkipTempDirCreation'})
1079 119 0 unless ((S_IMODE($st->mode) & 493) >= 493)
1080 0 119 unless chmod 0755, cwd()
1108 0 119 unless chown $uid, $gid, $new_temp_dir
1113 0 119 unless chmod 0700, $new_temp_dir
1121 0 119 unless chdir $new_temp_dir
1129 0 125 unless pipe READONLY, WRITEONLY
1154 0 125 unless (defined $_)
1162 125 0 if ($kidpid) { }
1163 0 125 unless close $writeonly
1173 0 125 unless close $readonly
1186 0 125 if ($? >> 8 != 0) { }
1210 0 0 unless close $readonly
1224 0 0 unless close $writeonly
1276 0 4 if $a_var =~ /$MAGIC_NUMBER/
1294 0 120 if ref $output ne 'SCALAR'
1302 0 111 unless defined $variable
1314 111 0 if ($variable =~ /(.*)/ms) { }
1380 2 341 unless eval { do { local $@; my(@args) = "fetchware-$$-XXXXXXXXXX"; push @args, 'DIR', $opts{'TempDir'} if defined $opts{'TempDir'}; push @args, defined $opts{'TempDir'} ? ('DIR', $opts{'TempDir'}) : ('TMPDIR', 1); push @args, 'CLEANUP', 1 unless defined $opts{'KeepTempDir'}; $temp_dir = tempdir(@args); if (config('stay_root') or ($< != 0 or $> != 0)) { die "App-Fetchware-Util: Fetchware failed to change the permissions of its temporary\ndirectory [$temp_dir] to 0700. This should not happen, and is a bug, or perhaps\nyour system's temporary directory is full. The OS error was [$!].\n" unless chmod 0700, $temp_dir; } ; $exception = $@; 1 } }
1387 5 338 if defined $opts{'TempDir'}
1390 5 338 defined $opts{'TempDir'} ? :
1394 335 8 unless defined $opts{'KeepTempDir'}
1400 0 341 if (config('stay_root') or ($< != 0 or $> != 0))
1404 0 0 unless chmod 0700, $temp_dir
1425 0 341 unless chdir $temp_dir
1433 0 341 unless open $fh_sem, '>', 'fetchware.sem'
1445 0 341 unless flock $fh_sem, 6
1470 327 0 if (defined $fh_sem)
1471 0 327 unless close $fh_sem
1486 327 0 if (defined original_cwd())
1488 0 327 unless chdir original_cwd()