summaryrefslogtreecommitdiff
path: root/lib/File
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-01-18 13:33:44 +0000
committerNicholas Clark <nick@ccl4.org>2011-01-18 13:49:54 +0000
commit786dada42452aac14d9fe9c4066dbf18063ceb4a (patch)
tree9a98ebaead97cc807505876953cdbb01e1f134e6 /lib/File
parentd6dc8a6dc95226ddff7719cd1e0bd053c4e5725e (diff)
downloadperl-786dada42452aac14d9fe9c4066dbf18063ceb4a.tar.gz
Remove MacOS Classic code from File::Find's tests.
Diffstat (limited to 'lib/File')
-rw-r--r--lib/File/Find/t/find.t119
-rw-r--r--lib/File/Find/t/taint.t77
2 files changed, 49 insertions, 147 deletions
diff --git a/lib/File/Find/t/find.t b/lib/File/Find/t/find.t
index f386668d9d..1d0a0870b1 100644
--- a/lib/File/Find/t/find.t
+++ b/lib/File/Find/t/find.t
@@ -166,10 +166,8 @@ sub wanted_Name {
print "# \$File::Find::name => '$n'\n";
my $i = rindex($n,'/');
my $OK = exists($Expect_Name{$n});
- unless ($^O eq 'MacOS') {
- if ( $OK ) {
- $OK= exists($Expect_Name{substr($n,0,$i)}) if $i >= 0;
- }
+ if ( $OK ) {
+ $OK= exists($Expect_Name{substr($n,0,$i)}) if $i >= 0;
}
Check($OK);
delete $Expect_Name{$n};
@@ -180,10 +178,8 @@ sub wanted_File {
s#\.$## if ($^O eq 'VMS' && $_ ne '.');
my $i = rindex($_,'/');
my $OK = exists($Expect_File{ $_});
- unless ($^O eq 'MacOS') {
- if ( $OK ) {
- $OK= exists($Expect_File{ substr($_,0,$i)}) if $i >= 0;
- }
+ if ( $OK ) {
+ $OK= exists($Expect_File{ substr($_,0,$i)}) if $i >= 0;
}
Check($OK);
delete $Expect_File{ $_};
@@ -228,29 +224,18 @@ sub my_postprocess {
# 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 "."
-# as first argument, to create a directory path like "./fa/dir" on
-# 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.
+# as first argument, to create a directory path like "./fa/dir". If there's
+# no second argument, this function will return "./"
sub dir_path {
my $first_arg = shift @_;
if ($first_arg eq '.') {
- if ($^O eq 'MacOS') {
- return '' unless @_;
- # ignore first argument; return a relative path
- # with leading ":" and with trailing ":"
- return File::Spec->catdir(@_);
- } else { # other OS
- return './' unless @_;
- my $path = File::Spec->catdir(@_);
- # add leading "./"
- $path = "./$path";
- return $path;
- }
-
+ return './' unless @_;
+ my $path = File::Spec->catdir(@_);
+ # add leading "./"
+ $path = "./$path";
+ return $path;
} else { # $first_arg ne '.'
return $first_arg unless @_; # return plain filename
return File::Spec->catdir($first_arg, @_); # relative path
@@ -259,14 +244,9 @@ sub dir_path {
# Use topdir() to specify a directory path that you want to pass to
-# find/finddepth. Basically, topdir() does the same as dir_path() (see
-# above), except that there's no trailing ":" on Mac OS.
+# find/finddepth. Historically topdir() differed on Mac OS classic.
-sub topdir {
- my $path = dir_path(@_);
- $path =~ s/:$// if ($^O eq 'MacOS');
- return $path;
-}
+*topdir = \&dir_path;
# Use file_path() to specify a file path that's expected for $_
@@ -277,28 +257,18 @@ sub topdir {
# 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
# first argument, to create a file path like "./fa/file" on 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.
+# systems. If there's no second argument, this function will return the
+# string "./"
sub file_path {
my $first_arg = shift @_;
if ($first_arg eq '.') {
- if ($^O eq 'MacOS') {
- return '' unless @_;
- # ignore first argument; return a relative path
- # with leading ":", but without trailing ":"
- return File::Spec->catfile(@_);
- } else { # other OS
- return './' unless @_;
- my $path = File::Spec->catfile(@_);
- # add leading "./"
- $path = "./$path";
- return $path;
- }
-
+ return './' unless @_;
+ my $path = File::Spec->catfile(@_);
+ # add leading "./"
+ $path = "./$path";
+ return $path;
} else { # $first_arg ne '.'
return $first_arg unless @_; # return plain filename
return File::Spec->catfile($first_arg, @_); # relative path
@@ -312,15 +282,9 @@ sub file_path {
# 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
-# plain file/directory names.
-
-sub file_path_name {
- my $path = file_path(@_);
- $path = ":$path" if (($^O eq 'MacOS') && ($path !~ /:/));
- return $path;
-}
+# Historically file_path_name differed on Mac OS classic.
+
+*file_path_name = \&file_path;
@@ -331,11 +295,7 @@ MkDir( dir_path('fb'), 0770 );
touch( file_path('fb', 'fb_ord') );
MkDir( dir_path('fb', 'fba'), 0770 );
touch( file_path('fb', 'fba', 'fba_ord') );
-if ($^O eq 'MacOS') {
- CheckDie( symlink(':fb',':fa:fsl') ) if $symlink_exists;
-} else {
- CheckDie( symlink('../fb','fa/fsl') ) if $symlink_exists;
-}
+CheckDie( symlink('../fb','fa/fsl') ) if $symlink_exists;
touch( file_path('fa', 'fa_ord') );
MkDir( dir_path('fa', 'faa'), 0770 );
@@ -670,11 +630,7 @@ if ( $symlink_exists ) {
file_path('dangling_dir_sl') ) );
rmdir dir_path('dangling_dir');
touch(file_path('dangling_file'));
- if ($^O eq 'MacOS') {
- CheckDie( symlink('dangling_file', ':fa:dangling_file_sl') );
- } else {
- CheckDie( symlink('../dangling_file','fa/dangling_file_sl') );
- }
+ CheckDie( symlink('../dangling_file','fa/dangling_file_sl') );
unlink file_path('dangling_file');
{
@@ -714,11 +670,7 @@ if ( $symlink_exists ) {
print "# check recursion\n";
- if ($^O eq 'MacOS') {
- CheckDie( symlink(':fa:faa',':fa:faa:faa_sl') );
- } else {
- CheckDie( symlink('../faa','fa/faa/faa_sl') );
- }
+ CheckDie( symlink('../faa','fa/faa/faa_sl') );
undef $@;
eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
no_chdir => 1}, topdir('fa') ); };
@@ -727,11 +679,7 @@ if ( $symlink_exists ) {
print "# check follow_skip (file)\n";
- if ($^O eq 'MacOS') {
- CheckDie( symlink(':fa:fa_ord',':fa:fa_ord_sl') ); # symlink to a file
- } else {
- CheckDie( symlink('./fa_ord','fa/fa_ord_sl') ); # symlink to a file
- }
+ CheckDie( symlink('./fa_ord','fa/fa_ord_sl') ); # symlink to a file
undef $@;
eval {File::Find::finddepth( {wanted => \&simple_wanted,
@@ -777,11 +725,7 @@ if ( $symlink_exists ) {
print "# check follow_skip (directory)\n";
- if ($^O eq 'MacOS') {
- CheckDie( symlink(':fa:faa',':fa:faa_sl') ); # symlink to a directory
- } else {
- CheckDie( symlink('./faa','fa/faa_sl') ); # symlink to a directory
- }
+ CheckDie( symlink('./faa','fa/faa_sl') ); # symlink to a directory
undef $@;
eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
@@ -904,12 +848,7 @@ if ($symlink_exists) { # Issue 68260
MkDir (dir_path ('fa', 'fac'), 0770);
MkDir (dir_path ('fb', 'fbc'), 0770);
touch (file_path ('fa', 'fac', 'faca'));
- if ($^O eq 'MacOS') {
- CheckDie (symlink ('..::::..:fa:fac:faca', 'fb:fbc:fbca'));
- }
- else {
- CheckDie (symlink ('..////../fa/fac/faca', 'fb/fbc/fbca'));
- }
+ CheckDie (symlink ('..////../fa/fac/faca', 'fb/fbc/fbca'));
use warnings;
my $dangling_symlink;
diff --git a/lib/File/Find/t/taint.t b/lib/File/Find/t/taint.t
index 2059765838..d47b21a7c3 100644
--- a/lib/File/Find/t/taint.t
+++ b/lib/File/Find/t/taint.t
@@ -147,29 +147,18 @@ sub simple_wanted {
# 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 "."
-# as first argument, to create a directory path like "./fa/dir" on
-# 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.
+# as first argument, to create a directory path like "./fa/dir". If there's
+# no second argument this function will return the string "./"
sub dir_path {
my $first_arg = shift @_;
if ($first_arg eq '.') {
- if ($^O eq 'MacOS') {
- return '' unless @_;
- # ignore first argument; return a relative path
- # with leading ":" and with trailing ":"
- return File::Spec->catdir(@_);
- } else { # other OS
- return './' unless @_;
- my $path = File::Spec->catdir(@_);
- # add leading "./"
- $path = "./$path";
- return $path;
- }
-
+ return './' unless @_;
+ my $path = File::Spec->catdir(@_);
+ # add leading "./"
+ $path = "./$path";
+ return $path;
} else { # $first_arg ne '.'
return $first_arg unless @_; # return plain filename
my $fname = File::Spec->catdir($first_arg, @_); # relative path
@@ -180,14 +169,9 @@ sub dir_path {
# Use topdir() to specify a directory path that you want to pass to
-# find/finddepth. Basically, topdir() does the same as dir_path() (see
-# above), except that there's no trailing ":" on Mac OS.
+# find/finddepth. Historically topdir() differed on Mac OS classic.
-sub topdir {
- my $path = dir_path(@_);
- $path =~ s/:$// if ($^O eq 'MacOS');
- return $path;
-}
+*topdir = \&dir_path;
# Use file_path() to specify a file path that's expected for $_
@@ -197,29 +181,18 @@ sub topdir {
# 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
-# first argument, to create a file path like "./fa/file" on 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.
+# first argument, to create a file path like "./fa/file". If there's no
+# second argument, this function will return the string "./" otherwise.
sub file_path {
my $first_arg = shift @_;
if ($first_arg eq '.') {
- if ($^O eq 'MacOS') {
- return '' unless @_;
- # ignore first argument; return a relative path
- # with leading ":", but without trailing ":"
- return File::Spec->catfile(@_);
- } else { # other OS
- return './' unless @_;
- my $path = File::Spec->catfile(@_);
- # add leading "./"
- $path = "./$path";
- return $path;
- }
-
+ return './' unless @_;
+ my $path = File::Spec->catfile(@_);
+ # add leading "./"
+ $path = "./$path";
+ return $path;
} else { # $first_arg ne '.'
return $first_arg unless @_; # return plain filename
my $fname = File::Spec->catfile($first_arg, @_); # relative path
@@ -235,15 +208,9 @@ sub file_path {
# 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
-# plain file/directory names.
-
-sub file_path_name {
- my $path = file_path(@_);
- $path = ":$path" if (($^O eq 'MacOS') && ($path !~ /:/));
- return $path;
-}
+# Historically file_path_name differed on Mac OS classic.
+
+*file_path_name = \&file_path;
MkDir( dir_path('for_find'), 0770 );
@@ -259,11 +226,7 @@ MkDir( dir_path('fb', 'fba'), 0770 );
touch( file_path('fb', 'fba', 'fba_ord') );
SKIP: {
skip "Creating symlink", 1, unless $symlink_exists;
-if ($^O eq 'MacOS') {
- ok( symlink(':fb',':fa:fsl'), 'Created symbolic link' );
-} else {
- ok( symlink('../fb','fa/fsl'), 'Created symbolic link' );
-}
+ ok( symlink('../fb','fa/fsl'), 'Created symbolic link' );
}
touch( file_path('fa', 'fa_ord') );