Skip to content

Commit

Permalink
Reland "Add test directory -> monorail component metadata to test inv…
Browse files Browse the repository at this point in the history
…ocations."

This reverts commit a2927e3.

Change-Id: I40558e50f44a497a492829e561fc7c0358619d2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2779735
Reviewed-by: Chan Li <chanli@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/master@{#865433}
  • Loading branch information
dpranke authored and Chromium LUCI CQ committed Mar 23, 2021
1 parent eead3fe commit 548c753
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -4371,6 +4371,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',
Expand Down
4 changes: 4 additions & 0 deletions build/config/fuchsia/generate_runner_scripts.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
57 changes: 57 additions & 0 deletions testing/generate_location_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/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

from __future__ import print_function

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'

try:
return subprocess.call([
exe,
'location-tags',
'-out', args.out,
'-root', SRC_DIR,
'-repo', 'https://chromium.googlesource.com/chromium/src',
])
except OSError as e:
# TODO(crbug.com/1191087): Figure out what exactly is going on on Win7
# and whether this should work, be a hard error, or can be safely
# ignored.
print('%s not found: %s' % (exe, repr(e)))
if (e.errno == errno.ENOENT and sys.platform == 'win32'
and sys.getwindowsversion().major < 10):
pass
raise


if __name__ == '__main__':
sys.exit(main())
41 changes: 35 additions & 6 deletions testing/test.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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" ]
}

Expand Down Expand Up @@ -303,7 +323,6 @@ template("test") {
forward_variables_from(invoker,
[
"data",
"data_deps",
"deps",
"executable_args",
"retries",
Expand All @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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})",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 548c753

Please sign in to comment.