Branch Coverage

blib/lib/App/Fetchware/Util.pm
Criterion Covered Total %
branch 110 240 45.8


line true false branch
81 2466 2 if (not defined $fetchware::quiet && $fetchware::quiet > 0) { }
84 103 2363 if ($_[$#_] =~ /\w*\n\w*\z/) { }
104 5231 2 if (not defined $fetchware::quiet && $fetchware::quiet > 0) { }
106 4400 831 if (defined $fetchware::verbose and $fetchware::verbose > 0)
109 1362 3038 if ($_[$#_] =~ /\w*\n\w*\z/) { }
135 340 0 if ($arg =~ /(.*)/) { }
152 197 2 if (not defined $fetchware::quiet && $fetchware::quiet > 0) { }
157 0 197 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'}
239 0 3 if defined config('mirror')
240 0 3 if (exists $opts{'PATH'} and defined $opts{'PATH'} and $opts{'PATH'}) { }
3 0 elsif (defined $url and $url) { }
269 0 3 if ($path eq '') { }
301 0 3 if ($@)
308 3 0 if (defined $dirlist)
314 0 3 unless defined $dirlist
330 0 3 if ($url =~ m[^ftp://.*$]) { }
0 3 elsif ($url =~ m[^http://.*$]) { }
3 0 elsif ($url =~ m[^file://.*$]) { }
360 0 0 unless $ftp = 'Net::FTP'->new($site)
367 0 0 unless $ftp->login('anonymous', '-anonymous@')
374 0 0 unless my(@dir_listing) = $ftp->dir($path)
392 0 0 if @_ % 2 == 0
395 0 0 if config('user_agent')
408 0 0 unless $response->{'success'}
417 0 0 ref $v eq 'ARRAY' ? :
421 0 0 unless length $response->{'content'}
438 0 9 unless (file_name_is_absolute($local_lookup_url))
443 2 7 unless -e $local_lookup_url
451 0 7 unless opendir my $dh, $local_lookup_url
458 225 14 unless ($filename eq '.' or $filename eq '..')
476 2 5 if $pc_local_lookup_url->stat and not $pc_local_lookup_url->children
495 2 3 if (@_ == 1) { }
3 0 elsif (@_ == 2) { }
501 0 0 unless (exists $opts{'PATH'} or defined $opts{'PATH'})
515 0 0 config('lookup_url') =~ m[^file://] ? :
0 0 defined config('lookup_url') ? :
0 0 if (not config('mirror') and exists $opts{'PATH'} and defined config('lookup_url') ? config('lookup_url') =~ m[^file://] ? 1 : 0 : 1)
532 3 2 if defined config('mirror')
535 3 0 config('lookup_url') =~ m[^file://] ? :
3 0 defined config('lookup_url') ? :
3 2 if (exists $opts{'PATH'} and defined config('lookup_url') ? config('lookup_url') =~ m[^file://] ? 1 : 0 : 0) { }
0 2 elsif (defined config('lookup_url')) { }
554 0 5 if (exists $opts{'PATH'} and defined $opts{'PATH'} and $opts{'PATH'}) { }
5 0 elsif (defined $url and $url) { }
568 0 0 if $path eq $opts{'PATH'}
569 0 0 if ($path eq '') { }
593 0 0 if (not $path =~ m[/$]) { }
622 7 1 if $path eq $url_path
623 1 0 if ($path eq '') { }
647 0 0 if (not $path =~ m[/$]) { }
669 0 5 if ($@)
676 5 0 if (defined $filename)
682 0 5 unless defined $filename
698 0 5 if ($url =~ m[^ftp://]) { }
0 5 elsif ($url =~ m[^http://]) { }
5 0 elsif ($url =~ m[^file://]) { }
730 0 0 unless my $ftp = 'Net::FTP'->new($site)
737 0 0 unless $ftp->login('anonymous', '-anonymous@')
744 0 0 unless $ftp->binary
752 0 0 unless $ftp->cwd($directories)
761 0 0 unless $ftp->get($file)
782 0 0 if @_ % 2 == 0
785 0 0 if config('user_agent')
806 0 0 unless $response->{'success'}
816 0 0 unless length $response->{'content'}
834 0 0 unless open my $fh, '>', $filename
841 0 0 unless close $fh
862 0 5 unless file_name_is_absolute($url)
880 0 5 unless cp($untainted_url, $untainted_cwd)
912 180 1 if (not exists $opts{'MODE'} && defined $opts{'MODE'}) { }
913 0 180 unless open $fh, '<', $file_to_check
915 0 1 unless open $fh, $opts{'MODE'}, $file_to_check
922 0 181 if ($info->uid != 0 and $info->uid != $<)
935 2 179 if ($info->mode & 18)
979 0 716 if ($info->uid != 0 and $info->uid != $<)
992 179 537 if ($info->mode & 18)
994 1 178 unless $info->mode & 512 and S_ISDIR($info->mode)
1033 0 2 unless open my $output_fh, '>', \$output
1039 0 2 unless close $output_fh
1048 2 126 if (config('stay_root'))
1055 126 0 if (is_os_type('Unix') and $< == 0 || $> == 0) { }
1069 6 120 unless file(cwd())->basename =~ /^fetchware-$$/
1071 0 6 unless (exists $opts{'SkipTempDirCreation'} and defined $opts{'SkipTempDirCreation'} and $opts{'SkipTempDirCreation'})
1078 120 0 unless ((S_IMODE($st->mode) & 493) >= 493)
1079 0 120 unless chmod 0755, cwd()
1112 0 120 unless chown $uid, $gid, $new_temp_dir
1117 0 120 unless chmod 0700, $new_temp_dir
1125 0 120 unless chdir $new_temp_dir
1133 0 126 unless pipe READONLY, WRITEONLY
1158 0 126 unless (defined $_)
1166 126 0 if ($kidpid) { }
1167 0 126 unless close $writeonly
1177 0 126 unless close $readonly
1189 0 126 if ($? >> 8 != 0) { }
1221 0 0 unless close $readonly
1235 0 0 unless close $writeonly
1287 0 4 if $a_var =~ /$MAGIC_NUMBER/
1305 0 121 if ref $output ne 'SCALAR'
1313 0 232 unless defined $variable
1325 232 0 if ($variable =~ /(.*)/ms) { }
1391 2 387 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 } }
1398 5 384 if defined $opts{'TempDir'}
1402 5 384 defined $opts{'TempDir'} ? :
1405 381 8 unless defined $opts{'KeepTempDir'}
1411 0 387 if (config('stay_root') or ($< != 0 or $> != 0))
1415 0 0 unless chmod 0700, $temp_dir
1436 0 387 unless chdir $temp_dir
1444 0 387 unless open $fh_sem, '>', 'fetchware.sem'
1456 0 387 unless flock $fh_sem, 6
1481 373 0 if (defined $fh_sem)
1482 0 373 unless close $fh_sem
1497 373 0 if (defined original_cwd())
1499 0 373 unless chdir original_cwd()