9 my @paths = File::Spec->path;
10 my @ext = $^O eq 'MSWin32' ? (split /\Q$Config{path_sep}/, $ENV{PATHEXT}) : ('');
13 for my $dir (@paths) {
14 my $file = File::Spec->catfile($dir||'.', $shell);
16 my $full = $file . $ext;
25 my @paths = `$^X -le"print for \@INC"`;
29 grep { !exists $paths{$_} } @INC;
32 my $extra_lib = join ' ', map { qq{"-I$_"} } @extra_lib;
51 opt => '-NoProfile -ExecutionPolicy Unrestricted',
56 my $name = $shell->{name};
58 if @ARGV && !grep {$_ eq $name} @ARGV;
59 $shell->{shell} = which($name) || next;
60 $shell->{ext} ||= $name;
61 $shell->{perl} ||= qq{"$^X"};
66 plan skip_all => 'no supported shells found';
68 plan tests => 4*@shells;
70 my $sep = $Config{path_sep};
72 my $root = File::Spec->rootdir;
73 for my $shell (@shells) {
74 my $ll = File::Temp->newdir();
75 my $ll_dir = local::lib->normalize_path("$ll");
76 local $ENV{PERL_LOCAL_LIB_ROOT};
77 local $ENV{PATH} = $root;
78 local $ENV{PERL5LIB} = $ENV{PERL5LIB};
79 delete $ENV{PERL_LOCAL_LIB_ROOT};
80 my $env = call_ll($shell, "$ll");
81 is $env->{PERL_LOCAL_LIB_ROOT}, $ll_dir, "$shell->{name}: activate root";
82 is $env->{PATH}, local::lib->install_base_bin_path($ll_dir)."$sep$root", "$shell->{name}: activate PATH";
84 $ENV{$_} = $env->{$_} for qw(PATH PERL5LIB PERL_LOCAL_LIB_ROOT);
85 $env = call_ll($shell, '--deactivate', "$ll");
87 is $env->{PERL_LOCAL_LIB_ROOT}, undef, "$shell->{name}: deactivate root";
88 is $env->{PATH}, $root, "$shell->{name}: deactivate PATH";
92 my ($info, @options) = @_;
93 my $option = @options ? '='.join(',', @options) : '';
95 local $ENV{SHELL} = $info->{shell};
97 my $file = File::Temp->new(
98 TEMPLATE => 'll-test-script-XXXXX',
100 SUFFIX => '.'.$info->{ext},
103 $file->print(scalar `"$^X" $extra_lib -Mlocal::lib$option` . "\n");
104 $file->print(qq{$info->{perl} -Mt::lib::ENVDumper -e1\n});
107 my $opt = $info->{opt} ? "$info->{opt} " : '';
108 my $out = `"$info->{shell}" $opt"$file"`;
110 die "failed with code: $?";
113 eval $out or die "bad output: $@";