This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/re/fold_grind.t: slight speed up
[perl5.git] / TestInit.pm
index c626965..a113554 100644 (file)
@@ -18,7 +18,7 @@
 
 package TestInit;
 
-$VERSION = 1.02;
+$VERSION = 1.03;
 
 # Let tests know they're running in the perl core.  Useful for modules
 # which live dual lives on CPAN.
@@ -59,7 +59,7 @@ 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!) {
+    if ($0 =~ s!^((?:ext|dist|cpan)[\\/][^\\/]+)[\//](.*\.t)$!$2!) {
        # Looks like a test in ext.
        chdir $1 or die "Can't chdir '$1': $!";
        new_inc(@up_2_t);
@@ -69,6 +69,7 @@ if (-f 't/TEST' && -f 'MANIFEST' && -d 'lib' && -d 'ext') {
     } else {
        chdir 't' or die "Can't chdir 't': $!";
        new_inc('../lib');
+       set_opt('../lib') if $0 =~ m!^lib/!;
     }
 } else {
     new_inc('../lib');
@@ -80,6 +81,8 @@ sub import {
     foreach (@_) {
        if ($_ eq 'U2T') {
            @new_inc = @up_2_t;
+       } elsif ($_ eq 'U1') {
+           @new_inc = '../lib';
        } elsif ($_ eq 'NC') {
            delete $ENV{PERL_CORE}
        } elsif ($_ eq 'A') {