Add test preventing internal code in libmonochrome.so
This adds the test script and a test for the script, but not an
actual test for the library yet. That will need to be added via
our internal repo.
Also adds an "isolated_script_test" GN template to make it easier
to add tests that just return exit codes for success/failure.
Bug: 1266989
Change-Id: I885072c0482dbf11eebf880461c4e6d0081d03b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3792096
Reviewed-by: Peter Wen <[email protected]>
Reviewed-by: Haiyang Pan <[email protected]>
Owners-Override: Andrew Grieve <[email protected]>
Commit-Queue: Andrew Grieve <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1103858}
diff --git a/testing/test.gni b/testing/test.gni
index b9cdf13..78b7abd 100644
--- a/testing/test.gni
+++ b/testing/test.gni
@@ -1031,14 +1031,13 @@
# The script must implement the
# [test executable API](//docs/testing/test_executable_api.md).
#
-# The template must be passed the `script` parameter, which specifies
-# the path to the script to run. It may optionally be passed a
-# `script_args` parameter, which can be used to include a list of
-# args to be specified by default. The template will produce
-# a `$root_build_dir/run_$target_name` wrapper and write the runtime_deps
-# for the target to $root_build_dir/${target_name}.runtime_deps, as per
-# the conventions listed in the
-# [test wrapper API](//docs/testing/test_wrapper_api.md).
+# The template must be passed the `script` parameter, which specifies the path
+# to the script to run. It may optionally be passed a `args` parameter, which
+# can be used to include a list of args to be specified by default. The
+# template will produce a `$root_build_dir/run_$target_name` wrapper and write
+# the runtime_deps for the target to
+# $root_build_dir/${target_name}.runtime_deps, as per the conventions listed in
+# the [test wrapper API](//docs/testing/test_wrapper_api.md).
template("script_test") {
if (use_rts) {
action("${target_name}__rts_filters") {
@@ -1084,12 +1083,12 @@
}
forward_variables_from(invoker,
- [ "*" ],
+ "*",
TESTONLY_AND_VISIBILITY + [
+ "args",
"data",
"data_deps",
"script",
- "script_args",
])
forward_variables_from(invoker, [ "visibility" ])
@@ -1101,6 +1100,33 @@
}
}
+# Defines a test target that uses exit code for pass/fail.
+template("isolated_script_test") {
+ script_test(target_name) {
+ forward_variables_from(invoker,
+ "*",
+ TESTONLY_AND_VISIBILITY + [
+ "args",
+ "deps",
+ "script",
+ ])
+ forward_variables_from(invoker, [ "visibility" ])
+ deps = [ "//testing:run_isolated_script_test" ]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ script = "//testing/scripts/run_isolated_script_test.py"
+ data = [ invoker.script ]
+ args = [
+ rebase_path(invoker.script, root_build_dir),
+ "--script-type=bare",
+ ]
+ if (defined(invoker.args)) {
+ args += invoker.args
+ }
+ }
+}
+
# Test defaults.
set_defaults("test") {
if (is_android) {