diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-08-26 19:06:55 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-08-26 19:06:55 +0100 |
commit | 5ed59b83dc91aee603f670bf9534221f120fa934 (patch) | |
tree | f2a6315d74588798d8287c97e31517ea428d3fb6 /t | |
parent | e447daf9e3940e576dd6b0451030ca27007189d9 (diff) | |
download | perl-5ed59b83dc91aee603f670bf9534221f120fa934.tar.gz |
t/TEST shouldn't use -M options until we've tested that they work.
Also, t/TEST doesn't need to set $ENV{PERL_CORE} as t/TestInit.pm does this.
t/TestInit.pm should also add '.' to @INC (except under tainting) to correctly
emulate the include path of this perl binary once it and its libraries are
installed.
Fix t/run/cloexec.t to not rely on -I../lib being passed as a command-line
arguments. t/run/*.t *test* that command line arguments work, so they can't
be called with command line arguments that are mandatory for them to work.
Diffstat (limited to 't')
-rwxr-xr-x | t/TEST | 16 | ||||
-rw-r--r-- | t/TestInit.pm | 12 | ||||
-rw-r--r-- | t/run/cloexec.t | 4 |
3 files changed, 23 insertions, 9 deletions
@@ -14,9 +14,6 @@ $| = 1; #BEGIN { require '../lib/strict.pm'; "strict"->import() }; #BEGIN { require '../lib/warnings.pm'; "warnings"->import() }; -# Let tests know they're running in the perl core. Useful for modules -# which live dual lives on CPAN. -$ENV{PERL_CORE} = 1; delete $ENV{PERL5LIB}; # remove empty elements due to insertion of empty symbols via "''p1'" syntax @@ -132,6 +129,12 @@ sub _scan_test { return { file => $file_opts, switch => $switch }; } +# directories with special sets of test switches +my %dir_to_switch = + (base => '', + comp => '', + run => '', + ); sub _run_test { my($test, $type) = @_; @@ -140,9 +143,14 @@ sub _run_test { my $perl = './perl'; my $lib = '../lib'; + $test =~ /^([^\/]+)/; + + my $testswitch = $dir_to_switch{$1}; + if (!defined $testswitch) { + $testswitch = '-I. -MTestInit'; # -T will remove . from @INC + } my $utf8 = $::with_utf8 ? '-I$lib -Mutf8' : ''; - my $testswitch = '-I. -MTestInit'; # -T will remove . from @INC my $results; if ($type eq 'deparse') { diff --git a/t/TestInit.pm b/t/TestInit.pm index 15af57a108..637cfec105 100644 --- a/t/TestInit.pm +++ b/t/TestInit.pm @@ -18,15 +18,21 @@ package TestInit; -$VERSION = 1.01; +$VERSION = 1.02; -chdir 't' if -d 't'; -@INC = '../lib'; +chdir 't' if -f 't/TestInit.pm'; +# Let tests know they're running in the perl core. Useful for modules +# which live dual lives on CPAN. # Don't interfere with the taintedness of %ENV, this could perturbate tests. # This feels like a better solution than the original, from # http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-07/msg00154.html $ENV{PERL_CORE} = $^X; +if (${^TAINT}) { + @INC = '../lib'; +} else { + @INC = ('../lib', '.'); +} $0 =~ s/\.dp$//; # for the test.deparse make target 1; diff --git a/t/run/cloexec.t b/t/run/cloexec.t index dfbae3ad9c..769609af7c 100644 --- a/t/run/cloexec.t +++ b/t/run/cloexec.t @@ -35,8 +35,8 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; - use Config; - if (!$Config{'d_fcntl'}) { + require Config; + if (!$Config::Config{'d_fcntl'}) { print("1..0 # Skip: fcntl() is not available\n"); exit(0); } |