Commit 686094f6 authored by jbudorick's avatar jbudorick Committed by Commit bot

[android] Write a runner script to the top-level output dir for gtests.

Android GN builds have been unable to build raw "unit_tests" as a target,
instead relying on unit_tests_apk or chrome/test:unit_tests. Linux builds,
in contrast, can do so without issue. I had thought that the issue was
that a "unit_tests" gn target in another directory was preventing gn
from creating a top-level alias. While this may be true, it's not the
reason for the discrepancy between Android and Linux builds. Instead,
the difference is that Linux builds create a unit_tests executable in
the top-level output directory, while Android builds create an APK and
a wrapper script in child directories.

This CL writes an additional wrapper script for gtest targets on Android
in the top-level directory that matches the suite's output_name (usually
its target name), allowing us to successfully build raw "unit_tests" on
Android. As a bonus, we can now run

  $ out/Release/unit_tests

(etc) on Android.

BUG=716117

Review-Url: https://codereview.chromium.org/2851523002
Cr-Commit-Position: refs/heads/master@{#469485}
parent ff1c7739
......@@ -615,7 +615,12 @@ template("test_runner_script") {
test_runner_args += [ "--tool=asan" ]
}
generated_script = "$root_build_dir/bin/run_${_test_name}"
if (defined(invoker.generated_script)) {
assert(_test_name != "" || true) # Mark _test_name as used.
generated_script = invoker.generated_script
} else {
generated_script = "$root_build_dir/bin/run_${_test_name}"
}
outputs = [
generated_script,
]
......
......@@ -190,22 +190,35 @@ template("test") {
}
}
group(target_name) {
testonly = true
if (_incremental_apk_only) {
deps = [
":${target_name}_incremental",
]
} else {
deps = [
test_runner_script(target_name) {
forward_variables_from(invoker,
_wrapper_script_vars + [
"data",
"data_deps",
"deps",
"public_deps",
])
if (_use_raw_android_executable) {
executable_dist_dir = "$root_out_dir/$_dist_target"
deps += [
":$_dist_target",
":$_test_runner_target",
]
if (_use_raw_android_executable) {
deps += [ ":$_dist_target" ]
} else {
apk_target = ":$_apk_target"
deps += [ ":$_apk_target" ]
if (_incremental_apk_only) {
deps += [ ":${target_name}_incremental" ]
} else {
deps += [ ":$_apk_target" ]
deps += [ ":$_test_runner_target" ]
}
}
generated_script = "$root_build_dir/$_output_name"
incremental_install = _incremental_apk_only
test_name = _output_name
test_suite = _output_name
test_type = "gtest"
}
# TODO(GYP_GONE): Delete this after we've converted everything to GN.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment