1- {-# LANGUAGE OverloadedStrings #-}
2-
31module Test.Smoke.Executable where
42
53import Control.Monad.Trans.Except (ExceptT )
@@ -12,18 +10,9 @@ import System.IO.Temp (withSystemTempFile)
1210import System.Process (CreateProcess (.. ), proc )
1311import System.Process.Text (readCreateProcessWithExitCode )
1412import Test.Smoke.Paths
13+ import Test.Smoke.Shell
1514import Test.Smoke.Types
1615
17- defaultShell :: ExceptT PathError IO Shell
18- defaultShell = do
19- sh <- findExecutable $ parseFile " sh"
20- return $ Shell sh mempty
21-
22- shellFromCommandLine :: CommandLine -> ExceptT PathError IO Shell
23- shellFromCommandLine (CommandLine shellName shellArgs) = do
24- shellCommand <- findExecutable shellName
25- return $ Shell shellCommand shellArgs
26-
2716runExecutable ::
2817 Executable
2918 -> Args
@@ -38,7 +27,7 @@ runExecutable (ExecutableProgram executablePath executableArgs) args (StdIn stdI
3827 {cwd = toFilePath . unWorkingDirectory <$> workingDirectory})
3928 stdIn
4029runExecutable (ExecutableScript (Shell shellPath shellArgs) (Script script)) args stdIn workingDirectory =
41- withSystemTempFile " smoke.sh " $ \ scriptPath scriptHandle -> do
30+ withSystemTempFile defaultShellScriptName $ \ scriptPath scriptHandle -> do
4231 Text.IO. hPutStr scriptHandle script
4332 hClose scriptHandle
4433 let executableArgs = shellArgs <> Args (Vector. singleton scriptPath)
@@ -61,3 +50,8 @@ convertCommandToExecutable (Just shell) (CommandScript Nothing script) =
6150convertCommandToExecutable _ (CommandScript (Just commandLine) script) = do
6251 shell <- shellFromCommandLine commandLine
6352 return $ ExecutableScript shell script
53+
54+ shellFromCommandLine :: CommandLine -> ExceptT PathError IO Shell
55+ shellFromCommandLine (CommandLine shellName shellArgs) = do
56+ shellCommand <- findExecutable shellName
57+ return $ Shell shellCommand shellArgs
0 commit comments