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'})) . '"';
44 opt => '-NoProfile -ExecutionPolicy Unrestricted',
49 my $name = $shell->{name};
51 if @ARGV && !grep {$_ eq $name} @ARGV;
52 $shell->{shell} = which($name) || next;
53 $shell->{ext} ||= $name;
54 $shell->{perl} ||= qq{"$^X"};
59 plan skip_all => 'no supported shells found';
61 plan tests => 6*@shells;
63 my $sep = $Config{path_sep};
65 my $root = File::Spec->rootdir;
66 for my $shell (@shells) {
67 my $ll = File::Temp->newdir();
68 my $ll_dir = local::lib->normalize_path("$ll");
69 local $ENV{PERL_LOCAL_LIB_ROOT};
70 delete $ENV{PERL_LOCAL_LIB_ROOT};
71 local $ENV{PATH} = $root;
73 delete $ENV{PERL5LIB};
74 my $env = call_ll($shell, "$ll");
75 is $env->{PERL_LOCAL_LIB_ROOT}, $ll_dir,
76 "$shell->{name}: activate root";
77 is $env->{PATH}, local::lib->install_base_bin_path($ll_dir)."$sep$root",
78 "$shell->{name}: activate PATH";
79 is $env->{PERL5LIB}, local::lib->install_base_perl_path($ll_dir),
80 "$shell->{name}: activate PERL5LIB";
82 $ENV{$_} = $env->{$_} for qw(PATH PERL5LIB PERL_LOCAL_LIB_ROOT);
83 $env = call_ll($shell, '--deactivate', "$ll");
85 is $env->{PERL_LOCAL_LIB_ROOT}, undef,
86 "$shell->{name}: deactivate root";
87 is $env->{PATH}, $root,
88 "$shell->{name}: deactivate PATH";
89 is $env->{PERL5LIB}, undef,
90 "$shell->{name}: deactivate PERL5LIB";
94 my ($info, @options) = @_;
95 my $option = @options ? '='.join(',', @options) : '';
97 local $ENV{SHELL} = $info->{shell};
99 my $file = File::Temp->new(
100 TEMPLATE => 'll-test-script-XXXXX',
102 SUFFIX => '.'.$info->{ext},
105 $file->print(scalar `"$^X" $extra_lib -Mlocal::lib$option` . "\n");
106 $file->print(qq{$info->{perl} -Mt::lib::ENVDumper -e1\n});
109 my $opt = $info->{opt} ? "$info->{opt} " : '';
110 my $out = `"$info->{shell}" $opt"$file"`;
112 die "failed with code: $?";
115 eval $out or die "bad output: $@";