{ "test": { "doc": ["A test written in C++"] , "tainted": ["test"] , "target_fields": ["srcs", "private-hdrs", "private-deps", "data"] , "string_fields": [ "name" , "args" , "stage" , "pure C" , "private-defines" , "private-cflags" , "private-ldflags" ] , "config_vars": [ "ARCH" , "HOST_ARCH" , "CC" , "CXX" , "CFLAGS" , "CXXFLAGS" , "LDFLAGS" , "ADD_CFLAGS" , "ADD_CXXFLAGS" , "ADD_LDFLAGS" , "ENV" , "BUILD_POSITION_INDEPENDENT" , "TEST_ENV" , "CC_TEST_LAUNCHER" , "RUNS_PER_TEST" ] , "implicit": { "defaults": [["./", "..", "defaults"]] , "runner": ["test_runner.py"] , "summarizer": [["./", "../../shell/test", "test_summary.py"]] } , "field_doc": { "name": [ "The name of the test" , "" , "Used to name the test binary as well as for staging the test result" ] , "args": ["Command line arguments for the test binary"] , "srcs": ["The sources of the test binary"] , "private-hdrs": [ "Any additional header files that need to be present when compiling" , "the test binary." ] , "private-defines": [ "List of defines set for source files local to this target." , "Each list entry will be prepended by \"-D\"." ] , "private-cflags": ["List of compile flags set for source files local to this target."] , "private-ldflags": [ "Additional linker flags for linking external libraries (not built" , "by this tool, typically system libraries)." ] , "stage": [ "The logical location of all header and source files." , "Individual directory components are joined with \"/\"." ] , "data": ["Any files the test binary needs access to when running"] } , "config_doc": { "CC": ["The name of the C compiler to be used."] , "CXX": ["The name of the C++ compiler to be used."] , "CFLAGS": [ "The flags for CC to be used instead of the default ones" , "taken from the [\"CC\", \"defaults\"] target" ] , "CXXFLAGS": [ "The flags for CXX to be used instead of the default ones" , "taken from the [\"CC\", \"defaults\"] target" ] , "LDFLAGS": [ "The linker flags do be used instead of the default ones" , "taken from the [\"CC\", \"defaults\"] target" ] , "ADD_CFLAGS": [ "The flags to add to the default ones for CC" , "taken from the [\"CC\", \"defaults\"] target" ] , "ADD_CXXFLAGS": [ "The flags to add to the default ones for CXX" , "taken from the [\"CC\", \"defaults\"] target" ] , "ADD_LDFLAGS": [ "The linker flags to add to the default ones" , "taken from the [\"CC\", \"defaults\"] target" ] , "ENV": ["The environment for any action generated."] , "BUILD_POSITION_INDEPENDENT": ["Build with -fPIC."] , "TEST_ENV": ["The environment for executing the test runner."] , "CC_TEST_LAUNCHER": [ "List of strings representing the launcher that is prepend to the" , "command line for running the test binary." ] , "RUNS_PER_TEST": [ "The number of times the test should be run in order to detect flakyness." , "If set, no test action will be taken from cache." ] } , "artifacts_doc": [ "result: the result of this test (\"PASS\" or \"FAIL\"); useful for" , " generating test reports." , "stdout/stderr: Any output the invocation of the test binary produced on" , " the respective file descriptor" , "time-start/time-stop: The time (decimally coded) in seconds since the" , " epoch when the test invocation started and ended." ] , "runfiles_doc": [ "A tree consisting of the artifacts staged at the name of the test." , "As the built-in \"install\" rule only takes the runfiles of its" , "\"private-deps\" argument, this gives an easy way of defining test" , "suites." ] , "imports": { "artifacts": ["./", "../..", "field_artifacts"] , "runfiles": ["./", "../..", "field_runfiles"] , "compile-deps": ["./", "..", "compile-deps"] , "compile-args-deps": ["./", "..", "compile-args-deps"] , "link-deps": ["./", "..", "link-deps"] , "link-args-deps": ["./", "..", "link-args-deps"] , "run-libs-deps": ["./", "..", "run-libs-deps"] , "run-libs-args-deps": ["./", "..", "run-libs-args-deps"] , "cflags-files-deps": ["./", "..", "cflags-files-deps"] , "ldflags-files-deps": ["./", "..", "ldflags-files-deps"] , "binary": ["./", "..", "bin artifact"] , "host transition": ["transitions", "for host"] , "stage": ["./", "../..", "stage_singleton_field"] } , "config_transitions": { "defaults": [{"type": "CALL_EXPRESSION", "name": "host transition"}] , "private-deps": [{"type": "CALL_EXPRESSION", "name": "host transition"}] , "data": [{"type": "CALL_EXPRESSION", "name": "host transition"}] } , "expression": { "type": "let*" , "bindings": [ [ "name" , { "type": "assert_non_empty" , "msg": "A non-empty name has to be provided for binaries" , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}} } ] , ["pure C", {"type": "FIELD", "name": "pure C"}] , [ "stage" , { "type": "join" , "separator": "/" , "$1": {"type": "FIELD", "name": "stage"} } ] , [ "srcs" , { "type": "to_subdir" , "subdir": {"type": "var", "name": "stage"} , "$1": { "type": "let*" , "bindings": [["fieldname", "srcs"]] , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} } } ] , [ "private-hdrs" , { "type": "to_subdir" , "subdir": {"type": "var", "name": "stage"} , "$1": { "type": "let*" , "bindings": [["fieldname", "private-hdrs"]] , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"} } } ] , ["host-trans", {"type": "CALL_EXPRESSION", "name": "host transition"}] , ["defaults-transition", {"type": "var", "name": "host-trans"}] , ["deps-transition", {"type": "var", "name": "host-trans"}] , ["deps-fieldnames", ["private-deps"]] , [ "cflags-files" , {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"} ] , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}] , [ "compile-args" , { "type": "++" , "$1": [ { "type": "foreach" , "var": "def" , "range": {"type": "FIELD", "name": "private-defines"} , "body": {"type": "join", "$1": ["-D", {"type": "var", "name": "def"}]} } , {"type": "FIELD", "name": "private-cflags"} , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"} ] } ] , [ "ldflags-files" , {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"} ] , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}] , [ "link-args" , { "type": "++" , "$1": [ {"type": "CALL_EXPRESSION", "name": "link-args-deps"} , {"type": "FIELD", "name": "private-ldflags"} ] } ] , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}] , [ "run-libs-args" , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"} ] , ["binary", {"type": "CALL_EXPRESSION", "name": "binary"}] , [ "staged test binary" , { "type": "map_union" , "$1": { "type": "foreach_map" , "range": {"type": "var", "name": "binary"} , "var_val": "binary" , "body": { "type": "singleton_map" , "key": "test" , "value": {"type": "var", "name": "binary"} } } } ] , [ "runner" , { "type": "map_union" , "$1": { "type": "foreach" , "var": "runner" , "range": {"type": "FIELD", "name": "runner"} , "body": { "type": "map_union" , "$1": { "type": "foreach" , "var": "runner" , "range": { "type": "values" , "$1": { "type": "DEP_ARTIFACTS" , "dep": {"type": "var", "name": "runner"} } } , "body": { "type": "singleton_map" , "key": "runner" , "value": {"type": "var", "name": "runner"} } } } } } ] , [ "test-args" , { "type": "singleton_map" , "key": "test-args.json" , "value": { "type": "BLOB" , "data": { "type": "json_encode" , "$1": {"type": "FIELD", "name": "args", "default": []} } } } ] , [ "test-launcher" , { "type": "singleton_map" , "key": "test-launcher.json" , "value": { "type": "BLOB" , "data": { "type": "json_encode" , "$1": {"type": "var", "name": "CC_TEST_LAUNCHER", "default": []} } } } ] , [ "data" , { "type": "let*" , "bindings": [ ["fieldname", "data"] , ["transition", {"type": "var", "name": "deps-transition"}] ] , "body": { "type": "map_union" , "$1": [ {"type": "CALL_EXPRESSION", "name": "runfiles"} , {"type": "CALL_EXPRESSION", "name": "artifacts"} ] } } ] , [ "test-name" , { "type": "join" , "separator": "/" , "$1": [{"type": "var", "name": "stage"}, {"type": "var", "name": "name"}] } ] , [ "test input" , { "type": "map_union" , "$1": [ { "type": "to_subdir" , "subdir": "work" , "$1": {"type": "var", "name": "data"} } , {"type": "var", "name": "runner"} , {"type": "var", "name": "test-args"} , {"type": "var", "name": "test-launcher"} , {"type": "var", "name": "staged test binary"} , {"type": "var", "name": "run-libs"} ] } ] ] , "body": { "type": "if" , "cond": {"type": "var", "name": "RUNS_PER_TEST"} , "else": { "type": "let*" , "bindings": [ [ "test-results" , { "type": "ACTION" , "outs": ["result", "stdout", "stderr", "time-start", "time-stop"] , "inputs": {"type": "var", "name": "test input"} , "cmd": ["./runner"] , "env": { "type": "var" , "name": "TEST_ENV" , "default": {"type": "empty_map"} } , "may_fail": ["test"] , "fail_message": { "type": "join" , "$1": ["CC test ", {"type": "var", "name": "test-name"}, " failed"] } } ] , [ "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"} } } , "then": { "type": "let*" , "bindings": [ [ "attempts" , { "type": "map_union" , "$1": { "type": "foreach" , "var": "ATTEMPT" , "range": { "type": "range" , "$1": {"type": "var", "name": "RUNS_PER_TEST"} } , "body": { "type": "singleton_map" , "key": {"type": "var", "name": "ATTEMPT"} , "value": { "type": "TREE" , "$1": { "type": "ACTION" , "outs": [ "result" , "stdout" , "stderr" , "time-start" , "time-stop" ] , "inputs": { "type": "map_union" , "$1": [ { "type": "singleton_map" , "key": "ATTEMPT" , "value": { "type": "BLOB" , "data": {"type": "var", "name": "ATTEMPT"} } } , {"type": "var", "name": "test input"} ] } , "cmd": ["./runner"] , "env": { "type": "var" , "name": "TEST_ENV" , "default": {"type": "empty_map"} } , "may_fail": ["test"] , "no_cache": ["test"] , "fail_message": { "type": "join" , "$1": [ "CC test " , {"type": "var", "name": "test-name"} , " failed (Run" , {"type": "var", "name": "ATTEMPT"} , ")" ] } } } } } } ] , [ "summarizer" , { "type": "let*" , "bindings": [["fieldname", "summarizer"], ["location", "summarizer"]] , "body": {"type": "CALL_EXPRESSION", "name": "stage"} } ] , [ "summary" , { "type": "ACTION" , "inputs": { "type": "map_union" , "$1": [ {"type": "var", "name": "attempts"} , {"type": "var", "name": "summarizer"} ] } , "outs": ["stdout", "stderr", "result", "time-start", "time-stop"] , "cmd": ["./summarizer"] } ] , [ "artifacts" , { "type": "map_union" , "$1": [ {"type": "var", "name": "summary"} , { "type": "singleton_map" , "key": "work" , "value": {"type": "TREE", "$1": {"type": "var", "name": "attempts"}} } ] } ] , [ "runfiles" , { "type": "singleton_map" , "key": {"type": "var", "name": "name"} , "value": {"type": "TREE", "$1": {"type": "var", "name": "artifacts"}} } ] ] , "body": { "type": "RESULT" , "artifacts": {"type": "var", "name": "artifacts"} , "runfiles": {"type": "var", "name": "runfiles"} } } } } } }