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'})) . '"';
36 skip => $^O eq 'cygwin',
39 name => 'powershell.exe',
40 opt => '-NoProfile -ExecutionPolicy Unrestricted -File',
43 skip => $^O eq 'cygwin',
46 my $name = $shell->{name};
47 $shell->{shell} = which($name);
48 $shell->{ext} ||= $name;
49 $shell->{perl} ||= qq{"$^X"};
52 if !grep {$_ eq $name} @ARGV;
53 if (!$shell->{shell}) {
54 warn "unable to find executable for $name";
58 elsif ($shell->{skip} || !$shell->{shell}) {
65 plan skip_all => 'no supported shells found';
67 plan tests => 6*@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 delete $ENV{PERL_LOCAL_LIB_ROOT};
77 local $ENV{PATH} = $root;
79 delete $ENV{PERL5LIB};
80 my $env = call_ll($shell, "$ll");
81 is $env->{PERL_LOCAL_LIB_ROOT}, $ll_dir,
82 "$shell->{name}: activate root";
83 my $bin_path = local::lib->install_base_bin_path($ll_dir);
84 like $env->{PATH}, qr/^\Q$bin_path$sep$root\E(?:$|\Q$sep\E)/,
85 "$shell->{name}: activate PATH";
86 is $env->{PERL5LIB}, local::lib->install_base_perl_path($ll_dir),
87 "$shell->{name}: activate PERL5LIB";
89 $ENV{$_} = $env->{$_} for qw(PATH PERL5LIB PERL_LOCAL_LIB_ROOT);
90 $env = call_ll($shell, '--deactivate', "$ll");
92 is $env->{PERL_LOCAL_LIB_ROOT}, undef,
93 "$shell->{name}: deactivate root";
94 like $env->{PATH}, qr/^\Q$root\E(?:$|\Q$sep\E)/,
95 "$shell->{name}: deactivate PATH";
96 is $env->{PERL5LIB}, undef,
97 "$shell->{name}: deactivate PERL5LIB";
101 my ($info, @options) = @_;
102 my $option = @options ? '='.join(',', @options) : '';
104 local $ENV{SHELL} = $info->{shell};
107 = `"$^X" $extra_lib -Mlocal::lib$option` . "\n"
108 . qq{$info->{perl} -Mt::lib::ENVDumper -e1\n};
110 my $file = File::Temp->new(
111 TEMPLATE => 'll-test-script-XXXXX',
113 SUFFIX => '.'.$info->{ext},
115 print { $file } $script;
118 my $opt = $info->{opt} ? "$info->{opt} " : '';
119 my $cmd = qq{"$info->{shell}" $opt"$file"};
122 diag "script:\n$script";
123 diag "running:\n$cmd";
124 die "failed with code: $?";
127 eval $out or die "bad output: $@";