be more strict about what shells to test
[p5sagit/local-lib.git] / t / shell.t
index 047d49c..4088216 100644 (file)
--- a/t/shell.t
+++ b/t/shell.t
@@ -8,18 +8,13 @@ use Config;
 use local::lib ();
 
 my @paths = File::Spec->path;
-my @ext = $^O eq 'MSWin32'  ? (split /\Q$Config{path_sep}/, $ENV{PATHEXT}) : ('');
 sub which {
   my $shell = shift;
-  for my $dir (@paths) {
-    my $file = File::Spec->catfile($dir||'.', $shell);
-    for my $ext (@ext) {
-      my $full = $file . $ext;
-      return $full
-        if -x $full;
-    }
-  }
-  return;
+  my ($full) =
+    grep { -x }
+    map { File::Spec->catfile( $_, $shell) }
+    File::Spec->path;
+  return $full;
 }
 
 my $extra_lib = '-I"' . dirname(dirname($INC{'local/lib.pm'})) . '"';
@@ -34,14 +29,14 @@ for my $shell (
     opt => '-f',
   },
   {
-    name => 'cmd',
+    name => 'cmd.exe',
     opt => '/Q /D /C',
     ext => 'bat',
     perl => qq{@"$^X"},
     skip => $^O eq 'cygwin',
   },
   {
-    name => 'powershell',
+    name => 'powershell.exe',
     opt => '-NoProfile -ExecutionPolicy Unrestricted -File',
     ext => 'ps1',
     perl => qq{& '$^X'},
@@ -107,19 +102,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;