Branch Coverage

blib/lib/Test/MockFile.pm
Criterion Covered Total %
branch 357 516 69.1


line true false branch
200 49 0 unless &Internals::SvREADONLY(\$_[0])
212 0 0 unless ref \$handle eq "GLOB"
279 0 45 unless defined $command and defined $_file_arg_post->{$command}
282 2 21 if $command eq "open" and ref $at_under_ref and scalar @$at_under_ref == 2
294 0 198 unless scalar @stack
295 0 198 unless defined $stack[0]
297 92 106 if $stack[0] eq "Test::MockFile"
298 60 46 if $stack[0] eq "Overload::FileCheck"
300 1 45 if $authorized_strict_mode_packages{$stack[0]}
366 0 13 unless defined $command_rule
369 0 13 unless defined $action
371 3 10 ref $command_rule eq 'ARRAY' ? :
372 2 11 ref $file_rule eq 'ARRAY' ? :
376 12 7 ref $c_rule eq 'Regexp' ? :
11 8 ref $f_rule eq 'Regexp' || !defined($f_rule) ? :
457 1 4 if ($extra)
502 46 51 $STRICT_MODE_STATUS & 2 ? :
508 51 46 unless is_strict_mode()
511 0 46 if grep {$command eq $_;} "readdir", "telldir", "rewinddir", "seekdir", "closedir"
514 1 45 unless scalar @stack
521 45 0 if ($file_arg >= 0)
522 0 45 scalar @$at_under_ref <= $file_arg ? :
526 1 44 if defined $filename and $filename =~ /^\*?(?:main::)?[<*&+>]*STD(?:OUT|IN|ERR)$/
532 1 43 if (UNIVERSAL::isa($filename, "GLOB"))
533 0 1 if $command ne "open" and $command ne "sysopen"
537 2 20 if $command eq "open" and $at_under_ref->[1] and $at_under_ref->[1] =~ /&/
548 18 24 if $pass
550 0 24 if $file_arg == -1
564 19 22 if (defined $rule->{'file_rule'})
565 9 10 unless defined $context->{'filename'} and $context->{'filename'} =~ /$rule->{'file_rule'}/
569 7 25 unless $context->{'command'} =~ /$rule->{'command_rule'}/
572 12 13 ref $rule->{'action'} ? :
574 18 7 if defined $answer
588 18 16 grep({$_ eq 'nostrict';} @args) ? :
590 0 34 if (defined $STRICT_MODE_STATUS and not $STRICT_MODE_STATUS & 4 and $STRICT_MODE_STATUS != $strict_mode)
602 22 0 unless defined $opt and $opt eq "plugin"
639 0 70 unless defined $file and length $file
640 0 70 if _is_path_mocked($file)
645 0 67 if (@stats > 1)
652 0 67 if not defined $contents and @stats
656 1 66 if (@stats)
657 0 1 unless ref $stats[0] eq "HASH"
663 1 66 defined $stats{'mode'} ? :
670 7 40 if (defined $contents and $files_being_mocked{$dirname})
701 0 1 unless (open $fh, "<", $file_on_disk)
735 0 12 unless defined $file and length $file
736 0 12 unless not defined $readlink or length $readlink
738 0 12 if _is_path_mocked($file)
744 4 8 if ($files_being_mocked{$dirname})
763 5 222 if ($path =~ m[ ( ^ | / ) \.{2} ( / | $ ) ]msx)
830 0 46 unless defined $dirname and length $dirname
831 0 46 if _is_path_mocked($dirname)
837 44 0 if $path ne "/"
840 5 39 if @_ > 2
884 4 3 $opts ? :
885 1 1 if (ref $opts eq "HASH" and $opts->{'mode'})
889 1 0 if (keys %{$opts;} == 0)
895 1 3 if ($mode) { }
948 118 0 if (scalar @_ == 1 and ref $_[0]) { }
0 0 elsif (scalar @_ % 2) { }
958 0 118 unless my $path = $opts{'path'}
960 0 118 unless ($path =~ m[^/])
991 0 366 unless exists $self->{$key}
1009 1 110 unless $type
1011 13 1 $type eq 'lstat' ? :
96 14 $type eq 'stat' ? :
1017 0 109 if (scalar @_ != 2)
1023 2 107 unless (defined $file_or_fh and length $file_or_fh)
1031 1 106 if defined $file and defined bless( {}, 'A::BROKEN::SYMLINK' ) and $file eq bless( {}, 'A::BROKEN::SYMLINK' )
1032 1 105 if defined $file and defined bless( {}, 'A::CIRCULAR::SYMLINK' ) and $file eq bless( {}, 'A::CIRCULAR::SYMLINK' )
1034 0 105 unless (defined $file and length $file)
1040 27 78 unless ($file_data)
1041 26 1 unless ref $file_or_fh
1046 24 53 unless $file_data->is_link or defined $file_data->contents
1054 0 128 unless my $absolute_path_to_file = _find_file_or_fh($file_path)
1056 0 128 $files_being_mocked{$absolute_path_to_file} ? :
1062 0 325 unless my $file = _find_file_or_fh($file_path)
1075 651 0 if $absolute_path_to_file ne "/"
1082 2 649 if $depth and not $mock_object
1085 615 34 unless $mock_object and $mock_object->is_link
1092 7 27 unless $follow_link
1098 2 25 if ($depth > 10)
1111 2 657 unless defined $fh and length $fh
1117 1087 57 unless $mock_fh
1118 13 44 unless "$mock_fh" eq "$fh"
1139 1 777 unless defined $path
1144 21 807 if $path =~ s[//+][/]gmsx
1145 8 820 if $path =~ s[/\.$][/]
1146 11 817 if $path =~ s[(?:[^/]+)/\.\.(/|$)][$1]
1147 35 793 if $path =~ s[/$][]
1150 1 776 if $path eq "/.."
1152 713 63 if $path =~ m[^/]msx
1157 0 63 if ($path =~ m[ ^(~ ([^/]+)? ) ]msx)
1166 0 0 if ($pwdata[0] eq $username)
1174 0 0 unless $pw_homedir
1183 0 63 if $path eq "."
1189 0 118 unless ref $self
1194 0 118 unless defined $path
1199 118 0 if (defined $files_being_mocked{$path})
1200 0 118 unless $self == $files_being_mocked{$path}
1222 0 270 unless $self
1224 0 270 if $self->is_link
1228 141 129 if ($self->is_dir)
1229 0 141 if $new_contents
1232 15 126 unless $self->{'has_content'}
1246 66 6 defined $_->{'contents'} || $_->is_link || $_->is_dir ? :
1255 129 0 if ($self->is_file)
1256 12 117 if (defined $new_contents)
1257 0 12 if ref $new_contents
1290 0 214 unless $self
1303 0 9 unless $self
1305 1 8 unless ($self->exists)
1310 2 6 if ($self->is_dir)
1311 0 2 if ($] < 5.019 and $^O eq 'darwin' || $^O =~ /bsd/i) { }
1320 1 5 if ($self->is_link) { }
1344 0 6 unless $self
1347 2 4 unless $self->is_file
1351 2 2 unless (defined $pre_size)
1406 0 27 unless $self->is_link
1408 0 27 if (scalar @_ == 2)
1409 0 0 if (defined $readlink and ref $readlink)
1428 78 952 defined $self->{'readlink'} && length $self->{'readlink'} && $self->{'mode'} & 40960 ? :
1440 204 142 ($self->{'mode'} & 61440) == 16384 ? :
1452 219 62 ($self->{'mode'} & 61440) == 32768 ? :
1465 2 111 if $self->is_link
1468 0 111 if ($] < "5.012")
1469 0 0 unless $self->exists
1485 3 0 defined $self->{'readlink'} ? :
3 138 if $self->is_link
1488 70 15 defined $self->{'contents'} ? :
85 53 if $self->is_file
1491 23 29 $self->{'has_content'} ? :
52 1 if $self->is_dir
1506 0 54 if (int $blocks > $blocks)
1556 5 0 if (scalar @_ == 2 and defined $time and $time =~ /^[0-9]+$/)
1575 5 0 if (@_ == 2 and defined $time and $time =~ /^[0-9]+$/)
1594 5 0 if (@_ == 2 and defined $time and $time =~ /^[0-9]+$/)
1628 0 0 unless $code_ref and ref $code_ref eq "CODE"
1725 2 57 if $] < "5.015"
1726 3 54 if $] < "5.021"
1727 2 52 if $] > "5.027"
1744 25 25 m[^(.+)/[^/]+$]msx ? :
1756 0 62 if (defined $_[0] and not ref $_[0])
1769 10 52 if ($arg_count == 2)
1772 7 3 if ($_[1] =~ /^ ( >> | [+]?> | [+]?< ) (.+) $/msx) { }
1 2 elsif ($_[1] =~ m[^[\./\\\w\d\-]+$]msx) { }
1 1 elsif ($_[1] =~ /^\|/msx) { }
1 0 elsif ($_[1] =~ /\|$/msx) { }
1797 0 62 if ($arg_count != 3)
1799 0 0 if _goto_is_available()
1800 0 0 if (@_ == 1) { }
0 0 elsif (@_ == 2) { }
0 0 elsif (@_ >= 3) { }
1812 0 62 if (ref $file and ref $file eq "SCALAR")
1813 0 0 if _goto_is_available()
1818 0 0 if not $abs_path and $mode ne "|-" and $mode ne "-|"
1819 0 62 if $abs_path eq bless( {}, 'A::BROKEN::SYMLINK' )
1829 30 28 if ($mode eq "|-" or $mode eq "-|" or not grep({$_ eq $mode;} ">", "<", ">>", "+<", "+>", "+>>") or not defined $mock_file)
1833 0 25 if _goto_is_available()
1834 0 25 if (@_ == 1) { }
3 22 elsif (@_ == 2) { }
22 0 elsif (@_ >= 3) { }
1848 3 25 if (not defined $mock_file->contents and grep {$mode eq $_;} "<", "+<")
1854 18 7 if grep {$_ eq $mode;} "+<", "+>", "+>>", "<"
1855 11 14 if grep {$_ eq $mode;} "+<", "+>", "+>>", ">", ">>"
1860 0 25 if ($likely_bareword) { }
1864 0 0 $_[1] ? :
1873 25 0 if ref $_[0]
1876 2 23 if ($mode eq '>>' or $mode eq '+>>') { }
7 16 elsif ($mode eq '>' or $mode eq '+>') { }
1903 4 3 unless ($mock_file)
1905 0 3 if _goto_is_available()
1912 0 3 if (($sysopen_mode & 132803) != $sysopen_mode)
1917 0 3 if (($sysopen_mode & 131072) == 131072 and $mock_file->is_link)
1923 0 1 if ($sysopen_mode & 128 and $sysopen_mode & 64 and defined $mock_file->{'contents'})
1929 1 2 if ($sysopen_mode & 64 and not defined $mock_file->{'contents'})
1934 1 2 if ($sysopen_mode & 512 and defined $mock_file->{'contents'})
1940 0 0 $rd_wr_mode == 2 ? :
1 0 $rd_wr_mode == 1 ? :
2 1 $rd_wr_mode == 0 ? :
1947 0 3 if (not defined $mock_file->{'contents'} and $rd_wr_mode == 0)
1959 3 0 if ref $_[0]
1962 1 2 if ($sysopen_mode & 512)
1967 0 3 if ($sysopen_mode & 1024)
1977 1 23 if defined $_[0] and not ref $_[9]
1982 0 24 if (scalar @_ != 2 or not defined $_[1])
1985 0 0 if _goto_is_available()
1990 10 14 unless ($mock_dir)
1992 0 7 if _goto_is_available()
1996 0 14 unless (defined $mock_dir->contents)
2001 1 13 unless ($mock_dir->{'mode'} & 16384)
2006 12 1 if (not defined $_[0]) { }
1 0 elsif (ref $_[0]) { }
2026 28 0 if defined $_[0] and not ref $_[9]
2030 6 22 unless ($mocked_dir)
2032 0 6 if _goto_is_available()
2037 0 22 unless ($obj)
2041 0 22 unless (defined $obj->{'files_in_readdir'})
2045 0 22 unless (defined $obj->{'tell'})
2050 4 18 if $obj->{'tell'} > $#{$$obj{"files_in_readdir"};}
2052 14 4 if (wantarray)
2067 4 0 if defined $_[0] and not ref $_[9]
2072 0 4 unless ($mocked_dir and $mocked_dir->{'obj'})
2074 0 0 if _goto_is_available()
2080 0 4 unless (defined $obj->{'files_in_readdir'})
2084 0 4 unless (defined $obj->{'tell'})
2094 1 0 if defined $_[0] and not ref $_[9]
2099 0 1 unless ($mocked_dir and $mocked_dir->{'obj'})
2101 0 0 if _goto_is_available()
2107 0 1 unless (defined $obj->{'files_in_readdir'})
2111 0 1 unless (defined $obj->{'tell'})
2122 1 0 if defined $_[0] and not ref $_[9]
2127 0 1 unless ($mocked_dir and $mocked_dir->{'obj'})
2129 0 0 if _goto_is_available()
2135 0 1 unless (defined $obj->{'files_in_readdir'})
2139 0 1 unless (defined $obj->{'tell'})
2149 14 0 if defined $_[0] and not ref $_[9]
2154 1 13 unless ($mocked_dir and $mocked_dir->{'obj'})
2156 0 1 if _goto_is_available()
2173 7 4 if (not $mock) { }
2189 2 5 unless (defined $file)
2191 0 2 if ($^O eq 'freebsd') { }
2201 1 4 unless ($mock_object)
2203 0 1 if _goto_is_available()
2207 2 2 unless ($mock_object->is_link)
2220 1 27 unless (defined $file)
2230 2 25 unless ($mock)
2232 0 2 if _goto_is_available()
2237 6 19 if ($mock->exists)
2259 1 13 unless (defined $file)
2266 4 9 unless ($mock)
2268 0 4 if _goto_is_available()
2274 8 1 if ($mock->exists)
2275 1 7 if ($mock->is_file)
2280 1 6 if ($mock->is_link)
2286 1 6 unless ($mock->exists)
2291 1 5 if (_files_in_dir($file))
2303 0 13 if $^O eq "MSWin32"
2308 0 13 unless @files
2312 13 1 ref $_ ? :
2316 1 12 if (@mocked_files and @mocked_files != @files)
2325 2 10 if $uid == -1
2326 2 10 if $gid == -1
2341 0 12 unless ($mock)
2343 0 0 if _goto_is_available()
2348 1 11 unless ($mock->exists)
2351 1 0 unless $set_error
2359 0 11 unless ($is_root)
2360 0 0 if ($> != $uid or not $is_in_group)
2361 0 0 unless $set_error
2382 0 6 unless @files
2388 1 5 unless $mode =~ /^[0-9]+/msx
2395 8 1 ref $_ ? :
2399 1 5 if (@mocked_files and @mocked_files != @files)
2411 0 7 unless ($mock)
2413 0 0 if _goto_is_available()
2419 0 7 unless ($mock->exists)
2438 0 37 !$^V || $^V lt 5.18.0 ? :