diff options
| -rw-r--r-- | src/Script/Shell.hs | 7 | ||||
| -rw-r--r-- | test/asset/shell/working-directory.et | 4 | ||||
| -rw-r--r-- | test/script/shell.et | 14 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/Script/Shell.hs b/src/Script/Shell.hs index 91bdcb0..fbb92af 100644 --- a/src/Script/Shell.hs +++ b/src/Script/Shell.hs @@ -154,6 +154,13 @@ executeCommand sei@ShellExecInfo {..} st pstdin pstdout pstderr scmd@ShellComman executeCommandProcess :: ShellExecInfo -> ShellState -> Handle -> Handle -> Handle -> [ Text ] -> Text -> TestRun ( TestRun ProcessStatus, ShellState ) executeCommandProcess ShellExecInfo {..} st@ShellState {..} pstdin pstdout pstderr args = \case + "pwd" + | [] <- args -> do + liftIO $ hPutStrLn pstdout shellWorkingDirectory + return ( return (Exited ExitSuccess), st ) + | otherwise -> do + liftIO $ hPutStrLn pstderr $ "pwd: too many arguments" + return ( return (Exited (ExitFailure (-1))), st ) cmd -> liftIO $ do (_, _, _, phandle) <- createProcess_ "shell" (proc (T.unpack cmd) (map T.unpack args)) diff --git a/test/asset/shell/working-directory.et b/test/asset/shell/working-directory.et new file mode 100644 index 0000000..e1732ee --- /dev/null +++ b/test/asset/shell/working-directory.et @@ -0,0 +1,4 @@ +test Test: + node n + shell on n as sh: + pwd diff --git a/test/script/shell.et b/test/script/shell.et index 00826c8..2c09aa4 100644 --- a/test/script/shell.et +++ b/test/script/shell.et @@ -98,3 +98,17 @@ test ShellPipe: with p: expect /run-done/ + + +test ShellWorkingDirectory: + spawn as p + with p: + send "load ${scripts.path}/working-directory.et" + local: + expect /(load-.*)/ capture done + guard (done == "load-done") + flush + + send "run *" + + expect from p /child-stdout sh (\/.*)/ capture orig_pwd |