diff options
Diffstat (limited to 'test/script')
| -rw-r--r-- | test/script/definition.et | 21 | ||||
| -rw-r--r-- | test/script/expansion.et | 15 | ||||
| -rw-r--r-- | test/script/list.et | 42 | ||||
| -rw-r--r-- | test/script/network.et | 28 | ||||
| -rw-r--r-- | test/script/output.et | 57 | ||||
| -rw-r--r-- | test/script/parser.et | 26 | ||||
| -rw-r--r-- | test/script/run.et | 329 | ||||
| -rw-r--r-- | test/script/shell.et | 203 |
8 files changed, 721 insertions, 0 deletions
diff --git a/test/script/definition.et b/test/script/definition.et new file mode 100644 index 0000000..31ae21f --- /dev/null +++ b/test/script/definition.et @@ -0,0 +1,21 @@ +module definition + +asset scripts: + path: ../asset/definition + +test Definition: + spawn as p + with p: + send "load ${scripts.path}/basic.et" + expect /load-done/ + + send "run Test" + expect /global-info - Starting test ‘basic\.Test’/ + expect /child-stdout p 4/ + expect /match p 4/ + expect /child-stdout p 11/ + expect /match p 11/ + expect /run-test-result Test (.*)/ capture result + guard (result == "done") + expect /(.*)/ capture done + guard (done == "run-done 1 1 0 0") diff --git a/test/script/expansion.et b/test/script/expansion.et new file mode 100644 index 0000000..85c241d --- /dev/null +++ b/test/script/expansion.et @@ -0,0 +1,15 @@ +module expansion + +asset expansion: + path: ../asset/expansion.et + +test VariableExpansion: + spawn as p + with p: + send "load ${expansion.path}" + expect /load-done/ + send "run VariableExpansion" + for str in [ "1", "1.3", "abc", "abc" ]: + expect /child-stdout p $str/ + expect /match p $str/ + expect /run-done 1 1 0 0/ diff --git a/test/script/list.et b/test/script/list.et new file mode 100644 index 0000000..7a032cb --- /dev/null +++ b/test/script/list.et @@ -0,0 +1,42 @@ +module list + +asset scripts: + path: ../asset/list + +def expect_next_stdout (what) from p: + expect /child-stdout shell (.*)/ from p capture line + guard (line == what) + + +test ListConcat: + spawn as p + with p: + send "load ${scripts.path}/concat.et" + expect /load-done/ + + send "run Test" + expect_next_stdout from p: + "c1 1" + "c1-end" + "c2 1" + "c2-end" + "c3 1" + "c3 2" + "c3 3" + "c3 6" + "c3 5" + "c3 2" + "c3 3" + "c3-end" + "c4 1" + "c4 2" + "c4 3" + "c4 6" + "c4 5" + "c4 2" + "c4 3" + "c4-end" + local: + expect /run-test-result Test (.*)/ capture result + guard (result == "done") + expect /run-done 1 1 0 0/ diff --git a/test/script/network.et b/test/script/network.et new file mode 100644 index 0000000..2978910 --- /dev/null +++ b/test/script/network.et @@ -0,0 +1,28 @@ +module network + +asset scripts: + path: ../asset/network + + +def run_test_from using p (file): + guard (file /= "") # TODO: forces (file :: String) + send "" to p # TODO: forces (p :: Process) + + with p: + send "load $file" + expect /load-done/ + + send "run Test" + expect /run-test-result Test (.*)/ capture result + guard (result == "done") + expect /run-done 1 1 0 0/ + + +test DisconnectNode: + spawn as p + run_test_from using p "${scripts.path}/disconnect_node.et" + + +test DisconnectNodes: + spawn as p + run_test_from using p "${scripts.path}/disconnect_nodes.et" diff --git a/test/script/output.et b/test/script/output.et new file mode 100644 index 0000000..8fb5616 --- /dev/null +++ b/test/script/output.et @@ -0,0 +1,57 @@ +module output + +asset scripts: + path: ../asset/output + +test FlushOutput: + spawn as p + with p: + send "load ${scripts.path}/flush.et" + expect /load-done/ + + send "run Test" + expect /child-stdout p a/ + expect /child-stdout p b/ + expect /child-stdout p c/ + expect /child-stdout p d/ + expect /child-stdout p e/ + expect /match p e/ + expect /ignored p b/ + expect /ignored p c/ + expect /ignored p d/ + expect /match p a/ + expect /match-fail expect.*/ + + expect /run-test-result Test (.*)/ capture result + guard (result == "failed") + expect /run-done 1 0 0 1/ + +test IgnoreOutput: + spawn as p + with p: + send "load ${scripts.path}/ignore.et" + expect /load-done/ + + send "run Test" + expect /child-stdout p a/ + expect /child-stdout p b/ + expect /child-stdout p c/ + expect /child-stdout p d/ + expect /child-stdin p x/ + expect /child-stdout p e/ + expect /child-stdout p F/ + expect /child-stdout p g/ + expect /child-stdout p H/ + expect /match p d/ + expect /ignored p b/ + expect /ignored p c/ + expect /match p a/ + expect /ignored p e/ + expect /match p H/ + expect /ignored p g/ + expect /match p F/ + expect /match-fail expect.*/ + + expect /run-test-result Test (.*)/ capture result + guard (result == "failed") + expect /run-done 1 0 0 1/ diff --git a/test/script/parser.et b/test/script/parser.et new file mode 100644 index 0000000..d387877 --- /dev/null +++ b/test/script/parser.et @@ -0,0 +1,26 @@ +module parser + +asset scripts: + path: ../asset/parser + +def expect_load_success using p of file: + guard (file /= "") # TODO: forces (file :: String) + send "load ${scripts.path}/$file.et" to p + expect /load-([a-z-]+).*/ from p capture done + guard (done == "done") + +def expect_load_failure using p of file giving error: + guard (file /= "") # TODO: forces (file :: String) + send "load ${scripts.path}/$file.et" to p + expect /load-([a-z-]+) ([a-z-]+).*/ from p capture done, msg + guard (done == "failed") + guard (msg == error) + +test Parser: + spawn as p + expect_load_failure using p of "non-existing-file" giving "file-not-found" + expect_load_success using p of "indent" + expect_load_success using p of "function" + expect_load_failure using p of "function-fail" giving "parse-error" + expect_load_success using p of "tags" + expect_load_success using p of "type-annotation" diff --git a/test/script/run.et b/test/script/run.et new file mode 100644 index 0000000..d58746a --- /dev/null +++ b/test/script/run.et @@ -0,0 +1,329 @@ +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: + send "load ${scripts.path}/trivial.et" + expect /load-done/ + + send "run AlwaysSucceeds" + local: + expect /run-test-result AlwaysSucceeds (.*)/ capture result + guard (result == "done") + expect /run-done ([0-9]+) ([0-9]+) 0 0/ capture total, passed + guard (total == passed) + + send "run AlwaysFails" + local: + expect /match-fail .*/ + expect /run-test-result AlwaysFails (.*)/ capture result + guard (result == "failed") + expect /run-done ([0-9]+) 0 0 ([0-9]+)/ capture total, failed + guard (total == failed) + + +test SimpleRun: + let should_succeed = [ "bool", "command-flush", "command-ignore" ] + let should_fail = [ "bool", "command-ignore" ] + 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-test-result Test (.*)/ capture result + guard (result == "done") + expect /run-done 1 1 0 0/ + 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-test-result Test (.*)/ capture result + guard (result == "failed") + expect /run-done 1 0 0 1/ + flush + + +test RunConfig: + node n + 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 + + with p: + send "load-config" + expect /load-config-done/ + send "run *" + 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/ + expect /run-test-result ExpectEcho done/ + expect /run-done 3 2 0 1/ + + +test GetSysInfo: + node n + 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 + + with p: + send "load-config" + expect /load-config-done/ + send "run SysInfo" + expect /run-done 1 1 0 0/ + + +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 /(match-fail-.*)/ capture done + guard (done == "match-fail-done") + local: + expect /run-test-result AG (.*)/ capture result + guard (result == "failed") + expect /run-done 1 0 0 1/ + 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 /(match-fail-.*)/ capture done + guard (done == "match-fail-done") + local: + expect /run-test-result AE (.*)/ capture result + guard (result == "failed") + expect /run-done 1 0 0 1/ + 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 /(match-fail-.*)/ capture done + guard (done == "match-fail-done") + local: + expect /run-test-result BG (.*)/ capture result + guard (result == "failed") + expect /run-done 1 0 0 1/ + 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 /(match-fail-.*)/ capture done + guard (done == "match-fail-done") + local: + expect /run-test-result CG (.*)/ capture result + guard (result == "failed") + expect /run-done 1 0 0 1/ + flush + + send "run BE" + expect /match-fail expect failed/ + expect /match-fail-line .*\/callstack.et:27:5: .*/ + expect /match-fail-var x 1/ + expect /match-fail-line .*\/callstack.et:31:5: .*/ + expect /match-fail-var p <process:p#[0-9]+>/ + local: + expect /(match-fail-.*)/ capture done + guard (done == "match-fail-done") + local: + expect /run-test-result BE (.*)/ capture result + guard (result == "failed") + expect /run-done 1 0 0 1/ + flush + + send "run CE" + expect /match-fail expect failed/ + expect /match-fail-line .*\/callstack.et:36:5: .*/ + expect /match-fail-var x 3/ + expect /match-fail-var y 2/ + expect /match-fail-line .*\/callstack.et:41:5: .*/ + expect /match-fail-var p <process:p#[0-9]+>/ + expect /match-fail-var z 3/ + local: + expect /(match-fail-.*)/ capture done + guard (done == "match-fail-done") + local: + expect /run-test-result CE (.*)/ capture result + guard (result == "failed") + expect /run-done 1 0 0 1/ + flush + + +test RunTag: + spawn as p + with p: + send "load ${scripts.path}/tags.et" + local: + expect /(load-.*)/ capture done + guard (done == "load-done") + flush + + send "run A" + local: + expect /run-test-result A1 (.*)/ capture result + guard (result == "done") + local: + expect /run-test-result A2 (.*)/ capture result + guard (result == "done") + local: + expect /run-(.*)/ capture done + guard (done == "done 2 2 0 0") + + send "run B C" + local: + expect /run-test-result B1 (.*)/ capture result + guard (result == "done") + local: + expect /run-test-result B2 (.*)/ capture result + guard (result == "done") + local: + expect /run-test-result C1 (.*)/ capture result + guard (result == "done") + local: + expect /run-test-result C2 (.*)/ capture result + guard (result == "done") + local: + expect /run-test-result BC (.*)/ capture result + guard (result == "done") + local: + expect /run-(.*)/ capture done + guard (done == "done 5 5 0 0") + + +test RunTagExclude: + spawn as p + with p: + send "load ${scripts.path}/tags.et" + local: + expect /(load-.*)/ capture done + guard (done == "load-done") + flush + + send "run * ^A ^C ^T2 ^B1" + local: + expect /run-test-result T1 (.*)/ capture result + guard (result == "done") + local: + expect /run-test-result B2 (.*)/ capture result + guard (result == "done") + local: + expect /run-(.*)/ capture done + guard (done == "done 2 2 0 0") + + send "run T1 B1 A C ^B ^A1" + local: + expect /run-test-result T1 (.*)/ capture result + guard (result == "done") + local: + expect /run-test-result A2 (.*)/ capture result + guard (result == "done") + local: + expect /run-test-result C1 (.*)/ capture result + guard (result == "done") + local: + expect /run-test-result C2 (.*)/ capture result + guard (result == "done") + local: + expect /run-(.*)/ capture done + guard (done == "done 4 4 0 0") + + +test RunExcludeConfig1: + node n + local: + shell on n: + cp ${scripts.path}/erebos-tester-select1.yaml erebos-tester.yaml + cp ${scripts.path}/tags.et . + + spawn as p on n + with p: + send "load-config" + expect /load-config-done/ + send "run *" + expect /run-test-result T1 done/ + expect /run-test-result T2 done/ + expect /run-test-result A1 done/ + expect /run-test-result A2 done/ + expect /run-test-result C1 done/ + expect /run-test-result C2 done/ + local: + expect /run-(.*)/ capture done + guard (done == "done 6 6 0 0") + +test RunExcludeConfig2: + node n + local: + shell on n: + cp ${scripts.path}/erebos-tester-select2.yaml erebos-tester.yaml + cp ${scripts.path}/tags.et . + + spawn as p on n + with p: + send "load-config" + expect /load-config-done/ + send "run *" + expect /run-test-result T2 done/ + expect /run-test-result A2 done/ + expect /run-test-result B1 done/ + expect /run-test-result B2 done/ + local: + expect /run-(.*)/ capture done + guard (done == "done 4 4 0 0") diff --git a/test/script/shell.et b/test/script/shell.et new file mode 100644 index 0000000..90ff29a --- /dev/null +++ b/test/script/shell.et @@ -0,0 +1,203 @@ +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 *" + 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-done 2 1 0 1/ + + +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 *" + + 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-done 1 1 0 0/ + + +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 *" + + 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-done 3 3 0 0/ + + +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 home + expect_next_stdout from p: + "$home/abc/def" + "$home/abc" + "$home/abc/def/ghi" + "$home/abc" + "$home/abc" + "$home/abc/def/ghi" + "$home/abc/def/ghi" + "$home" + "$home" + "/tmp" + + +test ShellExitOnError: + spawn as p + with p: + send "load ${scripts.path}/error-exit.et" + local: + expect /(load-.*)/ capture done + guard (done == "load-done") + + send "run Default" + expect /child-fail sh failed at: .*error-exit.et:4:9: false/ + expect /run-test-result Default failed/ + expect /run-done 1 0 0 1/ + flush + + send "run DisabledSuccess" + expect /run-test-result DisabledSuccess done/ + expect /run-done 1 1 0 0/ + flush + + send "run DisabledFailure" + expect /run-test-result DisabledFailure failed/ + expect /run-done 1 0 0 1/ + flush + + send "run Enabled" + expect /child-fail sh failed at: .*error-exit.et:25:9: false/ + expect /run-test-result Enabled failed/ + expect /run-done 1 0 0 1/ + 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 1 1 0 0/ + flush + + send "run NegateTrue" + expect /child-fail sh failed at: .*logic.et:9:9: ! true/ + expect /run-test-result NegateTrue failed/ + expect /run-done 1 0 0 1/ + flush + + send "run NegateNothing" + expect /child-fail sh failed at: .*logic.et:14:9: !/ + expect /run-test-result NegateNothing failed/ + expect /run-done 1 0 0 1/ + flush + + +test ShellVariableExpansion: + spawn as p + with p: + send "load ${scripts.path}/expansion.et" + local: + expect /(load-.*)/ capture done + guard (done == "load-done") + + send "run Test" + expect /child-stdout sh A some string B 2 4.5 C/ + expect /child-stdout sh D a b c d e f E/ + expect /child-stdout sh F 1 2 3 4 5 G/ + expect /child-stdout sh H I/ + expect /child-stdout sh w x y z J/ + expect /child-stdout sh w x y z K 1 2 3 4 5 L 2 M < > \| \& \; N/ + expect /child-stdout sh some stringO Psome string/ + expect /run-test-result Test done/ + expect /run-done 1 1 0 0/ + flush |