#!./perl
my $warn_msg;
BEGIN {
chdir 't' if -d 't';
}
else { print "1..85\n"; }
# Uncomment this to see where File::Find is chdir'ing to. Helpful for
# debugging its little jaunts around the filesystem.
# BEGIN {
# use Cwd;
# *CORE::GLOBAL::chdir = sub ($) {
# my($file, $line) = (caller)[1,2];
#
# printf "# cwd: %s\n", cwd();
# print "# chdir: @_ from $file at $line\n";
# my($return) = CORE::chdir($_[0]);
# printf "# newcwd: %s\n", cwd();
#
# return $return;
# };
# }
BEGIN {
{
# This is a hack - at present File::Find does not produce native names on
# Win32 or VMS, so force File::Spec to use Unix names.
# must be set *before* importing File::Find
}
}
$::count_commonsense = 0;
print "ok 1\n";
} else {
}
$::count_commonsense = 0;
print "ok 2\n";
} else {
}
my $case = 2;
my $FastFileTests_OK = 0;
sub cleanup {
}
}
}
}
END {
}
$case++;
}
$case++;
}
sub touch {
}
}
sub wanted_File_Dir {
s#\.$## if ($^O eq 'VMS' && $_ ne '.');
delete $Expect_File{ $_}
} else {
delete $Expect_File{$_}
}
}
sub wanted_File_Dir_prune {
}
sub wanted_Name {
$n =~ s#\.$## if ($^O eq 'VMS' && $n ne '.');
print "# \$File::Find::name => '$n'\n";
}
}
delete $Expect_Name{$n};
}
sub wanted_File {
print "# \$_ => '$_'\n";
s#\.$## if ($^O eq 'VMS' && $_ ne '.');
}
}
delete $Expect_File{ $_};
}
sub simple_wanted {
print "# \$_ => '$_'\n";
}
sub noop_wanted {}
sub my_preprocess {
@files = @_;
print "# --preprocess--\n";
}
print "# --end preprocess--\n";
delete $Expect_Dir{ $File::Find::dir }
}
return @files;
}
sub my_postprocess {
delete $Expect_Dir{ $File::Find::dir};
}
# Use dir_path() to specify a directory path that's expected for
# $File::Find::dir (%Expect_Dir). Also use it in file operations like
# chdir, rmdir etc.
#
# dir_path() concatenates directory names to form a *relative*
# directory path, independent from the platform it's run on, although
# there are limitations. Don't try to create an absolute path,
# because that may fail on operating systems that have the concept of
# volume names (e.g. Mac OS). As a special case, you can pass it a "."
# operating systems other than Mac OS (actually, Mac OS will ignore
# the ".", if it's the first argument). If there's no second argument,
# this function will return the empty string on Mac OS and the string
# "./" otherwise.
sub dir_path {
my $first_arg = shift @_;
# ignore first argument; return a relative path
# with leading ":" and with trailing ":"
} else { # other OS
# add leading "./"
return $path;
}
} else { # $first_arg ne '.'
return $first_arg unless @_; # return plain filename
}
}
# Use topdir() to specify a directory path that you want to pass to
# above), except that there's no trailing ":" on Mac OS.
sub topdir {
return $path;
}
# Use file_path() to specify a file path that's expected for $_
# (%Expect_File). Also suitable for file operations like unlink etc.
#
# file_path() concatenates directory names (if any) and a filename to
# form a *relative* file path (the last argument is assumed to be a
# file). It's independent from the platform it's run on, although
# there are limitations. As a special case, you can pass it a "." as
# systems other than Mac OS (actually, Mac OS will ignore the ".", if
# it's the first argument). If there's no second argument, this
# function will return the empty string on Mac OS and the string "./"
# otherwise.
sub file_path {
my $first_arg = shift @_;
# ignore first argument; return a relative path
# with leading ":", but without trailing ":"
} else { # other OS
# add leading "./"
return $path;
}
} else { # $first_arg ne '.'
return $first_arg unless @_; # return plain filename
}
}
# Use file_path_name() to specify a file path that's expected for
# $File::Find::Name (%Expect_Name). Note: When the no_chdir => 1
# option is in effect, $_ is the same as $File::Find::Name. In that
# case, also use this function to specify a file path that's expected
# for $_.
#
# Basically, file_path_name() does the same as file_path() (see
# above), except that there's always a leading ":" on Mac OS, even for
sub file_path_name {
return $path;
}
} else {
}
print "# check re-entrancy\n";
# no_chdir is in effect, hence we use file_path_name to specify the expected paths for %Expect_File
%Expect_Name = (File::Spec->curdir => 1,
# no_chdir is in effect, hence we use file_path_name to specify the
# expected paths for %Expect_File
%Expect_File = (File::Spec->curdir => 1,
print "# check preprocess\n";
%Expect_Dir = (
);
File::Find::find( {wanted => \&noop_wanted,
preprocess => \&my_preprocess}, File::Spec->curdir );
print "# check postprocess\n";
%Expect_Dir = (
);
File::Find::find( {wanted => \&noop_wanted,
postprocess => \&my_postprocess}, File::Spec->curdir );
{
print "# checking argument localization\n";
### this checks the fix of perlbug [19977] ###
}
# see thread starting
{
print "# checking that &_ and %_ are still accessible and that\n",
"# tie magic on \$_ is not triggered\n";
my $true_count;
my $sub = 0;
sub _ {
++$sub;
}
my $tie_called = 0;
sub STORE {
++$tie_called;
}
untie $_;
}
print "# --- symbolic link tests --- \n";
# Verify that File::Find::find will call wanted even if the topdir of
# is a symlink to a directory, and it shouldn't follow the link
# unless follow is set, which it isn't in this case
File::Find::find( {wanted => \&wanted_File_Dir_prune,
# no_chdir is in effect, hence we use file_path_name to specify
# the expected paths for %Expect_File
File::Find::find( {wanted => \&wanted_File_Dir, follow_fast => 1,
File::Find::finddepth( {wanted => \&wanted_Name,
# no_chdir is in effect, hence we use file_path_name to specify
# the expected paths for %Expect_File
File::Find::finddepth( {wanted => \&wanted_File, follow_fast => 1,
print "# check dangling symbolic links\n";
} else {
}
{
# these tests should also emit a warning
use warnings;
%Expect_File = (File::Spec->curdir => 1,
},
}
print "# check recursion\n";
} else {
}
undef $@;
print "# check follow_skip (file)\n";
} else {
}
undef $@;
eval {File::Find::finddepth( {wanted => \&simple_wanted,
follow => 1,
follow_skip => 0, no_chdir => 1},
# no_chdir is in effect, hence we use file_path_name to specify
# the expected paths for %Expect_File
# We may encounter the symlink first
follow_skip => 1, no_chdir => 1},
# Only the file and its symlink have value 2;<
print "# check follow_skip (directory)\n";
} else {
}
undef $@;
follow_skip => 0, no_chdir => 1},
undef $@;
follow_skip => 1, no_chdir => 1},
# no_chdir is in effect, hence we use file_path_name to specify
# the expected paths for %Expect_File
# We may actually encounter the symlink first.
# If we encountered the symlink first, then the entries corresponding to
# the real name remain, if the real name first then the symlink
my @names = sort keys %Expect_File;
# In sorted order the directory name comes first
# Normalise both to the original name
}