This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Cannot portably split on $Config{path_sep} -- use quotemeta($Config{path_sep}).
[perl5.git] / dist / ExtUtils-Install / t / lib / MakeMaker / Test / Utils.pm
index 7e5d5fc..453a8ed 100644 (file)
@@ -135,21 +135,30 @@ sub which_perl {
   perl_lib;
 
 Sets up environment variables so perl can find its libraries.
+Run this before changing directories.
 
 =cut
 
 my $old5lib = $ENV{PERL5LIB};
 my $had5lib = exists $ENV{PERL5LIB};
 sub perl_lib {
-                               # perl-src/t/
-    my $lib =  $ENV{PERL_CORE} ? qq{../lib}
-                               # ExtUtils-MakeMaker/t/
-                               : qq{../blib/lib};
-    $lib = File::Spec->rel2abs($lib);
-    my @libs = ($lib);
-    push @libs, $ENV{PERL5LIB} if exists $ENV{PERL5LIB};
-    $ENV{PERL5LIB} = join($Config{path_sep}, @libs);
-    unshift @INC, $lib;
+    if ($ENV{PERL_CORE}) {
+       # Whilst we'll be running in perl-src/cpan/$distname/t/
+       # instead of blib, our code will be copied with all the other code to
+       # the top-level library.
+       # $ENV{PERL5LIB} will be set with this, but (by default) it's a relative
+       # path.
+       $ENV{PERL5LIB} = join $Config{path_sep}, map {
+           File::Spec->rel2abs($_) } split quotemeta($Config{path_sep}), $ENV{PERL5LIB};
+       @INC = map { File::Spec->rel2abs($_) } @INC;
+    } else {
+       my $lib = 'blib/lib';
+       $lib = File::Spec->rel2abs($lib);
+       my @libs = ($lib);
+       push @libs, $ENV{PERL5LIB} if exists $ENV{PERL5LIB};
+       $ENV{PERL5LIB} = join($Config{path_sep}, @libs);
+       unshift @INC, $lib;
+    }
 }
 
 END { 
@@ -340,7 +349,7 @@ sub setup_mm_test_root {
         open( MMTMP, '>mmtesttmp.com' ) || 
           die "Error creating command file; $!";
         print MMTMP <<'COMMAND';
-$ MM_TEST_ROOT = F$PARSE("SYS$DISK:[-]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
+$ MM_TEST_ROOT = F$PARSE("SYS$DISK:[--]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
 $ DEFINE/JOB/NOLOG/TRANSLATION=CONCEALED MM_TEST_ROOT 'MM_TEST_ROOT'
 COMMAND
         close MMTMP;