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;
50 opt => '-ExecutionPolicy Unrestricted',
55 my $name = $shell->{name};
57 if @ARGV && !grep {$_ eq $name} @ARGV;
58 $shell->{shell} = which($name) || next;
59 $shell->{ext} ||= $name;
60 $shell->{perl} ||= qq{"$^X"};
65 plan skip_all => 'no supported shells found';
67 plan tests => 4*@shells;
69 my $sep = $Config{path_sep};
71 my $root = File::Spec->rootdir;
72 for my $shell (@shells) {
73 my $ll = File::Temp->newdir();
74 my $ll_dir = local::lib->normalize_path("$ll");
75 local $ENV{PERL_LOCAL_LIB_ROOT};
76 local $ENV{PATH} = $root;
77 local $ENV{PERL5LIB} = $ENV{PERL5LIB};
78 delete $ENV{PERL_LOCAL_LIB_ROOT};
79 my $env = call_ll($shell, "$ll");
80 is $env->{PERL_LOCAL_LIB_ROOT}, $ll_dir, "$shell->{name}: activate root";
81 is $env->{PATH}, local::lib->install_base_bin_path($ll_dir)."$sep$root", "$shell->{name}: activate PATH";
83 $ENV{$_} = $env->{$_} for qw(PATH PERL5LIB PERL_LOCAL_LIB_ROOT);
84 $env = call_ll($shell, '--deactivate', "$ll");
86 is $env->{PERL_LOCAL_LIB_ROOT}, undef, "$shell->{name}: deactivate root";
87 is $env->{PATH}, $root, "$shell->{name}: deactivate PATH";
91 my ($info, @options) = @_;
92 my $option = @options ? '='.join(',', @options) : '';
94 local $ENV{SHELL} = $info->{shell};
96 my $file = File::Temp->new('ll-test-script-XXXXX',
98 SUFFIX => '.'.$info->{ext},
101 $file->print(scalar `"$^X" $extra_lib -Mlocal::lib$option` . "\n");
102 $file->print(qq{$info->{perl} -Mt::lib::ENVDumper -e1\n});
105 my $opt = $info->{opt} ? "$info->{opt} " : '';
106 my $out = `"$info->{shell}" $opt"$file"`;
108 die "failed with code: $?";
111 eval $out or die "bad output: $@";