-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathTestInit.pm.testpack
48 lines (42 loc) · 1.06 KB
/
TestInit.pm.testpack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package TestInit;
sub import {
my $chdir;
my $setopt;
foreach (@_) {
if($_ eq 'A') {
require File::Spec::Functions;
# Forcibly untaint this.
@INC = map { $_ = File::Spec::Functions::rel2abs($_); /(.*)/; $1 } @INC;
$^X = File::Spec::Functions::rel2abs($^X);
} elsif($_ eq 'T') {
$chdir = '..';
unshift(@INC, './lib');
} elsif($_ eq 'NC') {
delete $ENV{PERL_CORE}
}
}
# See TestInit.pm in the perl tree for explaination.
unless($setopt) {
if (-f 't/TEST' && -f 'MANIFEST' && -d 'lib' && -d 'ext') {
if ($0 =~ s!^((?:ext|dist|cpan)[\\/][^\\/]+)[\\/](.*\.t)$!$2!) {
$chdir = $1;
$setopt = 1;
$^X =~ s!^\.([\\/])!..$1..$1!;
} else {
$chdir = 't';
unshift(@INC, '../lib');
$setopt = $0 =~ m!^lib/!;
}
} else {
unshift(@INC, '../lib');
}
}
chdir($chdir) or die "Can't chdir($chdir): $!"
if defined($chdir) && !(-f 't/TEST' && -f 'MANIFEST' && -d 'lib' && -d 'ext');
if($setopt) {
my $lib = join $sep, @INC;
$lib .= substr($ENV{PERL5LIB}, 0, 0) if exists $ENV{PERL5LIB};
$ENV{PERL5LIB} = $lib;
}
}
1;