Test-Virtual-Filesystem
view release on metacpan or search on metacpan
lib/Test/Virtual/Filesystem.pm view on Meta::CPAN
features, but in those methods the subfeature names are flattened.
=cut
sub Features : ATTR(CODE) { ## no critic(MixedCase)
my ($class, $symbol, $code_ref, $attr, $features) = @_;
if ($symbol eq 'ANON') {
warn 'cannot test anonymous subs - you probably loaded ' . $class . ' too late.' .
' (after the CHECK block was run)';
} else {
my @features = ref $features ? @{$features} : split m/\s*,\s*/xms, $features;
# Wrap the sub in a feature test
no warnings 'redefine'; ## no critic(TestingAndDebugging::ProhibitNoWarnings)
*{$symbol} = sub {
my $blocking_feature = _blocking_feature(__PACKAGE__, $_[0], @features);
return $blocking_feature if $blocking_feature;
return $code_ref->(@_);
};
}
return;
}
sub _blocking_feature {
my ($pkg, $self, @features) = @_;
for my $feature (@features) {
return $feature . ' (no OS support)' if $feature_disabled{$feature};
my $opts = $self->{fs_opts};
for my $part (split m{/}xms, $feature) {
return $feature if !ref $opts;
return $feature if !$opts->{$part};
$opts = $opts->{$part};
}
}
return;
}
=item stat_dir(), introduced in v0.01
lib/Test/Virtual/Filesystem.pm view on Meta::CPAN
return is("$num_errno ($str_errno)", "$expected_errnos->[0] ($expected_str)", $msg);
} else {
return is("$num_errno ($str_errno)", "[@{$expected_errnos}] ($expected_str)", $msg);
}
}
sub _file {
my ($self, $path) = @_;
$path =~ s{\A /}{}xms or croak 'test paths must be absolute';
# Change path to proper OS format
return File::Spec->catfile($self->{tempdir}, split m{/}xms, $path);
}
sub _write_file {
my ($self, $f, @content) = @_;
open my $fh, '>', $f or die $OS_ERROR;
binmode $fh;
for my $content (@content) {
print {$fh} $content or die $OS_ERROR;
}
close $fh or die $OS_ERROR;
( run in 0.704 second using v1.01-cache-2.11-cpan-71847e10f99 )