-sub new_inc {
- if (${^TAINT}) {
- @INC = @_;
- } else {
- @INC = (@_, '.');
- }
-}
-
-sub set_opt {
- my $sep;
- if ($^O eq 'VMS') {
- $sep = '|';
- } elsif ($^O eq 'MSWin32') {
- $sep = ';';
- } else {
- $sep = ':';
- }
-
- my $lib = join $sep, @_;
- if (exists $ENV{PERL5LIB}) {
- $ENV{PERL5LIB} = $lib . substr $ENV{PERL5LIB}, 0, 0;
- } else {
- $ENV{PERL5LIB} = $lib;
- }
-}
-
-my @up_2_t = ('../../lib', '../../t');
-# This is incompatible with the import options.
-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 hand-running tests,
- # that's good enough
- if ($0 =~ s!^(ext[\\/][^\\/]+)[\//](.*\.t)$!$2!) {
- # Looks like a test in ext.
- chdir $1 or die "Can't chdir '$1': $!";
- new_inc(@up_2_t);
- set_opt(@up_2_t);
- $^X =~ s!^\./!../../!;
- $^X =~ s!^\.\\!..\\..\\!;
- } else {
- chdir 't' or die "Can't chdir 't': $!";
- new_inc('../lib');
- }
-} else {
- new_inc('../lib');
-}