Branch Coverage

blib/lib/Test/MockFile.pm
Criterion Covered Total %
branch 352 514 68.4


line true false branch
200 49 0 unless &Internals::SvREADONLY(\$_[0])
212 0 0 unless ref \$handle eq "GLOB"
279 0 32 unless defined $command and defined $_file_arg_post->{$command}
282 2 18 if $command eq "open" and ref $at_under_ref and scalar @$at_under_ref == 2
294 0 119 unless scalar @stack
295 0 119 unless defined $stack[0]
297 66 53 if $stack[0] eq "Test::MockFile"
298 20 33 if $stack[0] eq "Overload::FileCheck"
300 1 32 if $authorized_strict_mode_packages{$stack[0]}
366 0 11 unless defined $command_rule
369 0 11 unless defined $action
371 1 10 ref $command_rule eq 'ARRAY' ? :
372 2 9 ref $file_rule eq 'ARRAY' ? :
376 12 3 ref $c_rule eq 'Regexp' ? :
9 6 ref $f_rule eq 'Regexp' || !defined($f_rule) ? :
498 33 51 $STRICT_MODE_STATUS & 2 ? :
504 51 33 unless is_strict_mode()
507 0 33 if grep {$command eq $_;} "readdir", "telldir", "rewinddir", "seekdir", "closedir"
510 1 32 unless scalar @stack
517 32 0 if ($file_arg >= 0)
518 0 32 scalar @$at_under_ref <= $file_arg ? :
522 1 31 if defined $filename and $filename =~ /^\*?(?:main::)?[<*&+>]*STD(?:OUT|IN|ERR)$/
528 0 31 if (UNIVERSAL::isa($filename, "GLOB"))
529 0 0 if $command ne "open" and $command ne "sysopen"
533 0 19 if $command eq "open" and $at_under_ref->[1] and $at_under_ref->[1] =~ /&/
544 15 16 if $pass
546 0 16 if $file_arg == -1
560 14 8 if (defined $rule->{'file_rule'})
561 5 9 unless defined $context->{'filename'} and $context->{'filename'} =~ /$rule->{'file_rule'}/
565 1 16 unless $context->{'command'} =~ /$rule->{'command_rule'}/
568 4 12 ref $rule->{'action'} ? :
570 15 1 if defined $answer
584 18 13 grep({$_ eq 'nostrict';} @args) ? :
586 0 31 if (defined $STRICT_MODE_STATUS and not $STRICT_MODE_STATUS & 4 and $STRICT_MODE_STATUS != $strict_mode)
598 21 0 unless defined $opt and $opt eq "plugin"
635 0 70 unless defined $file and length $file
636 0 70 if _is_path_mocked($file)
641 0 67 if (@stats > 1)
648 0 67 if not defined $contents and @stats
652 1 66 if (@stats)
653 0 1 unless ref $stats[0] eq "HASH"
659 1 66 defined $stats{'mode'} ? :
666 7 40 if (defined $contents and $files_being_mocked{$dirname})
697 0 1 unless (open $fh, "<", $file_on_disk)
731 0 12 unless defined $file and length $file
732 0 12 unless not defined $readlink or length $readlink
734 0 12 if _is_path_mocked($file)
740 4 8 if ($files_being_mocked{$dirname})
759 5 222 if ($path =~ m[ ( ^ | / ) \.{2} ( / | $ ) ]msx)
826 0 46 unless defined $dirname and length $dirname
827 0 46 if _is_path_mocked($dirname)
833 44 0 if $path ne "/"
836 5 39 if @_ > 2
880 4 3 $opts ? :
881 1 1 if (ref $opts eq "HASH" and $opts->{'mode'})
885 1 0 if (keys %{$opts;} == 0)
891 1 3 if ($mode) { }
944 118 0 if (scalar @_ == 1 and ref $_[0]) { }
0 0 elsif (scalar @_ % 2) { }
954 0 118 unless my $path = $opts{'path'}
956 0 118 unless ($path =~ m[^/])
987 0 366 unless exists $self->{$key}
1005 1 100 unless $type
1007 6 1 $type eq 'lstat' ? :
93 7 $type eq 'stat' ? :
1013 0 99 if (scalar @_ != 2)
1019 2 97 unless (defined $file_or_fh and length $file_or_fh)
1027 1 96 if defined $file and defined bless( {}, 'A::BROKEN::SYMLINK' ) and $file eq bless( {}, 'A::BROKEN::SYMLINK' )
1028 1 95 if defined $file and defined bless( {}, 'A::CIRCULAR::SYMLINK' ) and $file eq bless( {}, 'A::CIRCULAR::SYMLINK' )
1030 0 95 unless (defined $file and length $file)
1036 17 78 unless ($file_data)
1037 16 1 unless ref $file_or_fh
1042 24 53 unless $file_data->is_link or defined $file_data->contents
1050 0 128 unless my $absolute_path_to_file = _find_file_or_fh($file_path)
1052 0 128 $files_being_mocked{$absolute_path_to_file} ? :
1058 0 312 unless my $file = _find_file_or_fh($file_path)
1071 625 0 if $absolute_path_to_file ne "/"
1078 2 623 if $depth and not $mock_object
1081 589 34 unless $mock_object and $mock_object->is_link
1088 7 27 unless $follow_link
1094 2 25 if ($depth > 10)
1107 2 631 unless defined $fh and length $fh
1113 1087 57 unless $mock_fh
1114 13 44 unless "$mock_fh" eq "$fh"
1135 1 740 unless defined $path
1140 21 770 if $path =~ s[//+][/]gmsx
1141 8 783 if $path =~ s[/\.$][/]
1142 11 780 if $path =~ s[(?:[^/]+)/\.\.(/|$)][$1]
1143 35 756 if $path =~ s[/$][]
1146 1 739 if $path eq "/.."
1148 680 59 if $path =~ m[^/]msx
1153 0 59 if ($path =~ m[ ^(~ ([^/]+)? ) ]msx)
1162 0 0 if ($pwdata[0] eq $username)
1170 0 0 unless $pw_homedir
1179 0 59 if $path eq "."
1185 0 118 unless ref $self
1190 0 118 unless defined $path
1195 118 0 if (defined $files_being_mocked{$path})
1196 0 118 unless $self == $files_being_mocked{$path}
1218 0 270 unless $self
1220 0 270 if $self->is_link
1224 141 129 if ($self->is_dir)
1225 0 141 if $new_contents
1228 15 126 unless $self->{'has_content'}
1242 66 6 defined $_->{'contents'} || $_->is_link || $_->is_dir ? :
1251 129 0 if ($self->is_file)
1252 12 117 if (defined $new_contents)
1253 0 12 if ref $new_contents
1286 0 214 unless $self
1299 0 9 unless $self
1301 1 8 unless ($self->exists)
1306 2 6 if ($self->is_dir)
1307 0 2 if ($] < 5.019 and $^O eq 'darwin' || $^O =~ /bsd/i) { }
1316 1 5 if ($self->is_link) { }
1340 0 6 unless $self
1343 2 4 unless $self->is_file
1347 2 2 unless (defined $pre_size)
1402 0 27 unless $self->is_link
1404 0 27 if (scalar @_ == 2)
1405 0 0 if (defined $readlink and ref $readlink)
1424 78 952 defined $self->{'readlink'} && length $self->{'readlink'} && $self->{'mode'} & 40960 ? :
1436 204 142 ($self->{'mode'} & 61440) == 16384 ? :
1448 219 62 ($self->{'mode'} & 61440) == 32768 ? :
1461 2 111 if $self->is_link
1464 0 111 if ($] < "5.012")
1465 0 0 unless $self->exists
1481 3 0 defined $self->{'readlink'} ? :
3 138 if $self->is_link
1484 70 15 defined $self->{'contents'} ? :
85 53 if $self->is_file
1487 23 29 $self->{'has_content'} ? :
52 1 if $self->is_dir
1502 0 54 if (int $blocks > $blocks)
1552 5 0 if (scalar @_ == 2 and defined $time and $time =~ /^[0-9]+$/)
1571 5 0 if (@_ == 2 and defined $time and $time =~ /^[0-9]+$/)
1590 5 0 if (@_ == 2 and defined $time and $time =~ /^[0-9]+$/)
1624 0 0 unless $code_ref and ref $code_ref eq "CODE"
1721 2 55 if $] < "5.015"
1722 3 52 if $] < "5.021"
1723 2 50 if $] > "5.027"
1740 25 25 m[^(.+)/[^/]+$]msx ? :
1752 0 59 if (defined $_[0] and not ref $_[0])
1765 10 49 if ($arg_count == 2)
1768 7 3 if ($_[1] =~ /^ ( >> | [+]?> | [+]?< ) (.+) $/msx) { }
1 2 elsif ($_[1] =~ m[^[\./\\\w\d\-]+$]msx) { }
1 1 elsif ($_[1] =~ /^\|/msx) { }
1 0 elsif ($_[1] =~ /\|$/msx) { }
1793 0 59 if ($arg_count != 3)
1795 0 0 if _goto_is_available()
1796 0 0 if (@_ == 1) { }
0 0 elsif (@_ == 2) { }
0 0 elsif (@_ >= 3) { }
1808 0 59 if (ref $file and ref $file eq "SCALAR")
1809 0 0 if _goto_is_available()
1814 0 0 if not $abs_path and $mode ne "|-" and $mode ne "-|"
1815 0 59 if $abs_path eq bless( {}, 'A::BROKEN::SYMLINK' )
1825 27 28 if ($mode eq "|-" or $mode eq "-|" or not grep({$_ eq $mode;} ">", "<", ">>", "+<", "+>", "+>>") or not defined $mock_file)
1829 0 23 if _goto_is_available()
1830 0 23 if (@_ == 1) { }
3 20 elsif (@_ == 2) { }
20 0 elsif (@_ >= 3) { }
1844 3 25 if (not defined $mock_file->contents and grep {$mode eq $_;} "<", "+<")
1850 18 7 if grep {$_ eq $mode;} "+<", "+>", "+>>", "<"
1851 11 14 if grep {$_ eq $mode;} "+<", "+>", "+>>", ">", ">>"
1856 0 25 if ($likely_bareword) { }
1860 0 0 $_[1] ? :
1869 25 0 if ref $_[0]
1872 2 23 if ($mode eq '>>' or $mode eq '+>>') { }
7 16 elsif ($mode eq '>' or $mode eq '+>') { }
1899 4 3 unless ($mock_file)
1901 0 3 if _goto_is_available()
1908 0 3 if (($sysopen_mode & 132803) != $sysopen_mode)
1913 0 3 if (($sysopen_mode & 131072) == 131072 and $mock_file->is_link)
1919 0 1 if ($sysopen_mode & 128 and $sysopen_mode & 64 and defined $mock_file->{'contents'})
1925 1 2 if ($sysopen_mode & 64 and not defined $mock_file->{'contents'})
1930 1 2 if ($sysopen_mode & 512 and defined $mock_file->{'contents'})
1936 0 0 $rd_wr_mode == 2 ? :
1 0 $rd_wr_mode == 1 ? :
2 1 $rd_wr_mode == 0 ? :
1943 0 3 if (not defined $mock_file->{'contents'} and $rd_wr_mode == 0)
1955 3 0 if ref $_[0]
1958 1 2 if ($sysopen_mode & 512)
1963 0 3 if ($sysopen_mode & 1024)
1973 1 23 if defined $_[0] and not ref $_[9]
1978 0 24 if (scalar @_ != 2 or not defined $_[1])
1981 0 0 if _goto_is_available()
1986 10 14 unless ($mock_dir)
1988 0 7 if _goto_is_available()
1992 0 14 unless (defined $mock_dir->contents)
1997 1 13 unless ($mock_dir->{'mode'} & 16384)
2002 12 1 if (not defined $_[0]) { }
1 0 elsif (ref $_[0]) { }
2022 28 0 if defined $_[0] and not ref $_[9]
2026 6 22 unless ($mocked_dir)
2028 0 6 if _goto_is_available()
2033 0 22 unless ($obj)
2037 0 22 unless (defined $obj->{'files_in_readdir'})
2041 0 22 unless (defined $obj->{'tell'})
2046 4 18 if $obj->{'tell'} > $#{$$obj{"files_in_readdir"};}
2048 14 4 if (wantarray)
2063 4 0 if defined $_[0] and not ref $_[9]
2068 0 4 unless ($mocked_dir and $mocked_dir->{'obj'})
2070 0 0 if _goto_is_available()
2076 0 4 unless (defined $obj->{'files_in_readdir'})
2080 0 4 unless (defined $obj->{'tell'})
2090 1 0 if defined $_[0] and not ref $_[9]
2095 0 1 unless ($mocked_dir and $mocked_dir->{'obj'})
2097 0 0 if _goto_is_available()
2103 0 1 unless (defined $obj->{'files_in_readdir'})
2107 0 1 unless (defined $obj->{'tell'})
2118 1 0 if defined $_[0] and not ref $_[9]
2123 0 1 unless ($mocked_dir and $mocked_dir->{'obj'})
2125 0 0 if _goto_is_available()
2131 0 1 unless (defined $obj->{'files_in_readdir'})
2135 0 1 unless (defined $obj->{'tell'})
2145 14 0 if defined $_[0] and not ref $_[9]
2150 1 13 unless ($mocked_dir and $mocked_dir->{'obj'})
2152 0 1 if _goto_is_available()
2169 7 4 if (not $mock) { }
2185 2 5 unless (defined $file)
2187 0 2 if ($^O eq 'freebsd') { }
2197 1 4 unless ($mock_object)
2199 0 1 if _goto_is_available()
2203 2 2 unless ($mock_object->is_link)
2216 1 27 unless (defined $file)
2226 2 25 unless ($mock)
2228 0 2 if _goto_is_available()
2233 6 19 if ($mock->exists)
2255 1 13 unless (defined $file)
2262 4 9 unless ($mock)
2264 0 4 if _goto_is_available()
2270 8 1 if ($mock->exists)
2271 1 7 if ($mock->is_file)
2276 1 6 if ($mock->is_link)
2282 1 6 unless ($mock->exists)
2287 1 5 if (_files_in_dir($file))
2299 0 13 if $^O eq "MSWin32"
2304 0 13 unless @files
2308 13 1 ref $_ ? :
2312 1 12 if (@mocked_files and @mocked_files != @files)
2321 2 10 if $uid == -1
2322 2 10 if $gid == -1
2337 0 12 unless ($mock)
2339 0 0 if _goto_is_available()
2344 1 11 unless ($mock->exists)
2347 1 0 unless $set_error
2355 0 11 unless ($is_root)
2356 0 0 if ($> != $uid or not $is_in_group)
2357 0 0 unless $set_error
2378 0 6 unless @files
2384 1 5 unless $mode =~ /^[0-9]+/msx
2391 8 1 ref $_ ? :
2395 1 5 if (@mocked_files and @mocked_files != @files)
2407 0 7 unless ($mock)
2409 0 0 if _goto_is_available()
2415 0 7 unless ($mock->exists)
2434 0 34 !$^V || $^V lt 5.18.0 ? :