summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-06-20 10:50:50 +0200
committerNicholas Clark <nick@ccl4.org>2011-06-22 22:41:21 +0200
commit09e28dd9a3526a21d5884f16918aab03c647f01d (patch)
tree9555c07836cbedff62abc7fb0d6700cef568b449
parentdb6ebcbf60ec41f9f5ff67500e4e7433e400f46d (diff)
downloadperl-09e28dd9a3526a21d5884f16918aab03c647f01d.tar.gz
In TestInit, eliminate @new_inc, by assigning to @INC directly.
To decide whether to default, we can test $set_opt instead of whether @new_inc is empty, as all places that assign to @new_inc (now to @INC) also set $set_opt.
-rw-r--r--TestInit.pm26
1 files changed, 11 insertions, 15 deletions
diff --git a/TestInit.pm b/TestInit.pm
index 5aadefe892..e7609dae5d 100644
--- a/TestInit.pm
+++ b/TestInit.pm
@@ -30,14 +30,13 @@ $ENV{PERL_CORE} = $^X;
sub import {
my $self = shift;
my @up_2_t = ('../../lib', '../../t');
- my @new_inc;
my ($abs, $chdir, $setopt);
foreach (@_) {
if ($_ eq 'U2T') {
- @new_inc = @up_2_t;
+ @INC = @up_2_t;
$setopt = 1;
} elsif ($_ eq 'U1') {
- @new_inc = '../lib';
+ @INC = '../lib';
$setopt = 1;
} elsif ($_ eq 'NC') {
delete $ENV{PERL_CORE}
@@ -46,7 +45,7 @@ sub import {
} elsif ($_ eq 'T') {
$chdir = '..'
unless -f 't/TEST' && -f 'MANIFEST' && -d 'lib' && -d 'ext';
- @new_inc = 'lib';
+ @INC = 'lib';
$setopt = 1;
} else {
die "Unknown option '$_'";
@@ -56,7 +55,7 @@ sub import {
# Need to default. This behaviour is consistent with previous behaviour,
# as the equivalent of this code used to be run at the top level, hence
# would happen (unconditionally) before import() was called.
- unless (@new_inc) {
+ unless ($setopt) {
if (-f 't/TEST' && -f 'MANIFEST' && -d 'lib' && -d 'ext') {
# We're being run from the top level. Try to change directory, and
# set things up correctly. This is a 90% solution, but for
@@ -64,18 +63,18 @@ sub import {
if ($0 =~ s!^((?:ext|dist|cpan)[\\/][^\\/]+)[\//](.*\.t)$!$2!) {
# Looks like a test in ext.
$chdir = $1;
- @new_inc = @up_2_t;
+ @INC = @up_2_t;
$setopt = 1;
$^X =~ s!^\.([/\\])!..$1..$1!;
} else {
$chdir = 't';
- @new_inc = '../lib';
+ @INC = '../lib';
$setopt = $0 =~ m!^lib/!;
}
} else {
# (likely) we're being run by t/TEST or t/harness, and we're a test
# in t/
- @new_inc = '../lib';
+ @INC = '../lib';
}
}
@@ -84,17 +83,12 @@ sub import {
}
if ($abs) {
- @INC = @new_inc;
require File::Spec::Functions;
# Forcibly untaint this.
- @new_inc = map { $_ = File::Spec::Functions::rel2abs($_); /(.*)/; $1 }
- @new_inc;
+ @INC = map { $_ = File::Spec::Functions::rel2abs($_); /(.*)/; $1 } @INC;
$^X = File::Spec::Functions::rel2abs($^X);
}
- @INC = @new_inc;
- push @INC, '.' unless ${^TAINT};
-
if ($setopt) {
my $sep;
if ($^O eq 'VMS') {
@@ -105,13 +99,15 @@ sub import {
$sep = ':';
}
- my $lib = join $sep, @new_inc;
+ my $lib = join $sep, @INC;
if (exists $ENV{PERL5LIB}) {
$ENV{PERL5LIB} = $lib . substr $ENV{PERL5LIB}, 0, 0;
} else {
$ENV{PERL5LIB} = $lib;
}
}
+
+ push @INC, '.' unless ${^TAINT};
}
$0 =~ s/\.dp$//; # for the test.deparse make target