Commit cd69e8f5 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

Revert "Rework generated_script handling in MB."

This reverts commit b05d8793.

Reason for revert: Broke ios full_configs bot. See:
https://ci.chromium.org/p/chromium/builders/ci/ios-simulator-full-configs/25885

Doesn't look like this change triggered the full_config bots on try.

Original change's description:
> Rework generated_script handling in MB.
> 
> It turns out the work I did on the "wrapped_*" targets in
> gn_isolate_map was somewhat overlapping with the already-existing
> iOS work to declare things as "generated_scripts". However, the
> generated_scripts did not include test_env.py.
> 
> So, this CL rearranges things so that the generated script will call
> test_env.py, and then we can share logic between the generated_script
> targets (and every target on iOS and LaCrOS) and use that as the
> basis for the rest of the work going forward.
> 
> Bug: 816629
> Change-Id: I9d55c3f1587defcb599ddf1df838dd9ed5b6a12c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2357917
> Reviewed-by: Erik Staab <estaab@chromium.org>
> Commit-Queue: Dirk Pranke <dpranke@google.com>
> Cr-Commit-Position: refs/heads/master@{#799171}

TBR=dpranke@google.com,estaab@chromium.org,jeffyoon@chromium.org

Change-Id: I94597d58417f7aa76320579ca282293e6b643811
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 816629
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364014Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799629}
parent 2dfcb48f
...@@ -40,23 +40,22 @@ template("ios_test_runner_wrapper") { ...@@ -40,23 +40,22 @@ template("ios_test_runner_wrapper") {
generate_wrapper(target_name) { generate_wrapper(target_name) {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"data",
"data_deps",
"deps", "deps",
"executable_args",
"retries", "retries",
"shards", "shards",
"wrapper_output_name", "wrapper_output_name",
]) ])
testonly = true testonly = true
executable = "//testing/test_env.py"
# iOS main test runner # iOS main test runner
_runner_path = executable = "//ios/build/bots/scripts/run.py"
rebase_path("//ios/build/bots/scripts/run.py", root_build_dir)
executable_args = [ "@WrappedPath(${_runner_path})" ]
# arguments passed to run.py # arguments passed to run.py
if (defined(invoker.executable_args)) { if (!defined(executable_args)) {
executable_args += invoker.executable_args executable_args = []
} }
_rebased_mac_toolchain = rebase_path("//mac_toolchain", root_build_dir) _rebased_mac_toolchain = rebase_path("//mac_toolchain", root_build_dir)
...@@ -89,14 +88,12 @@ template("ios_test_runner_wrapper") { ...@@ -89,14 +88,12 @@ template("ios_test_runner_wrapper") {
"${shards}", "${shards}",
] ]
data_deps = []
if (defined(invoker.data_deps)) {
data_deps += invoker.data_deps
}
# test runner relies on iossim if use_ios_simulator (defined in ios_sdk.gni) # test runner relies on iossim if use_ios_simulator (defined in ios_sdk.gni)
if (use_ios_simulator) { if (use_ios_simulator) {
_rebased_root_build_dir = rebase_path("${root_build_dir}", root_build_dir) _rebased_root_build_dir = rebase_path("${root_build_dir}", root_build_dir)
if (!defined(data_deps)) {
data_deps = []
}
data_deps += [ "//testing/iossim" ] data_deps += [ "//testing/iossim" ]
executable_args += [ executable_args += [
...@@ -126,13 +123,10 @@ template("ios_test_runner_wrapper") { ...@@ -126,13 +123,10 @@ template("ios_test_runner_wrapper") {
# to ensure those wrappers are distinct. # to ensure those wrappers are distinct.
wrapper_script = "${root_out_dir}/bin/${_wrapper_output_name}" wrapper_script = "${root_out_dir}/bin/${_wrapper_output_name}"
data = [] # ios/build/bot/scripts/*.py needs to be present for test runner
if (defined(invoker.data)) { if (!defined(data)) {
data += invoker.data data = []
} }
data += [ data += [ "//ios/build/bots/scripts/" ]
"//.vpython",
"//ios/build/bots/scripts/",
]
} }
} }
...@@ -52,6 +52,17 @@ ...@@ -52,6 +52,17 @@
# : (the default), which indicates that we don't know what the command line # : (the default), which indicates that we don't know what the command line
# needs to be (this is a fatal error). # needs to be (this is a fatal error).
# TODO(crbug.com/816629): You may also set the type field to "wrapped_" +
# one of the above values; doing so indicates that the target conforms to
# the test wrapper API: for a given label //X:Y and build directory Z,
# there will be either a "Z/bin/run_Y" bash script (on Unix systems) or a
# "Z/bin/run_Y.bat" batch script (on Windows) that can be invoked directly
# to run the target in a swarming task, and "Z/Y.runtime_deps" file that
# contains the list of files and directories needed to run the task, in
# the format that GN uses with write_runtime_deps: a newline-separated list
# of files and directories relative to Z. Ultimately every target will
# be converted to this format, and this entire file will be deleted.
#
# The optional "executable" field can be used to override the name # The optional "executable" field can be used to override the name
# of the binary to run. If the field is not specified, the binary # of the binary to run. If the field is not specified, the binary
# name will be assumed to be the same as the ninja build target name. # name will be assumed to be the same as the ninja build target name.
...@@ -1736,7 +1747,7 @@ ...@@ -1736,7 +1747,7 @@
}, },
"url_unittests": { "url_unittests": {
"label": "//url:url_unittests", "label": "//url:url_unittests",
"type": "console_test_launcher", "type": "wrapped_console_test_launcher",
}, },
"usage_time_limit_unittests": { "usage_time_limit_unittests": {
"label": "//chrome/test:usage_time_limit_unittests", "label": "//chrome/test:usage_time_limit_unittests",
......
...@@ -1149,19 +1149,25 @@ class MetaBuildWrapper(object): ...@@ -1149,19 +1149,25 @@ class MetaBuildWrapper(object):
command, extra_files = self.GetIsolateCommand(target, vals) command, extra_files = self.GetIsolateCommand(target, vals)
# Any warning for an unused arg will get interleaved into the cmd's # TODO(crbug.com/816629): Convert everything to wrapped_isolated_scripts
# stdout. When that happens, the isolate step below will fail with an # and remove the else-branch of this.
# obscure error when it tries processing the lines of the warning. Fail if isolate_map[target]['type'] == 'wrapped_console_launcher':
# quickly in that case to avoid confusion runtime_deps = self.ReadFile(
cmd = self.GNCmd('desc', build_dir, label, 'runtime_deps', self.PathJoin(build_dir, target + '.runtime_deps')).splitlines()
'--fail-on-unused-args') else:
ret, out, _ = self.Call(cmd) # Any warning for an unused arg will get interleaved into the cmd's
if ret: # stdout. When that happens, the isolate step below will fail with an
if out: # obscure error when it tries processing the lines of the warning. Fail
self.Print(out) # quickly in that case to avoid confusion
return ret cmd = self.GNCmd('desc', build_dir, label, 'runtime_deps',
'--fail-on-unused-args')
ret, out, _ = self.Call(cmd)
if ret:
if out:
self.Print(out)
return ret
runtime_deps = out.splitlines() runtime_deps = out.splitlines()
ret = self.WriteIsolateFiles(build_dir, command, target, runtime_deps, vals, ret = self.WriteIsolateFiles(build_dir, command, target, runtime_deps, vals,
extra_files) extra_files)
...@@ -1367,26 +1373,25 @@ class MetaBuildWrapper(object): ...@@ -1367,26 +1373,25 @@ class MetaBuildWrapper(object):
or 'is_chromeos_device=true' in vals['gn_args']) or 'is_chromeos_device=true' in vals['gn_args'])
is_cros_device = 'is_chromeos_device=true' in vals['gn_args'] is_cros_device = 'is_chromeos_device=true' in vals['gn_args']
is_ios = 'target_os="ios"' in vals['gn_args'] is_ios = 'target_os="ios"' in vals['gn_args']
is_linux = ('target_os="linux"' in vals['gn_args']
or (self.platform in ('linux', 'linux2') and not is_android
and not is_fuchsia and not is_cros))
is_mac = self.platform == 'darwin' and not is_ios is_mac = self.platform == 'darwin' and not is_ios
is_win = self.platform == 'win32' or 'target_os="win"' in vals['gn_args'] is_win = self.platform == 'win32' or 'target_os="win"' in vals['gn_args']
is_lacros = 'chromeos_is_browser_only=true' in vals['gn_args'] is_lacros = 'chromeos_is_browser_only=true' in vals['gn_args']
test_type = isolate_map[target]['type'] test_type = isolate_map[target]['type']
if test_type.startswith('wrapped_') or is_lacros:
if is_mac or is_linux or is_lacros:
cmdline = ['bin/run_{}'.format(target)]
return cmdline, []
elif is_win:
cmdline = ['bin/run_{}.bat'.format(target)]
return cmdline, []
else:
test_type = test_type[len('wrapped_'):]
if self.use_luci_auth: # TODO(crbug.com/816629): Convert everything to wrapped_isolated_scripts
cmdline = ['luci-auth.exe' if is_win else 'luci-auth', 'context', '--']
else:
cmdline = []
if test_type == 'generated_script' or is_ios or is_lacros:
script = isolate_map[target].get('script', 'bin/run_{}'.format(target))
if is_win:
script += '.bat'
cmdline += [script]
return cmdline, []
# TODO(crbug.com/816629): Convert all targets to generated_scripts
# and delete the rest of this function. # and delete the rest of this function.
# This should be true if tests with type='windowed_test_launcher' are # This should be true if tests with type='windowed_test_launcher' are
...@@ -1407,16 +1412,49 @@ class MetaBuildWrapper(object): ...@@ -1407,16 +1412,49 @@ class MetaBuildWrapper(object):
clang_coverage = 'use_clang_coverage=true' in vals['gn_args'] clang_coverage = 'use_clang_coverage=true' in vals['gn_args']
java_coverage = 'use_jacoco_coverage=true' in vals['gn_args'] java_coverage = 'use_jacoco_coverage=true' in vals['gn_args']
use_python3 = isolate_map[target].get('use_python3', False)
executable = isolate_map[target].get('executable', target) executable = isolate_map[target].get('executable', target)
executable_suffix = isolate_map[target].get( executable_suffix = isolate_map[target].get(
'executable_suffix', '.exe' if is_win else '') 'executable_suffix', '.exe' if is_win else '')
cmdline += ['vpython']
extra_files = ['../../.vpython'] # TODO(crbug.com/1060857): Remove this once swarming task templates
# support command prefixes.
if self.use_luci_auth:
cmdline = ['luci-auth.exe' if is_win else 'luci-auth', 'context', '--']
else:
cmdline = []
if use_python3:
cmdline += ['vpython3']
extra_files = ['../../.vpython3']
else:
cmdline += ['vpython']
extra_files = ['../../.vpython']
extra_files += [ extra_files += [
'../../testing/test_env.py', '../../testing/test_env.py',
] ]
if is_android and test_type != 'script': if test_type == 'nontest':
self.WriteFailureAndRaise('We should not be isolating %s.' % target,
output_path=None)
if test_type == 'generated_script':
script = isolate_map[target]['script']
if self.platform == 'win32':
script += '.bat'
cmdline += [
'../../testing/test_env.py',
script,
]
elif is_ios and test_type != "raw":
# iOS commands are all wrapped with generate_wrapper. Some targets
# shared with iOS aren't defined with generated_script (ie/ basic_
# unittests) so we force those to follow iOS' execution process by
# mimicking what generated_script would do
script = 'bin/run_{}'.format(target)
cmdline += ['../../testing/test_env.py', script]
elif is_android and test_type != 'script':
if asan: if asan:
cmdline += [os.path.join('bin', 'run_with_asan'), '--'] cmdline += [os.path.join('bin', 'run_with_asan'), '--']
cmdline += [ cmdline += [
......
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