diff --git a/.gitignore b/.gitignore index 8ae985a5cd2e8b..31867d1985cb3d 100644 --- a/.gitignore +++ b/.gitignore @@ -280,6 +280,7 @@ vs-chromium-project.txt /sql/sql_unittests_run.xml /sync/sync.xml /testing/libfuzzer/fuzzer_corpus_for_bots/ +/testing/location_tags.json /testing/rts/ /testserver.log # See third_party/.gitignore for entries covering src/third_party. diff --git a/DEPS b/DEPS index 833b5631ae82e9..3fd3ecb4462471 100644 --- a/DEPS +++ b/DEPS @@ -4387,6 +4387,17 @@ hooks = [ ], }, + { + 'name': 'Generate component metadata for tests', + 'pattern': '.', + 'action': [ + 'vpython', + 'src/testing/generate_location_tags.py', + '--out', + 'src/testing/location_tags.json', + ], + }, + # Download and initialize "vpython" VirtualEnv environment packages. { 'name': 'vpython_common', diff --git a/build/config/fuchsia/generate_runner_scripts.gni b/build/config/fuchsia/generate_runner_scripts.gni index f7dbb61813ad11..53658ed8b8d8d4 100644 --- a/build/config/fuchsia/generate_runner_scripts.gni +++ b/build/config/fuchsia/generate_runner_scripts.gni @@ -91,6 +91,10 @@ template("fuchsia_package_runner") { data = [] } + if (defined(invoker.data)) { + data += invoker.data + } + wrapper_script = generated_run_pkg_script_path data_deps = [ diff --git a/testing/generate_location_tags.py b/testing/generate_location_tags.py new file mode 100755 index 00000000000000..2860d9db1be370 --- /dev/null +++ b/testing/generate_location_tags.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# Copyright (c) 2021 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +"""Generates the directory->tags mapping used by ResultDB.""" + +# pylint: disable=line-too-long +# +# For more on the tags, see +# https://source.chromium.org/chromium/infra/infra/+/master:go/src/go.chromium.org/luci/resultdb/sink/proto/v1/location_tag.proto +# +# pylint: enable=line-too-long + +import argparse +import os +import subprocess +import sys + +THIS_DIR = os.path.dirname(__file__) +SRC_DIR = os.path.dirname(THIS_DIR) +BUILD_DIR = os.path.join(SRC_DIR, 'build') +sys.path.insert(0, BUILD_DIR) +import find_depot_tools + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('-o', '--out', required=True, + help='path to write location tag metadata to') + args = parser.parse_args() + + exe = os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'dirmd') + if sys.platform == 'win32': + exe = exe + '.bat' + + return subprocess.call([ + exe, + 'location-tags', + '-out', args.out, + '-root', SRC_DIR, + '-repo', 'https://chromium.googlesource.com/chromium/src', + ]) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/testing/test.gni b/testing/test.gni index 22c55132c782ac..e3d8870966d106 100644 --- a/testing/test.gni +++ b/testing/test.gni @@ -78,11 +78,13 @@ template("test") { executable(_exec_target) { # Configs will always be defined since we set_defaults in BUILDCONFIG.gn. configs = [] - data_deps = [] - forward_variables_from(invoker, - "*", - TESTONLY_AND_VISIBILITY + _wrapper_script_vars + - [ "extra_dist_files" ]) + forward_variables_from( + invoker, + "*", + TESTONLY_AND_VISIBILITY + _wrapper_script_vars + [ + "data_deps", + "extra_dist_files", + ]) # Thanks to the set_defaults() for test(), configs are initialized with # the default shared_library configs rather than executable configs. @@ -92,6 +94,16 @@ template("test") { ] configs += [ "//build/config:executable_config" ] + if (defined(invoker.data_deps)) { + data_deps = invoker.data_deps + } else { + data_deps = [] + } + if (!defined(data)) { + data = [] + } + data += [ "//testing/location_tags.json" ] + # Don't output to the root or else conflict with the group() below. output_name = rebase_path(_exec_output, root_out_dir) } @@ -225,6 +237,13 @@ template("test") { ":$_library_target", ] } + + if (defined(invoker.data_deps)) { + data_deps = invoker.data_deps + } else { + data_deps = [] + } + data = [ "//testing/location_tags.json" ] } } else if (is_fuchsia) { assert(!defined(invoker.use_xvfb) || !invoker.use_xvfb) @@ -272,6 +291,7 @@ template("test") { package = ":$_pkg_target" package_name_override = _output_name + data = [ "//testing/location_tags.json" ] data_deps = [ "//testing/buildbot/filters:fuchsia_filters" ] } @@ -303,7 +323,6 @@ template("test") { forward_variables_from(invoker, [ "data", - "data_deps", "deps", "executable_args", "retries", @@ -321,6 +340,11 @@ template("test") { ] wrapper_output_name = "${_wrapper_output_name}" + + if (!defined(data)) { + data = [] + } + data += [ "//testing/location_tags.json" ] } _resources_bundle_data = target_name + "_resources_bundle_data" @@ -391,6 +415,7 @@ template("test") { generated_script = "$root_build_dir/bin/run_" + invoker.target_name test_exe = invoker.target_name runtime_deps_file = _runtime_deps_file + data = [ "//testing/location_tags.json" ] } executable(target_name) { @@ -440,6 +465,7 @@ template("test") { executable = "//testing/test_env.py" data += [ "//testing/test_env.py" ] } + data += [ "//testing/location_tags.json" ] executable_args = [ "@WrappedPath(../../build/lacros/test_runner.py)", @@ -515,6 +541,7 @@ template("test") { executable = "//testing/test_env.py" data += [ "//testing/test_env.py" ] } + data += [ "//testing/location_tags.json" ] executable_args = [ "@WrappedPath(./${_executable})", @@ -618,6 +645,8 @@ template("script_test") { if (defined(invoker.data)) { data += invoker.data } + data += [ "//testing/location_tags.json" ] + data_deps = [] if (defined(invoker.data_deps)) { data_deps += invoker.data_deps