summaryrefslogtreecommitdiff
path: root/test/script
diff options
context:
space:
mode:
Diffstat (limited to 'test/script')
-rw-r--r--test/script/run.et120
-rw-r--r--test/script/shell.et100
2 files changed, 204 insertions, 16 deletions
diff --git a/test/script/run.et b/test/script/run.et
index 973a786..dfccab5 100644
--- a/test/script/run.et
+++ b/test/script/run.et
@@ -3,6 +3,13 @@ module run
asset scripts:
path: ../asset/run
+asset scripts_success:
+ path: ../asset/run-success
+
+asset scripts_fail:
+ path: ../asset/run-fail
+
+
test TrivialRun:
spawn as p
with p:
@@ -21,16 +28,49 @@ test TrivialRun:
guard (done == "run-failed")
+test SimpleRun:
+ let should_succeed = [ "bool", "command-ignore" ]
+ let should_fail = [ "bool" ]
+ spawn as p
+
+ with p:
+ for file in should_succeed:
+ send "load ${scripts_success.path}/$file.et"
+ local:
+ expect /(load-.*)/ capture done
+ guard (done == "load-done")
+ flush
+
+ send "run Test"
+ local:
+ expect /(run-.*)/ capture done
+ guard (done == "run-done")
+ flush
+
+ for file in should_fail:
+ send "load ${scripts_fail.path}/$file.et"
+ local:
+ expect /(load-.*)/ capture done
+ guard (done == "load-done")
+ flush
+
+ send "run Test"
+ local:
+ expect /(run-.*)/ capture done
+ guard (done == "run-failed")
+ flush
+
+
test RunConfig:
node n
- shell on n:
- cp ${scripts.path}/erebos-tester.yaml .
- mkdir tools
- cp ${scripts.path}/tools/echo.sh ./tools/tool
- mkdir scripts
- # TODO: it seems that namespaces are not properly cleaned up after the failed test
- #cp ${scripts.path}/trivial.et ./scripts/
- cp ${scripts.path}/echo.et ./scripts/
+ local:
+ shell on n:
+ cp ${scripts.path}/erebos-tester.yaml .
+ mkdir tools
+ cp ${scripts.path}/tools/echo.sh ./tools/tool
+ mkdir scripts
+ cp ${scripts.path}/trivial.et ./scripts/
+ cp ${scripts.path}/echo.et ./scripts/
spawn as p on n
@@ -38,8 +78,8 @@ test RunConfig:
send "load-config"
expect /load-config-done/
send "run-all"
- #expect /run-test-result AlwaysSucceeds done/
- #expect /run-test-result AlwaysFails failed/
+ expect /run-test-result AlwaysSucceeds done/
+ expect /run-test-result AlwaysFails failed/
expect /child-stdin p abcdef/
expect /child-stdout p abcdef/
expect /match p abcdef/
@@ -49,12 +89,13 @@ test RunConfig:
test GetSysInfo:
node n
- shell on n:
- cp ${scripts.path}/erebos-tester.yaml .
- mkdir tools
- cp ${scripts.path}/tools/sysinfo.sh ./tools/tool
- mkdir scripts
- cp ${scripts.path}/sysinfo.et ./scripts/
+ local:
+ shell on n:
+ cp ${scripts.path}/erebos-tester.yaml .
+ mkdir tools
+ cp ${scripts.path}/tools/sysinfo.sh ./tools/tool
+ mkdir scripts
+ cp ${scripts.path}/sysinfo.et ./scripts/
spawn as p on n
@@ -63,3 +104,50 @@ test GetSysInfo:
expect /load-config-done/
send "run SysInfo"
expect /run-done/
+
+
+test CallStack:
+ spawn as p
+ with p:
+ send "load ${scripts.path}/callstack.et"
+ expect /load-done/
+
+ send "run AG"
+ expect /match-fail guard failed/
+ expect /match-fail-line .*\/callstack.et:3:5: .*/
+ expect /match-fail-var x 1/
+ local:
+ expect /(run-.*)/ capture done
+ guard (done == "run-failed")
+ flush
+
+ send "run AE"
+ expect /match-fail expect failed/
+ expect /match-fail-line .*\/callstack.et:8:5: .*/
+ expect /match-fail-var x 2/
+ local:
+ expect /(run-.*)/ capture done
+ guard (done == "run-failed")
+ flush
+
+ send "run BG"
+ expect /match-fail guard failed/
+ expect /match-fail-line .*\/callstack.et:12:5: .*/
+ expect /match-fail-var x 1/
+ expect /match-fail-line .*\/callstack.et:15:5: .*/
+ local:
+ expect /(run-.*)/ capture done
+ guard (done == "run-failed")
+ flush
+
+ send "run CG"
+ expect /match-fail guard failed/
+ expect /match-fail-line .*\/callstack.et:19:5: .*/
+ expect /match-fail-var x 3/
+ expect /match-fail-var y 2/
+ expect /match-fail-line .*\/callstack.et:23:5: .*/
+ expect /match-fail-var z 3/
+ local:
+ expect /(run-.*)/ capture done
+ guard (done == "run-failed")
+ flush
diff --git a/test/script/shell.et b/test/script/shell.et
new file mode 100644
index 0000000..282df37
--- /dev/null
+++ b/test/script/shell.et
@@ -0,0 +1,100 @@
+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"
+ "' \" \\\\\\ \\"
+ "a b c"
+
+ "\" ' \\ \$ # | > < ; [ ] { } ( ) * ? ~ & !"
+
+ with p:
+ expect /run-test-result Echo done/
+ expect /run-all-done/
+
+
+test ShellPipe:
+ spawn as p
+ with p:
+ send "load ${scripts.path}/pipe.et"
+ local:
+ expect /(load-.*)/ capture done
+ guard (done == "load-done")
+ flush
+
+ send "run-all"
+
+ expect_next_stdout from p:
+ "bc"
+ "b"
+ with p:
+ expect /run-test-result Pipe done/
+
+ expect_next_stdout from p:
+ "x"
+ "b"
+ "c"
+ "y"
+ "b"
+ "c"
+ "z"
+ with p:
+ expect /run-test-result Redirect done/
+
+ expect_next_stdout from p:
+ "c"
+ "e"
+ "g"
+ "bcdefg"
+ with p:
+ expect /run-test-result PipeRedirect done/
+
+ with p:
+ expect /run-all-done/