Skip to content

Commit 243df20

Browse files
vapierLUCI
authored andcommitted
launcher: change RunResult to subprocess.CompletedProcess
Since we require Python 3.6 now in the launcher, swap out our custom RunResult class for the standard subprocess one. Change-Id: Idd8598df37c0a952d3ef828df6e250cab03c6589 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/462341 Reviewed-by: Gavin Mak <[email protected]> Tested-by: Mike Frysinger <[email protected]> Commit-Queue: Mike Frysinger <[email protected]>
1 parent 4b94e77 commit 243df20

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

repo

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ if not REPO_REV:
124124
BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071"
125125

126126
# increment this whenever we make important changes to this script
127-
VERSION = (2, 50)
127+
VERSION = (2, 54)
128128

129129
# increment this if the MAINTAINER_KEYS block is modified
130130
KEYRING_VERSION = (2, 3)
@@ -483,11 +483,6 @@ def InitParser(parser):
483483

484484

485485
# This is a poor replacement for subprocess.run until we require Python 3.6+.
486-
RunResult = collections.namedtuple(
487-
"RunResult", ("returncode", "stdout", "stderr")
488-
)
489-
490-
491486
class RunError(Exception):
492487
"""Error when running a command failed."""
493488

@@ -526,7 +521,9 @@ def run_command(cmd, **kwargs):
526521
elif stderr == subprocess.STDOUT:
527522
dbg += " 2>&1"
528523
trace.print(dbg)
529-
ret = RunResult(proc.returncode, decode(stdout), decode(stderr))
524+
ret = subprocess.CompletedProcess(
525+
cmd, proc.returncode, decode(stdout), decode(stderr)
526+
)
530527

531528
# If things failed, print useful debugging output.
532529
if check and ret.returncode:
@@ -553,7 +550,6 @@ def run_command(cmd, **kwargs):
553550

554551

555552
class CloneFailure(Exception):
556-
557553
"""Indicate the remote clone of repo itself failed."""
558554

559555

tests/test_wrapper.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io
1818
import os
1919
import re
20+
import subprocess
2021
import sys
2122
import tempfile
2223
import unittest
@@ -358,8 +359,8 @@ class VerifyRev(RepoWrapperTestCase):
358359

359360
def test_verify_passes(self):
360361
"""Check when we have a valid signed tag."""
361-
desc_result = self.wrapper.RunResult(0, "v1.0\n", "")
362-
gpg_result = self.wrapper.RunResult(0, "", "")
362+
desc_result = subprocess.CompletedProcess([], 0, "v1.0\n", "")
363+
gpg_result = subprocess.CompletedProcess([], 0, "", "")
363364
with mock.patch.object(
364365
self.wrapper, "run_git", side_effect=(desc_result, gpg_result)
365366
):
@@ -370,8 +371,8 @@ def test_verify_passes(self):
370371

371372
def test_unsigned_commit(self):
372373
"""Check we fall back to signed tag when we have an unsigned commit."""
373-
desc_result = self.wrapper.RunResult(0, "v1.0-10-g1234\n", "")
374-
gpg_result = self.wrapper.RunResult(0, "", "")
374+
desc_result = subprocess.CompletedProcess([], 0, "v1.0-10-g1234\n", "")
375+
gpg_result = subprocess.CompletedProcess([], 0, "", "")
375376
with mock.patch.object(
376377
self.wrapper, "run_git", side_effect=(desc_result, gpg_result)
377378
):
@@ -382,7 +383,7 @@ def test_unsigned_commit(self):
382383

383384
def test_verify_fails(self):
384385
"""Check we fall back to signed tag when we have an unsigned commit."""
385-
desc_result = self.wrapper.RunResult(0, "v1.0-10-g1234\n", "")
386+
desc_result = subprocess.CompletedProcess([], 0, "v1.0-10-g1234\n", "")
386387
gpg_result = Exception
387388
with mock.patch.object(
388389
self.wrapper, "run_git", side_effect=(desc_result, gpg_result)

0 commit comments

Comments
 (0)