From 27755862921509cf3d64d730519fad3d0710c0b7 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 24 Feb 2023 15:09:49 +0100 Subject: Add rule for shell tests with remote execution ... similar to ["@", "rules", "shell/test", "script"], but implicitly starting a remote execution in the background, passing the information about that endpoint to the test via an environment variable. --- test/end-to-end/EXPRESSIONS | 190 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 test/end-to-end/EXPRESSIONS (limited to 'test/end-to-end/EXPRESSIONS') diff --git a/test/end-to-end/EXPRESSIONS b/test/end-to-end/EXPRESSIONS new file mode 100644 index 00000000..20b9cb6a --- /dev/null +++ b/test/end-to-end/EXPRESSIONS @@ -0,0 +1,190 @@ +{ "test-action": + { "vars": + [ "TEST_ENV" + , "ATTEMPT" + , "name" + , "test.sh" + , "keep" + , "transition" + , "TEST_COMPATIBLE_REMOTE" + ] + , "imports": + { "artifacts_list": ["@", "rules", "", "field_artifacts_list"] + , "runfiles_list": ["@", "rules", "", "field_runfiles_list"] + , "stage": ["@", "rules", "", "stage_singleton_field"] + } + , "expression": + { "type": "let*" + , "bindings": + [ ["fieldname", "runner"] + , ["location", "runner"] + , ["runner", {"type": "CALL_EXPRESSION", "name": "stage"}] + , ["fieldname", "just"] + , ["location", "just"] + , ["just", {"type": "CALL_EXPRESSION", "name": "stage"}] + , ["fieldname", "deps"] + , [ "deps" + , { "type": "TREE" + , "$1": + { "type": "disjoint_map_union" + , "msg": "Field \"deps\" has to stage in a conflict free way" + , "$1": + { "type": "++" + , "$1": + [ {"type": "CALL_EXPRESSION", "name": "runfiles_list"} + , {"type": "CALL_EXPRESSION", "name": "artifacts_list"} + ] + } + } + } + ] + , [ "attempt marker" + , { "type": "if" + , "cond": + { "type": "==" + , "$1": {"type": "var", "name": "ATTEMPT"} + , "$2": null + } + , "then": {"type": "empty_map"} + , "else": + { "type": "singleton_map" + , "key": "ATTEMPT" + , "value": + {"type": "BLOB", "data": {"type": "var", "name": "ATTEMPT"}} + } + } + ] + , [ "outs" + , { "type": "++" + , "$1": + [ [ "result" + , "stdout" + , "stderr" + , "time-start" + , "time-stop" + , "remotestdout" + , "remotestderr" + ] + , { "type": "foreach" + , "var": "filename" + , "range": {"type": "var", "name": "keep"} + , "body": + { "type": "join" + , "$1": ["work/", {"type": "var", "name": "filename"}] + } + } + ] + } + ] + , [ "inputs" + , { "type": "map_union" + , "$1": + [ { "type": "singleton_map" + , "key": "work" + , "value": {"type": "var", "name": "deps"} + } + , {"type": "var", "name": "just"} + , {"type": "var", "name": "runner"} + , {"type": "var", "name": "test.sh"} + , {"type": "var", "name": "attempt marker"} + ] + } + ] + , [ "cmd" + , { "type": "++" + , "$1": + [ [ "./runner" + , { "type": "if" + , "cond": {"type": "var", "name": "TEST_COMPATIBLE_REMOTE"} + , "then": "true" + , "else": "false" + } + ] + , {"type": "var", "name": "keep"} + ] + } + ] + , [ "test_env" + , {"type": "var", "name": "TEST_ENV", "default": {"type": "empty_map"}} + ] + ] + , "body": + { "type": "if" + , "cond": + {"type": "==", "$1": {"type": "var", "name": "ATTEMPT"}, "$2": null} + , "then": + { "type": "ACTION" + , "outs": {"type": "var", "name": "outs"} + , "inputs": {"type": "var", "name": "inputs"} + , "cmd": {"type": "var", "name": "cmd"} + , "env": {"type": "var", "name": "test_env"} + , "may_fail": ["test"] + , "fail_message": + { "type": "join" + , "$1": + [ "shell test with " + , { "type": "if" + , "cond": {"type": "var", "name": "TEST_COMPATIBLE_REMOTE"} + , "then": "compatible" + , "else": "native" + } + , " remote execution " + , {"type": "var", "name": "name"} + , " failed" + ] + } + } + , "else": + { "type": "ACTION" + , "outs": {"type": "var", "name": "outs"} + , "inputs": {"type": "var", "name": "inputs"} + , "cmd": {"type": "var", "name": "cmd"} + , "env": {"type": "var", "name": "test_env"} + , "may_fail": ["test"] + , "no_cache": ["test"] + , "fail_message": + { "type": "join" + , "$1": + [ "shell test with remote execution" + , {"type": "var", "name": "name"} + , " failed (Run " + , {"type": "var", "name": "ATTEMPT"} + , ")" + ] + } + } + } + } + } +, "test-result": + { "vars": + [ "TEST_ENV" + , "name" + , "test.sh" + , "keep" + , "runner" + , "deps-fieldname" + , "transition" + , "TEST_COMPATIBLE_REMOTE" + ] + , "imports": {"action": "test-action"} + , "expression": + { "type": "let*" + , "bindings": + [ ["test-results", {"type": "CALL_EXPRESSION", "name": "action"}] + , [ "runfiles" + , { "type": "singleton_map" + , "key": {"type": "var", "name": "name"} + , "value": + {"type": "TREE", "$1": {"type": "var", "name": "test-results"}} + } + ] + ] + , "body": + { "type": "RESULT" + , "artifacts": {"type": "var", "name": "test-results"} + , "runfiles": {"type": "var", "name": "runfiles"} + } + } + } +} -- cgit v1.2.3