diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-08-02 14:55:46 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-08-02 16:24:32 +0200 |
commit | 387b02e41cc835541dcfc31af5f96873d5576e37 (patch) | |
tree | 9f7cbd1a6e5f408c17d5c791566d50ab6b69b93c | |
parent | 28a93e24f6a33a8254c16c31961d523c71bdb1d2 (diff) |
Test: basic shell scripts
-rw-r--r-- | test/asset/shell/echo.et | 22 | ||||
-rw-r--r-- | test/asset/shell/spawn.et | 13 | ||||
-rw-r--r-- | test/script/shell.et | 57 |
3 files changed, 92 insertions, 0 deletions
diff --git a/test/asset/shell/echo.et b/test/asset/shell/echo.et new file mode 100644 index 0000000..4da319e --- /dev/null +++ b/test/asset/shell/echo.et @@ -0,0 +1,22 @@ +test Echo: + node n + let echo_str = "echo" + let space_str = "a b" + + shell on n as sh: + echo a b c + echo "a b c" + echo 'a b d' + echo a b " c d" + + /bin/echo "abcd" xyz + "echo" a"a" "b"c d + $echo_str b $echo_str c + + echo "$space_str" + echo $space_str + echo '$space_str' + + echo \$ \" \\ + echo "\""\""a" + echo "'" '"' '\\\' "\\" diff --git a/test/asset/shell/spawn.et b/test/asset/shell/spawn.et new file mode 100644 index 0000000..9d48e72 --- /dev/null +++ b/test/asset/shell/spawn.et @@ -0,0 +1,13 @@ +test ShellTrue: + node n + shell on n: + true + + shell on n as sh: + true + + +test ShellFalse: + node n + shell on n as sh: + false diff --git a/test/script/shell.et b/test/script/shell.et new file mode 100644 index 0000000..5cc11fb --- /dev/null +++ b/test/script/shell.et @@ -0,0 +1,57 @@ +asset scripts: + path: ../asset/shell + + +test ShellSpawn: + spawn as p + with p: + send "load ${scripts.path}/spawn.et" + local: + expect /(load-.*)/ capture done + guard (done == "load-done") + flush + + send "run-all" + expect /run-test-result ShellTrue done/ + expect /child-fail sh failed at: .*: false/ + expect /child-fail sh exit code: 1/ + expect /run-test-result ShellFalse failed/ + expect /run-all-done/ + + +def expect_next_stdout from p (expected): + expect from p /child-stdout sh (.*)/ capture line + guard (line == expected) + +test ShellEcho: + spawn as p + with p: + send "load ${scripts.path}/echo.et" + local: + expect /(load-.*)/ capture done + guard (done == "load-done") + flush + + send "run-all" + + expect_next_stdout from p: + "a b c" + "a b c" + "a b d" + "a b c d" + + "abcd xyz" + "aa bc d" + "b echo c" + + "a b" + "a b" + "\$space_str" + + "\$ \" \\" + "\"\"a" + "' \" \\\\\\ \\" + + with p: + expect /run-test-result Echo done/ + expect /run-all-done/ |