aboutsummaryrefslogtreecommitdiff
path: root/llvm_tools/modify_a_tryjob.py
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_tools/modify_a_tryjob.py')
-rwxr-xr-xllvm_tools/modify_a_tryjob.py51
1 files changed, 25 insertions, 26 deletions
diff --git a/llvm_tools/modify_a_tryjob.py b/llvm_tools/modify_a_tryjob.py
index 03de606d..2ecca800 100755
--- a/llvm_tools/modify_a_tryjob.py
+++ b/llvm_tools/modify_a_tryjob.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.
@@ -11,6 +10,7 @@ import argparse
import enum
import json
import os
+from pathlib import Path
import sys
import chroot
@@ -45,11 +45,12 @@ def GetCommandLineArgs():
parser.add_argument(
"--status_file",
required=True,
- help="The absolute path to the JSON file that contains the tryjobs used "
- "for bisecting LLVM.",
+ help="The absolute path to the JSON file that contains the tryjobs "
+ "used for bisecting LLVM.",
)
- # Add argument that determines what action to take on the revision specified.
+ # Add argument that determines what action to take on the revision
+ # specified.
parser.add_argument(
"--modify_tryjob",
required=True,
@@ -66,7 +67,8 @@ def GetCommandLineArgs():
help="The revision to either remove or relaunch.",
)
- # Add argument for other change lists that want to run alongside the tryjob.
+ # Add argument for other change lists that want to run alongside the
+ # tryjob.
parser.add_argument(
"--extra_change_lists",
type=int,
@@ -134,7 +136,6 @@ def GetCLAfterUpdatingPackages(
git_hash,
svn_version,
chroot_path,
- patch_metadata_file,
svn_option,
):
"""Updates the packages' LLVM_NEXT."""
@@ -145,7 +146,7 @@ def GetCLAfterUpdatingPackages(
llvm_variant=update_chromeos_llvm_hash.LLVMVariant.next,
git_hash=git_hash,
svn_version=svn_version,
- chroot_path=chroot_path,
+ chroot_path=Path(chroot_path),
mode=failure_modes.FailureModes.DISABLE_PATCHES,
git_hash_source=svn_option,
extra_commit_msg=None,
@@ -196,7 +197,6 @@ def AddTryjob(
git_hash,
revision,
chroot_path,
- patch_metadata_file,
extra_cls,
options,
builder,
@@ -212,7 +212,6 @@ def AddTryjob(
git_hash,
revision,
chroot_path,
- patch_metadata_file,
svn_option,
)
@@ -242,16 +241,17 @@ def PerformTryjobModification(
"""Removes, relaunches, or adds a tryjob.
Args:
- revision: The revision associated with the tryjob.
- modify_tryjob: What action to take on the tryjob.
- Ex: ModifyTryjob.REMOVE, ModifyTryjob.RELAUNCH, ModifyTryjob.ADD
- status_file: The .JSON file that contains the tryjobs.
- extra_cls: Extra change lists to be run alongside tryjob
- options: Extra options to pass into 'cros tryjob'.
- builder: The builder to use for 'cros tryjob'.
- chroot_path: The absolute path to the chroot (used by 'cros tryjob' when
- relaunching a tryjob).
- verbose: Determines whether to print the contents of a command to `stdout`.
+ revision: The revision associated with the tryjob.
+ modify_tryjob: What action to take on the tryjob.
+ Ex: ModifyTryjob.REMOVE, ModifyTryjob.RELAUNCH, ModifyTryjob.ADD
+ status_file: The .JSON file that contains the tryjobs.
+ extra_cls: Extra change lists to be run alongside tryjob
+ options: Extra options to pass into 'cros tryjob'.
+ builder: The builder to use for 'cros tryjob'.
+ chroot_path: The absolute path to the chroot (used by 'cros tryjob'
+ when relaunching a tryjob).
+ verbose: Determines whether to print the contents of a command to
+ `stdout`.
"""
# Format of 'bisect_contents':
@@ -265,7 +265,7 @@ def PerformTryjobModification(
# {[TRYJOB_INFORMATION]}
# ]
# }
- with open(status_file) as tryjobs:
+ with open(status_file, encoding="utf-8") as tryjobs:
bisect_contents = json.load(tryjobs)
if not bisect_contents["jobs"] and modify_tryjob != ModifyTryjob.ADD:
@@ -318,12 +318,10 @@ def PerformTryjobModification(
% (tryjob_index, status_file)
)
- # Make sure the revision is within the bounds of the start and end of the
- # bisection.
+ # Make sure the revision is within the bounds of the start and end of
+ # the bisection.
elif bisect_contents["start"] < revision < bisect_contents["end"]:
- patch_metadata_file = "PATCHES.json"
-
(
git_hash,
revision,
@@ -334,7 +332,6 @@ def PerformTryjobModification(
git_hash,
revision,
chroot_path,
- patch_metadata_file,
extra_cls,
options,
builder,
@@ -352,7 +349,7 @@ def PerformTryjobModification(
'Invalid "modify_tryjob" option provided: %s' % modify_tryjob
)
- with open(status_file, "w") as update_tryjobs:
+ with open(status_file, "w", encoding="utf-8") as update_tryjobs:
json.dump(
bisect_contents, update_tryjobs, indent=4, separators=(",", ": ")
)
@@ -365,6 +362,8 @@ def main():
args_output = GetCommandLineArgs()
+ chroot.VerifyChromeOSRoot(args_output.chroot_path)
+
PerformTryjobModification(
args_output.revision,
ModifyTryjob(args_output.modify_tryjob),