summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Script/Shell.hs12
-rw-r--r--test/asset/shell/logic.et14
-rw-r--r--test/script/shell.et26
3 files changed, 51 insertions, 1 deletions
diff --git a/src/Script/Shell.hs b/src/Script/Shell.hs
index f070de5..dbecee3 100644
--- a/src/Script/Shell.hs
+++ b/src/Script/Shell.hs
@@ -158,7 +158,17 @@ 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
+executeCommandProcess sei@ShellExecInfo {..} st@ShellState {..} pstdin pstdout pstderr args = \case
+ "!"
+ | (cmd : args') <- args -> do
+ ( exit, st' ) <- executeCommandProcess sei st pstdin pstdout pstderr args' cmd
+ let exit' = exit >>= \case Exited ExitSuccess -> return (Exited (ExitFailure (-1)))
+ _ -> return (Exited ExitSuccess)
+ return ( exit', st' )
+
+ | [] <- args -> do
+ return ( return (Exited (ExitFailure (-1))), st )
+
"cd"
| [] <- args -> liftIO $ do
hPutStrLn pstdout (nodeDir seiNode)
diff --git a/test/asset/shell/logic.et b/test/asset/shell/logic.et
new file mode 100644
index 0000000..d1d4b32
--- /dev/null
+++ b/test/asset/shell/logic.et
@@ -0,0 +1,14 @@
+test NegateFalse:
+ node n
+ shell on n as sh:
+ ! false
+
+test NegateTrue:
+ node n
+ shell on n as sh:
+ ! true
+
+test NegateNothing:
+ node n
+ shell on n as sh:
+ !
diff --git a/test/script/shell.et b/test/script/shell.et
index e58dfea..086d3d3 100644
--- a/test/script/shell.et
+++ b/test/script/shell.et
@@ -154,3 +154,29 @@ test ShellExitOnError:
expect /run-test-result Enabled failed/
expect /run-done/
flush
+
+
+test ShellLogic:
+ spawn as p
+ with p:
+ send "load ${scripts.path}/logic.et"
+ local:
+ expect /(load-.*)/ capture done
+ guard (done == "load-done")
+
+ send "run NegateFalse"
+ expect /run-test-result NegateFalse done/
+ expect /run-done/
+ flush
+
+ send "run NegateTrue"
+ expect /child-fail sh failed at: .*logic.et:9:9: ! true/
+ expect /run-test-result NegateTrue failed/
+ expect /run-done/
+ flush
+
+ send "run NegateNothing"
+ expect /child-fail sh failed at: .*logic.et:14:9: !/
+ expect /run-test-result NegateNothing failed/
+ expect /run-done/
+ flush