aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2022-05-19 21:30:17 -0700
committerYifan Hong <elsk@google.com>2022-05-19 21:30:17 -0700
commit4b96d85dac392052947e036ba4ff70ec9cd635ad (patch)
tree81bd3f5a3969a1705370d3e0cd6e49f387375f68
parentdc7641a794a9d8a74f81aa6e03df0d8b8ad16cd5 (diff)
downloadbazel_common_rules-android-gs-raviole-5.10-t-beta-4.tar.gz
exec_test is like exec, but it can be provided to bazel test. Test: TH Change-Id: Ia8cb2c54a7fd7305b718875027bd09f1a9dfa862
-rw-r--r--exec/exec.bzl27
1 files changed, 27 insertions, 0 deletions
diff --git a/exec/exec.bzl b/exec/exec.bzl
index 0769354..ee18f94 100644
--- a/exec/exec.bzl
+++ b/exec/exec.bzl
@@ -67,3 +67,30 @@ See `build/bazel_common_rules/exec/tests/BUILD` for examples.
},
executable = True,
)
+
+exec_test = rule(
+ implementation = _impl,
+ doc = """Run a test script when `bazel test` this target.
+
+See [documentation] for the `args` attribute.
+""",
+ attrs = {
+ "data": attr.label_list(aspects = [exec_aspect], allow_files = True, doc = """A list of labels providing runfiles. Labels may be used in `script`.
+
+Executables in `data` must not have the `args` and `env` attribute. Use
+[`embedded_exec`](#embedded_exec) to wrap the depended target so its env and args
+are preserved.
+"""),
+ "hashbang": attr.string(default = "/bin/bash -e", doc = "Hashbang of the script."),
+ "script": attr.string(doc = """The script.
+
+Use `$(rootpath <label>)` to refer to the path of a target specified in `data`. See
+[documentation](https://bazel.build/reference/be/make-variables#predefined_label_variables).
+
+Use `$@` to refer to the args attribute of this target.
+
+See `build/bazel_common_rules/exec/tests/BUILD` for examples.
+"""),
+ },
+ test = True,
+)