diff options
author | Bob Haarman <inglorion@chromium.org> | 2020-11-20 15:30:19 +0000 |
---|---|---|
committer | Bob Haarman <inglorion@chromium.org> | 2020-11-21 00:41:14 +0000 |
commit | 2c27f0a0c2dc4592643bfc1381f593f584a67a19 (patch) | |
tree | 50b00966018971ad14b0e0e511c2cb2d9c537fef | |
parent | 242137225162f36d6bcfb22608d8290ab99ad038 (diff) | |
download | toolchain-utils-2c27f0a0c2dc4592643bfc1381f593f584a67a19.tar.gz |
llvm_tools: pass cl number as str to avoid type error
llvm_bisection.py invokes the Gerrit CLI to abandon CLs created as part of the bisection. It passes a CL number to the command. Before this change, the CL number was passed as an int, which leads to the following error:
Traceback (most recent call last):
File "./auto_llvm_bisection.py", line 103, in main
bisection_ret = llvm_bisection.main(args_output)
File "/usr/local/google/home/inglorion/chromiumos/src/third_party/toolchain-utils/llvm_tools/llvm_bisection.py", line 364, in main
subprocess.check_output([gerrit, 'abandon', build['cl']],
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.8/subprocess.py", line 489, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1637, in _execute_child
self.pid = _posixsubprocess.fork_exec(
TypeError: expected str, bytes or os.PathLike object, not int
With this change, we convert the value to an str first, avoiding the type error.
BUG=chromium:1151325
TEST=run auto_llvm_bisection.py
Change-Id: I2b151c76757067f536712f69b14d6be549ee7c75
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2551789
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Jian Cai <jiancai@google.com>
Tested-by: Bob Haarman <inglorion@chromium.org>
-rwxr-xr-x | llvm_tools/llvm_bisection.py | 9 | ||||
-rwxr-xr-x | llvm_tools/llvm_bisection_unittest.py | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/llvm_tools/llvm_bisection.py b/llvm_tools/llvm_bisection.py index c8d694cd..b1898ea9 100755 --- a/llvm_tools/llvm_bisection.py +++ b/llvm_tools/llvm_bisection.py @@ -357,13 +357,14 @@ def main(args_output): print(skip_revisions_message) if args_output.cleanup: - # Abondon all the CLs created for bisection + # Abandon all the CLs created for bisection gerrit = os.path.join(args_output.chroot_path, 'chromite/bin/gerrit') for build in bisect_state['jobs']: try: - subprocess.check_output([gerrit, 'abandon', build['cl']], - stderr=subprocess.STDOUT, - encoding='utf-8') + subprocess.check_output( + [gerrit, 'abandon', str(build['cl'])], + stderr=subprocess.STDOUT, + encoding='utf-8') except subprocess.CalledProcessError as err: # the CL may have been abandoned if 'chromite.lib.gob_util.GOBError' not in err.output: diff --git a/llvm_tools/llvm_bisection_unittest.py b/llvm_tools/llvm_bisection_unittest.py index a40770a5..cc22dfa4 100755 --- a/llvm_tools/llvm_bisection_unittest.py +++ b/llvm_tools/llvm_bisection_unittest.py @@ -301,7 +301,7 @@ class LLVMBisectionTest(unittest.TestCase): [ os.path.join(args_output.chroot_path, 'chromite/bin/gerrit'), 'abandon', - cl, + str(cl), ], stderr=subprocess.STDOUT, encoding='utf-8', |