aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2023-07-26 09:49:35 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-07-28 19:23:44 +0000
commit8a149c1f04e941d409e0f51ee3f79760332b5a79 (patch)
tree087007464d973773206c215917566ec159bb7485
parent556a8da985ea1f68e124312538afe0ac59fd714a (diff)
downloadtoolchain-utils-8a149c1f04e941d409e0f51ee3f79760332b5a79.tar.gz
llvm_tools: make update_packages_and_run_tests lint-clean
BUG=None TEST=Preuploads Change-Id: If98425f5a8bf18984f66f1873008f273821d8e18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/4720511 Auto-Submit: George Burgess <gbiv@chromium.org> Reviewed-by: Jordan Abrahams-Whitehead <ajordanr@google.com> Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com> Tested-by: George Burgess <gbiv@chromium.org>
-rwxr-xr-xllvm_tools/update_packages_and_run_tests.py97
1 files changed, 48 insertions, 49 deletions
diff --git a/llvm_tools/update_packages_and_run_tests.py b/llvm_tools/update_packages_and_run_tests.py
index c700b69f..598d9099 100755
--- a/llvm_tools/update_packages_and_run_tests.py
+++ b/llvm_tools/update_packages_and_run_tests.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
# Copyright 2019 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -27,10 +26,10 @@ def GetCommandLineArgs():
"""Parses the command line for the command line arguments.
Returns:
- The log level to use when retrieving the LLVM hash or google3 LLVM version,
- the chroot path to use for executing chroot commands,
- a list of a package or packages to update their LLVM next hash,
- and the LLVM version to use when retrieving the LLVM hash.
+ The log level to use when retrieving the LLVM hash or google3 LLVM
+ version, the chroot path to use for executing chroot commands,
+ a list of a package or packages to update their LLVM next hash,
+ and the LLVM version to use when retrieving the LLVM hash.
"""
# Default path to the chroot if a path is not specified.
@@ -68,8 +67,8 @@ def GetCommandLineArgs():
"Otherwise, update LLVM_HASH",
)
- # Add argument for the absolute path to the file that contains information on
- # the previous tested svn version.
+ # Add argument for the absolute path to the file that contains information
+ # on the previous tested svn version.
parser.add_argument(
"--last_tested",
help="the absolute path to the file that contains the last tested "
@@ -161,13 +160,13 @@ def UnchangedSinceLastRun(last_tested_file, arg_dict):
"""Gets the arguments used for last run
Args:
- last_tested_file: The absolute path to the file that contains the
- arguments for the last run.
- arg_dict: The arguments used for this run.
+ last_tested_file: The absolute path to the file that contains the
+ arguments for the last run.
+ arg_dict: The arguments used for this run.
Returns:
- Return true if the arguments used for last run exist and are the
- same as the arguments used for this run. Otherwise return false.
+ Return true if the arguments used for last run exist and are the
+ same as the arguments used for this run. Otherwise return false.
"""
if not last_tested_file:
@@ -176,7 +175,7 @@ def UnchangedSinceLastRun(last_tested_file, arg_dict):
# Get the last tested svn version if the file exists.
last_arg_dict = None
try:
- with open(last_tested_file) as f:
+ with open(last_tested_file, encoding="utf-8") as f:
last_arg_dict = json.load(f)
except (IOError, ValueError):
@@ -198,12 +197,12 @@ def AddReviewers(cl, reviewers, chroot_path):
def AddLinksToCL(tests, cl, chroot_path):
"""Adds the test link(s) to the CL as a comment."""
- # NOTE: Invoking `cros_sdk` does not make each tryjob link appear on its own
- # line, so invoking the `gerrit` command directly instead of using `cros_sdk`
- # to do it for us.
+ # NOTE: Invoking `cros_sdk` does not make each tryjob link appear on its
+ # own line, so invoking the `gerrit` command directly instead of using
+ # `cros_sdk` to do it for us.
#
- # FIXME: Need to figure out why `cros_sdk` does not add each tryjob link as a
- # newline.
+ # FIXME: Need to figure out why `cros_sdk` does not add each tryjob link as
+ # a newline.
gerrit_abs_path = os.path.join(chroot_path, "chromite/bin/gerrit")
links = ["Started the following tests:"]
@@ -224,15 +223,15 @@ def GetTryJobCommand(change_list, extra_change_lists, options, builder):
"""Constructs the 'tryjob' command.
Args:
- change_list: The CL obtained from updating the packages.
- extra_change_lists: Extra change lists that would like to be run alongside
- the change list of updating the packages.
- options: Options to be passed into the tryjob command.
- builder: The builder to be passed into the tryjob command.
+ change_list: The CL obtained from updating the packages.
+ extra_change_lists: Extra change lists that would like to be run
+ alongside the change list of updating the packages.
+ options: Options to be passed into the tryjob command.
+ builder: The builder to be passed into the tryjob command.
Returns:
- The 'tryjob' command with the change list of updating the packages and
- any extra information that was passed into the command line.
+ The 'tryjob' command with the change list of updating the packages and
+ any extra information that was passed into the command line.
"""
tryjob_cmd = ["cros", "tryjob", "--yes", "--json", "-g", "%d" % change_list]
@@ -253,20 +252,20 @@ def RunTryJobs(cl_number, extra_change_lists, options, builders, chroot_path):
"""Runs a tryjob/tryjobs.
Args:
- cl_number: The CL created by updating the packages.
- extra_change_lists: Any extra change lists that would run alongside the CL
- that was created by updating the packages ('cl_number').
- options: Any options to be passed into the 'tryjob' command.
- builders: All the builders to run the 'tryjob' with.
- chroot_path: The absolute path to the chroot.
+ cl_number: The CL created by updating the packages.
+ extra_change_lists: Any extra change lists that would run alongside the
+ CL that was created by updating the packages ('cl_number').
+ options: Any options to be passed into the 'tryjob' command.
+ builders: All the builders to run the 'tryjob' with.
+ chroot_path: The absolute path to the chroot.
Returns:
- A list that contains stdout contents of each tryjob, where stdout is
- information (a hashmap) about the tryjob. The hashmap also contains stderr
- if there was an error when running a tryjob.
+ A list that contains stdout contents of each tryjob, where stdout is
+ information (a hashmap) about the tryjob. The hashmap also contains
+ stderr if there was an error when running a tryjob.
Raises:
- ValueError: Failed to submit a tryjob.
+ ValueError: Failed to submit a tryjob.
"""
# Contains the results of each builder.
@@ -306,20 +305,20 @@ def StartRecipeBuilders(
"""Launch recipe builders.
Args:
- cl_number: The CL created by updating the packages.
- extra_change_lists: Any extra change lists that would run alongside the CL
- that was created by updating the packages ('cl_number').
- options: Any options to be passed into the 'tryjob' command.
- builders: All the builders to run the 'tryjob' with.
- chroot_path: The absolute path to the chroot.
+ cl_number: The CL created by updating the packages.
+ extra_change_lists: Any extra change lists that would run alongside the
+ CL that was created by updating the packages ('cl_number').
+ options: Any options to be passed into the 'tryjob' command.
+ builders: All the builders to run the 'tryjob' with.
+ chroot_path: The absolute path to the chroot.
Returns:
- A list that contains stdout contents of each builder, where stdout is
- information (a hashmap) about the tryjob. The hashmap also contains stderr
- if there was an error when running a tryjob.
+ A list that contains stdout contents of each builder, where stdout is
+ information (a hashmap) about the tryjob. The hashmap also contains
+ stderr if there was an error when running a tryjob.
Raises:
- ValueError: Failed to start a builder.
+ ValueError: Failed to start a builder.
"""
# Contains the results of each builder.
@@ -408,7 +407,7 @@ def main():
"""Updates the packages' LLVM hash and run tests.
Raises:
- AssertionError: The script was run inside the chroot.
+ AssertionError: The script was run inside the chroot.
"""
chroot.VerifyOutsideChroot()
@@ -423,8 +422,8 @@ def main():
svn_option
)
- # There is no need to run tryjobs when all the key parameters remain unchanged
- # from last time.
+ # There is no need to run tryjobs when all the key parameters remain
+ # unchanged from last time.
# If --last_tested is specified, check if the current run has the same
# arguments last time --last_tested is used.
@@ -511,7 +510,7 @@ def main():
# If --last_tested is specified, record the arguments used
if args_output.last_tested:
- with open(args_output.last_tested, "w") as f:
+ with open(args_output.last_tested, "w", encoding="utf-8") as f:
json.dump(arg_dict, f, indent=2)