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 is $env->{PATH}, local::lib->install_base_bin_path($ll_dir)."$sep$root",
84 "$shell->{name}: activate PATH";
85 is $env->{PERL5LIB}, local::lib->install_base_perl_path($ll_dir),
86 "$shell->{name}: activate PERL5LIB";
88 $ENV{$_} = $env->{$_} for qw(PATH PERL5LIB PERL_LOCAL_LIB_ROOT);
89 $env = call_ll($shell, '--deactivate', "$ll");
91 is $env->{PERL_LOCAL_LIB_ROOT}, undef,
92 "$shell->{name}: deactivate root";
93 is $env->{PATH}, $root,
94 "$shell->{name}: deactivate PATH";
95 is $env->{PERL5LIB}, undef,
96 "$shell->{name}: deactivate PERL5LIB";
100 my ($info, @options) = @_;
101 my $option = @options ? '='.join(',', @options) : '';
103 local $ENV{SHELL} = $info->{shell};
106 = `"$^X" $extra_lib -Mlocal::lib$option` . "\n"
107 . qq{$info->{perl} -Mt::lib::ENVDumper -e1\n};
109 my $file = File::Temp->new(
110 TEMPLATE => 'll-test-script-XXXXX',
112 SUFFIX => '.'.$info->{ext},
114 print { $file } $script;
117 my $opt = $info->{opt} ? "$info->{opt} " : '';
118 my $cmd = qq{"$info->{shell}" $opt"$file"};
121 diag "script:\n$script";
122 diag "running:\n$cmd";
123 die "failed with code: $?";
126 eval $out or die "bad output: $@";