5 use File::Basename qw(dirname);
10 my @paths = File::Spec->path;
11 my @ext = $^O eq 'MSWin32' ? (split /\Q$Config{path_sep}/, $ENV{PATHEXT}) : ('');
14 for my $dir (@paths) {
15 my $file = File::Spec->catfile($dir||'.', $shell);
17 my $full = $file . $ext;
25 my $extra_lib = '-I"' . dirname(dirname($INC{'local/lib.pm'})) . '"';
41 skip => $^O eq 'cygwin',
45 opt => '-NoProfile -ExecutionPolicy Unrestricted -File',
48 skip => $^O eq 'cygwin',
51 my $name = $shell->{name};
52 $shell->{shell} = which($name);
53 $shell->{ext} ||= $name;
54 $shell->{perl} ||= qq{"$^X"};
57 if !grep {$_ eq $name} @ARGV;
58 if (!$shell->{shell}) {
59 warn "unable to find executable for $name";
63 elsif ($shell->{skip} || !$shell->{shell}) {
70 plan skip_all => 'no supported shells found';
72 plan tests => 6*@shells;
74 my $sep = $Config{path_sep};
76 my $root = File::Spec->rootdir;
77 for my $shell (@shells) {
78 my $ll = File::Temp->newdir();
79 my $ll_dir = local::lib->normalize_path("$ll");
80 local $ENV{PERL_LOCAL_LIB_ROOT};
81 delete $ENV{PERL_LOCAL_LIB_ROOT};
82 local $ENV{PATH} = $root;
84 delete $ENV{PERL5LIB};
85 my $env = call_ll($shell, "$ll");
86 is $env->{PERL_LOCAL_LIB_ROOT}, $ll_dir,
87 "$shell->{name}: activate root";
88 is $env->{PATH}, local::lib->install_base_bin_path($ll_dir)."$sep$root",
89 "$shell->{name}: activate PATH";
90 is $env->{PERL5LIB}, local::lib->install_base_perl_path($ll_dir),
91 "$shell->{name}: activate PERL5LIB";
93 $ENV{$_} = $env->{$_} for qw(PATH PERL5LIB PERL_LOCAL_LIB_ROOT);
94 $env = call_ll($shell, '--deactivate', "$ll");
96 is $env->{PERL_LOCAL_LIB_ROOT}, undef,
97 "$shell->{name}: deactivate root";
98 is $env->{PATH}, $root,
99 "$shell->{name}: deactivate PATH";
100 is $env->{PERL5LIB}, undef,
101 "$shell->{name}: deactivate PERL5LIB";
105 my ($info, @options) = @_;
106 my $option = @options ? '='.join(',', @options) : '';
108 local $ENV{SHELL} = $info->{shell};
110 my $file = File::Temp->new(
111 TEMPLATE => 'll-test-script-XXXXX',
113 SUFFIX => '.'.$info->{ext},
116 $file->print(scalar `"$^X" $extra_lib -Mlocal::lib$option` . "\n");
117 $file->print(qq{$info->{perl} -Mt::lib::ENVDumper -e1\n});
120 my $opt = $info->{opt} ? "$info->{opt} " : '';
121 my $out = `"$info->{shell}" $opt"$file"`;
123 die "failed with code: $?";
126 eval $out or die "bad output: $@";