aboutsummaryrefslogtreecommitdiff
path: root/llvm_tools/auto_llvm_bisection.py
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_tools/auto_llvm_bisection.py')
-rwxr-xr-xllvm_tools/auto_llvm_bisection.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/llvm_tools/auto_llvm_bisection.py b/llvm_tools/auto_llvm_bisection.py
index 3640abae..9b4b8559 100755
--- a/llvm_tools/auto_llvm_bisection.py
+++ b/llvm_tools/auto_llvm_bisection.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.
@@ -49,10 +48,15 @@ class BuilderStatus(enum.Enum):
RUNNING = "running"
+# Writing a dict with `.value`s spelled out makes `black`'s style conflict with
+# `cros lint`'s diagnostics.
builder_status_mapping = {
- BuilderStatus.PASS.value: update_tryjob_status.TryjobStatus.GOOD.value,
- BuilderStatus.FAIL.value: update_tryjob_status.TryjobStatus.BAD.value,
- BuilderStatus.RUNNING.value: update_tryjob_status.TryjobStatus.PENDING.value,
+ a.value: b.value
+ for a, b in (
+ (BuilderStatus.PASS, update_tryjob_status.TryjobStatus.GOOD),
+ (BuilderStatus.FAIL, update_tryjob_status.TryjobStatus.BAD),
+ (BuilderStatus.RUNNING, update_tryjob_status.TryjobStatus.PENDING),
+ )
}
@@ -63,8 +67,6 @@ def GetBuildResult(chroot_path, buildbucket_id):
try:
tryjob_json = subprocess.check_output(
[
- "cros_sdk",
- "--",
"cros",
"buildresult",
"--buildbucket-id",
@@ -98,13 +100,15 @@ def main():
"""Bisects LLVM using the result of `cros buildresult` of each tryjob.
Raises:
- AssertionError: The script was run inside the chroot.
+ AssertionError: The script was run inside the chroot.
"""
chroot.VerifyOutsideChroot()
args_output = llvm_bisection.GetCommandLineArgs()
+ chroot.VerifyChromeOSRoot(args_output.chroot_path)
+
if os.path.isfile(args_output.last_tested):
print("Resuming bisection for %s" % args_output.last_tested)
else:
@@ -114,7 +118,7 @@ def main():
# Update the status of existing tryjobs
if os.path.isfile(args_output.last_tested):
update_start_time = time.time()
- with open(args_output.last_tested) as json_file:
+ with open(args_output.last_tested, encoding="utf-8") as json_file:
json_dict = json.load(json_file)
while True:
print(
@@ -139,15 +143,16 @@ def main():
print("-" * 40)
- # Proceed to the next step if all the existing tryjobs have completed.
+ # Proceed to the next step if all the existing tryjobs have
+ # completed.
if completed:
break
delta_time = time.time() - update_start_time
if delta_time > POLLING_LIMIT_SECS:
- # Something is wrong with updating the tryjobs's 'status' via
- # `cros buildresult` (e.g. network issue, etc.).
+ # Something is wrong with updating the tryjobs's 'status'
+ # via `cros buildresult` (e.g. network issue, etc.).
sys.exit("Failed to update pending tryjobs.")
print("-" * 40)
@@ -157,7 +162,7 @@ def main():
# There should always be update from the tryjobs launched in the
# last iteration.
temp_filename = "%s.new" % args_output.last_tested
- with open(temp_filename, "w") as temp_file:
+ with open(temp_filename, "w", encoding="utf-8") as temp_file:
json.dump(
json_dict, temp_file, indent=4, separators=(",", ": ")
)