5 use File::Basename qw(dirname);
10 my @paths = File::Spec->path;
15 map { File::Spec->catfile( $_, $shell) }
20 my $extra_lib = '-I"' . dirname(dirname($INC{'local/lib.pm'})) . '"';
39 skip => $^O eq 'cygwin',
42 name => 'powershell.exe',
43 opt => '-NoProfile -ExecutionPolicy Unrestricted -File',
46 skip => $^O eq 'cygwin',
49 my $name = $shell->{name};
50 $shell->{shell} = which($name);
51 $shell->{ext} ||= $name;
52 $shell->{perl} ||= qq{"$^X"};
55 if !grep {$_ eq $name} @ARGV;
56 if (!$shell->{shell}) {
57 warn "unable to find executable for $name";
61 elsif ($shell->{skip} || !$shell->{shell}) {
68 plan skip_all => 'no supported shells found';
70 plan tests => 6*@shells;
72 my $sep = $Config{path_sep};
74 my $root = File::Spec->rootdir;
75 for my $shell (@shells) {
76 my $ll = File::Temp->newdir();
77 my $ll_dir = local::lib->normalize_path("$ll");
78 local $ENV{PERL_LOCAL_LIB_ROOT};
79 delete $ENV{PERL_LOCAL_LIB_ROOT};
80 local $ENV{PATH} = $root;
82 delete $ENV{PERL5LIB};
83 my $bin_path = local::lib->install_base_bin_path($ll_dir);
85 my $env = call_ll($shell, "$ll");
86 is $env->{PERL_LOCAL_LIB_ROOT}, $ll_dir,
87 "$shell->{name}: activate root";
88 like $env->{PATH}, qr/^\Q$bin_path$sep$root\E(?:$|\Q$sep\E)/,
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 like $env->{PATH}, qr/^\Q$root\E(?:$|\Q$sep\E)/,
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};
111 = `"$^X" $extra_lib -Mlocal::lib$option` . "\n"
112 . qq{$info->{perl} -Mt::lib::ENVDumper -e1\n};
114 my $file = File::Temp->new(
115 TEMPLATE => 'll-test-script-XXXXX',
117 SUFFIX => '.'.$info->{ext},
119 print { $file } $script;
122 my $opt = $info->{opt} ? "$info->{opt} " : '';
123 my $cmd = qq{"$info->{shell}" $opt"$file"};
126 diag "script:\n$script";
127 diag "running:\n$cmd";
128 die "failed with code: $?";
131 eval $out or die "bad output: $@";