summaryrefslogtreecommitdiff
path: root/lib/File
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2013-07-03 10:41:29 +0200
committerNicholas Clark <nick@ccl4.org>2013-07-05 20:26:25 +0200
commit05bc6e4e004001cec69ec60de3c2ccd2c84c6484 (patch)
tree7d9edd6a15cef84c987ce045021a42f942d77e49 /lib/File
parente06f856f7209ef9f86a20d46b2c039a3c7852762 (diff)
downloadperl-05bc6e4e004001cec69ec60de3c2ccd2c84c6484.tar.gz
Improve the BEGIN-time setup code for File::Find's tests.
In find.t merge the two BEGIN blocks and eliminate the redundant C<use File::Spec;> In both, don't attempt to change directory to t/ (which will be unhelpful once File::Find is moved to ext/) Only make paths in @INC absolute if $ENV{PERL_CORE} is set (which will ease making File::Find dual-life, if we want to this.)
Diffstat (limited to 'lib/File')
-rw-r--r--lib/File/Find/t/find.t35
-rw-r--r--lib/File/Find/t/taint.t9
2 files changed, 19 insertions, 25 deletions
diff --git a/lib/File/Find/t/find.t b/lib/File/Find/t/find.t
index 96a1000511..53ba648ad7 100644
--- a/lib/File/Find/t/find.t
+++ b/lib/File/Find/t/find.t
@@ -11,11 +11,21 @@ my ($warn_msg, @files, $file);
BEGIN {
require File::Spec;
- chdir 't' if -d 't';
- # May be doing dynamic loading while @INC is all relative
- unshift @INC => File::Spec->rel2abs('../lib');
-
- $SIG{'__WARN__'} = sub { $warn_msg = $_[0]; warn "# $_[0]"; }
+ if ($ENV{PERL_CORE}) {
+ # May be doing dynamic loading while @INC is all relative
+ @INC = map { $_ = File::Spec->rel2abs($_); /(.*)/; $1 } @INC;
+ }
+ $SIG{'__WARN__'} = sub { $warn_msg = $_[0]; warn "# $_[0]"; };
+
+ if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'VMS') {
+ # 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
+ require File::Spec::Unix;
+ @File::Spec::ISA = 'File::Spec::Unix';
+ }
+ require File::Find;
+ import File::Find;
}
my $test_count = 98;
@@ -45,21 +55,6 @@ my $orig_dir = cwd();
# };
# }
-
-BEGIN {
- use File::Spec;
- if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'VMS')
- {
- # 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
- require File::Spec::Unix;
- @File::Spec::ISA = 'File::Spec::Unix';
- }
- require File::Find;
- import File::Find;
-}
-
cleanup();
$::count_commonsense = 0;
diff --git a/lib/File/Find/t/taint.t b/lib/File/Find/t/taint.t
index 954c6780d9..d6fb256993 100644
--- a/lib/File/Find/t/taint.t
+++ b/lib/File/Find/t/taint.t
@@ -16,11 +16,10 @@ my ($cwd, $cwd_untainted);
BEGIN {
require File::Spec;
- chdir 't' if -d 't';
- # May be doing dynamic loading while @INC is all relative
- my $lib = File::Spec->rel2abs('../lib');
- $lib = $1 if $lib =~ m/(.*)/;
- unshift @INC => $lib;
+ if ($ENV{PERL_CORE}) {
+ # May be doing dynamic loading while @INC is all relative
+ @INC = map { $_ = File::Spec->rel2abs($_); /(.*)/; $1 } @INC;
+ }
}
use Config;