FastGlob
view release on metacpan or search on metacpan
t/glob-comparison.t view on Meta::CPAN
# --- Build a controlled directory tree ---
# Use DIR => '.' to avoid 8.3 short path issues on Windows
my $root = tempdir( DIR => '.', CLEANUP => 1 );
$root = abs_path($root);
# Helper: create a file (and parent dirs if needed)
sub touch {
my ($relpath) = @_;
my $full = File::Spec->catfile( $root, split m{/}, $relpath );
my $dir = File::Basename::dirname($full);
make_path($dir) unless -d $dir;
open my $fh, '>', $full or die "Cannot create $full: $!";
close $fh;
}
# Helper: create a directory
sub mkd {
my ($relpath) = @_;
my $full = File::Spec->catdir( $root, split m{/}, $relpath );
make_path($full) unless -d $full;
}
# Build the tree:
# root/
# alpha.c
# beta.c
# gamma.h
# delta.txt
# README
t/recursive-glob.t view on Meta::CPAN
# With hidedotfiles=0, readdir returns . and .. as well as .hidden
my @rel = rel(@got);
ok( (grep { $_ eq 'alpha/.hidden' } @rel), '.hidden is visible when hidedotfiles=0' );
ok( (grep { $_ eq 'alpha/one.c' } @rel), 'one.c still present' );
ok( (grep { $_ eq 'alpha/two.c' } @rel), 'two.c still present' );
};
subtest 'dot-dirs hidden in wildcard dir component' => sub {
local $FastGlob::hidedotfiles = 1;
my @got = FastGlob::glob("$tmpdir/*/*.c");
my @dirs_seen = map { (split m{[/\\]}, $_)[0] } rel(@got);
ok( !grep { /^\./ } @dirs_seen,
'wildcard dir component hides .dotdir' );
};
subtest 'dot-dirs visible when hidedotfiles=0' => sub {
local $FastGlob::hidedotfiles = 0;
my @got = FastGlob::glob("$tmpdir/.dotdir/*.txt");
is_deeply( [rel(@got)], ['.dotdir/secret.txt'],
'explicit .dotdir/*.txt finds secret.txt when hidedotfiles=0' );
};
( run in 1.271 second using v1.01-cache-2.11-cpan-71847e10f99 )