X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fshell.t;h=a6b599bc81f2816ae941d6bed906df3e7ec11755;hb=94ff402610700889a8d31a011a4d4dcd4c8223eb;hp=0d5ce6118d5d95668243cd603bdbfcb5b1d24bc7;hpb=57987bd1c4619b87c58818c26689a5a7e956093d;p=p5sagit%2Flocal-lib.git diff --git a/t/shell.t b/t/shell.t index 0d5ce61..a6b599b 100644 --- a/t/shell.t +++ b/t/shell.t @@ -35,23 +35,34 @@ for my $shell ( }, { name => 'cmd', - opt => '/D /C', + opt => '/Q /D /C', ext => 'bat', perl => qq{@"$^X"}, + skip => $^O eq 'cygwin', }, { name => 'powershell', - opt => '-NoProfile -ExecutionPolicy Unrestricted', + opt => '-NoProfile -ExecutionPolicy Unrestricted -File', ext => 'ps1', perl => qq{& '$^X'}, + skip => $^O eq 'cygwin', }, ) { my $name = $shell->{name}; - next - if @ARGV && !grep {$_ eq $name} @ARGV; - $shell->{shell} = which($name) || next; + $shell->{shell} = which($name); $shell->{ext} ||= $name; $shell->{perl} ||= qq{"$^X"}; + if (@ARGV) { + next + if !grep {$_ eq $name} @ARGV; + if (!$shell->{shell}) { + warn "unable to find executable for $name"; + next; + } + } + elsif ($shell->{skip} || !$shell->{shell}) { + next; + } push @shells, $shell; } @@ -96,19 +107,24 @@ sub call_ll { local $ENV{SHELL} = $info->{shell}; + my $script + = `"$^X" $extra_lib -Mlocal::lib$option` . "\n" + . qq{$info->{perl} -Mt::lib::ENVDumper -e1\n}; + my $file = File::Temp->new( TEMPLATE => 'll-test-script-XXXXX', TMPDIR => 1, SUFFIX => '.'.$info->{ext}, ); - - $file->print(scalar `"$^X" $extra_lib -Mlocal::lib$option` . "\n"); - $file->print(qq{$info->{perl} -Mt::lib::ENVDumper -e1\n}); - $file->close; + print { $file } $script; + close $file; my $opt = $info->{opt} ? "$info->{opt} " : ''; - my $out = `"$info->{shell}" $opt"$file"`; + my $cmd = qq{"$info->{shell}" $opt"$file"}; + my $out = `$cmd`; if ($?) { + diag "script:\n$script"; + diag "running:\n$cmd"; die "failed with code: $?"; } my $VAR1;