[Build] Split android_lint_test
This CL renames android_lint_test to android_nocompile_test and introduces 2 sub test suites: - android_lint_tests - android_lookup_dep_tests This CL also modifies the android_nocompile_test_suite() GN template so that the 'nocompile output directory' is shared for android_nocompile_test_suite() whose tests are defined in the same BUILD.gn file. This avoids running 'gn gen' for each android_nocompile_test_suite(). BUG=1108362 Change-Id: I07c19fa595e2e9c3cc63aadfd7e70983e4759255 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2945458 Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org> Reviewed-by: Haiyang Pan <hypan@google.com> Reviewed-by: Peter Wen <wnwen@chromium.org> Cr-Commit-Position: refs/heads/master@{#891876}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
cdca0e11bb
commit
e6a52a1fcc
2
BUILD.gn
2
BUILD.gn
@ -365,7 +365,7 @@ group("gn_all") {
|
||||
"//base/android/linker:chromium_android_linker",
|
||||
"//build/android/gyp/test:hello_world",
|
||||
"//build/android/stacktrace:java_deobfuscate",
|
||||
"//build/android/test:android_lint_test",
|
||||
"//build/android/test:android_nocompile_tests",
|
||||
"//build/config/android/test/proto:test_build_protos",
|
||||
"//chrome/android/monochrome:monochrome_public_apk_checker",
|
||||
"//chrome/android/webapk/shell_apk:maps_go_webapk",
|
||||
|
@ -18,6 +18,9 @@ _NINJA_PATH = os.path.join(_CHROMIUM_SRC, 'third_party', 'depot_tools', 'ninja')
|
||||
# Relative to _CHROMIUM_SRC
|
||||
_GN_SRC_REL_PATH = os.path.join('third_party', 'depot_tools', 'gn')
|
||||
|
||||
# Regex for determining whether compile failed because 'gn gen' needs to be run.
|
||||
_GN_GEN_REGEX = re.compile(r'ninja: (error|fatal):')
|
||||
|
||||
|
||||
def _raise_command_exception(args, returncode, output):
|
||||
"""Raises an exception whose message describes a command failure.
|
||||
@ -98,10 +101,13 @@ def _find_regex_in_test_failure_output(test_output, regex):
|
||||
if regex.find('\n') >= 0:
|
||||
return re.search(regex, failure_message)
|
||||
|
||||
for line in failure_message.split('\n')[:5]:
|
||||
return _search_regex_in_list(failure_message.split('\n')[:5], regex)
|
||||
|
||||
|
||||
def _search_regex_in_list(value, regex):
|
||||
for line in value:
|
||||
if re.search(regex, line):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
@ -138,14 +144,15 @@ def main():
|
||||
_copy_and_append_gn_args(options.gn_args_path, out_gn_args_path,
|
||||
extra_gn_args)
|
||||
|
||||
# As all of the test targets are declared in the same BUILD.gn file, it does
|
||||
# not matter which test target is used as the root target.
|
||||
# Extract directory from test target. As all of the test targets are declared
|
||||
# in the same BUILD.gn file, it does not matter which test target is used.
|
||||
target0_dir = test_configs[0]['target'].rsplit(':', 1)[0]
|
||||
gn_args = [
|
||||
_GN_SRC_REL_PATH, '--root-target=' + test_configs[0]['target'], 'gen',
|
||||
_GN_SRC_REL_PATH, '--root-target=' + target0_dir, 'gen',
|
||||
os.path.relpath(options.out_dir, _CHROMIUM_SRC)
|
||||
]
|
||||
_run_command(gn_args, cwd=_CHROMIUM_SRC)
|
||||
|
||||
ran_gn_gen = False
|
||||
error_messages = []
|
||||
for config in test_configs:
|
||||
# Strip leading '//'
|
||||
@ -157,6 +164,16 @@ def main():
|
||||
# "Compile successful." is not a compiler log message.
|
||||
test_output = _run_command_get_output(ninja_args, '""\nCompile successful.')
|
||||
|
||||
# 'gn gen' takes > 1s to run. Only run 'gn gen' if it is needed for compile.
|
||||
if _search_regex_in_list(test_output.split('\n'), _GN_GEN_REGEX):
|
||||
assert not ran_gn_gen
|
||||
ran_gn_gen = True
|
||||
_run_command(gn_args, cwd=_CHROMIUM_SRC)
|
||||
|
||||
# Redo compile.
|
||||
test_output = _run_command_get_output(ninja_args,
|
||||
'""\nCompile successful.')
|
||||
|
||||
if not _find_regex_in_test_failure_output(test_output, expect_regex):
|
||||
error_message = '//{} failed.\nExpected compile output pattern:\n'\
|
||||
'{}\nActual compile output:\n{}'.format(
|
||||
|
@ -6,18 +6,22 @@ import("//build/config/android/android_nocompile.gni")
|
||||
import("nocompile_gn/nocompile_sources.gni")
|
||||
|
||||
if (enable_java_templates) {
|
||||
android_nocompile_test_suite("android_lint_test") {
|
||||
# Depend on lint and compile_java Python scripts so that the action is re-run whenever the
|
||||
# scripts are modified.
|
||||
pydeps = [
|
||||
"//build/android/gyp/compile_java.pydeps",
|
||||
"//build/android/gyp/lint.pydeps",
|
||||
]
|
||||
group("android_nocompile_tests") {
|
||||
testonly = true
|
||||
|
||||
sources = [ rebase_path(
|
||||
missing_symbol_generated_importer_template_nocompile_source,
|
||||
"",
|
||||
"nocompile_gn") ]
|
||||
# No-compile tests use an output directory dedicated to no-compile tests.
|
||||
# All test suites use targets in nocompile_gn/BUILD.gn in order to share the
|
||||
# same target output directory and avoid running 'gn gen' for each
|
||||
# android_nocompile_test_suite().
|
||||
deps = [
|
||||
":android_lint_tests",
|
||||
":android_lookup_dep_tests",
|
||||
]
|
||||
}
|
||||
|
||||
android_nocompile_test_suite("android_lint_tests") {
|
||||
# Depend on lint script so that the action is re-run whenever the script is modified.
|
||||
pydeps = [ "//build/android/gyp/lint.pydeps" ]
|
||||
|
||||
tests = [
|
||||
{
|
||||
@ -34,6 +38,19 @@ if (enable_java_templates) {
|
||||
rebase_path(new_api_lint_test_nocompile_sources, "", "nocompile_gn")
|
||||
expected_compile_output_regex = "Error:.*NewApi"
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
android_nocompile_test_suite("android_lookup_dep_tests") {
|
||||
# Depend on compile_java Python scripts so that the action is re-run whenever the script is modified.
|
||||
pydeps = [ "//build/android/gyp/compile_java.pydeps" ]
|
||||
|
||||
sources = [ rebase_path(
|
||||
missing_symbol_generated_importer_template_nocompile_source,
|
||||
"",
|
||||
"nocompile_gn") ]
|
||||
|
||||
tests = [
|
||||
{
|
||||
target = "nocompile_gn:import_child_missing_symbol_test_java"
|
||||
nocompile_sources =
|
||||
|
@ -38,6 +38,7 @@ template("android_nocompile_test_suite") {
|
||||
_tests = invoker.tests
|
||||
_test0 = _tests[0]
|
||||
_test0_dir = get_label_info(_test0["target"], "dir")
|
||||
_test0_target_out_dir = get_label_info(_test0["target"], "target_out_dir")
|
||||
foreach(_test_config, _tests) {
|
||||
assert(
|
||||
_test0_dir == get_label_info(_test_config["target"], "dir"),
|
||||
@ -84,13 +85,18 @@ template("android_nocompile_test_suite") {
|
||||
_config_path = "$target_gen_dir/${target_name}.nocompile_config"
|
||||
write_file(_config_path, _json_test_configs, "json")
|
||||
|
||||
# Compute output directory for no-compile tests based on the directory containing test
|
||||
# targets instead of based on the test suite target name. This avoids calling 'gn gen' for each
|
||||
# android_nocompile_test_suite() for test suites whose tests are declared in the same BUILD.gn
|
||||
# file.
|
||||
_out_dir = "${_test0_target_out_dir}/nocompile_out"
|
||||
|
||||
_stamp_path = "${target_gen_dir}/${target_name}.stamp"
|
||||
args = [
|
||||
"--gn-args-path",
|
||||
"args.gn",
|
||||
"--out-dir",
|
||||
rebase_path("${target_out_dir}/${target_name}/nocompile_out",
|
||||
root_build_dir),
|
||||
rebase_path(_out_dir, root_build_dir),
|
||||
"--test-configs-path",
|
||||
rebase_path(_config_path, root_build_dir),
|
||||
"--stamp",
|
||||
|
@ -24721,7 +24721,7 @@
|
||||
},
|
||||
"android-lollipop-arm-rel": {
|
||||
"additional_compile_targets": [
|
||||
"android_lint_test",
|
||||
"android_nocompile_tests",
|
||||
"cronet_test_instrumentation_apk",
|
||||
"errorprone_plugin_tests",
|
||||
"monochrome_static_initializers"
|
||||
|
@ -92,8 +92,8 @@
|
||||
"label": "//chrome/test:android_browsertests",
|
||||
"type": "windowed_test_launcher",
|
||||
},
|
||||
"android_lint_test": {
|
||||
"label": "//build/android/test:android_lint_test",
|
||||
"android_nocompile_tests": {
|
||||
"label": "//build/android/test:android_nocompile_tests",
|
||||
"type": "additional_compile_target",
|
||||
},
|
||||
"android_sync_integration_tests": {
|
||||
|
@ -836,7 +836,7 @@
|
||||
'lollipop',
|
||||
],
|
||||
'additional_compile_targets': [
|
||||
'android_lint_test',
|
||||
'android_nocompile_tests',
|
||||
'cronet_test_instrumentation_apk',
|
||||
'errorprone_plugin_tests',
|
||||
'monochrome_static_initializers',
|
||||
|
Reference in New Issue
Block a user