diff options
| -rwxr-xr-x | repo | 12 | ||||
| -rw-r--r-- | tests/test_wrapper.py | 11 |
2 files changed, 10 insertions, 13 deletions
| @@ -124,7 +124,7 @@ if not REPO_REV: | |||
| 124 | BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071" | 124 | BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071" |
| 125 | 125 | ||
| 126 | # increment this whenever we make important changes to this script | 126 | # increment this whenever we make important changes to this script |
| 127 | VERSION = (2, 50) | 127 | VERSION = (2, 54) |
| 128 | 128 | ||
| 129 | # increment this if the MAINTAINER_KEYS block is modified | 129 | # increment this if the MAINTAINER_KEYS block is modified |
| 130 | KEYRING_VERSION = (2, 3) | 130 | KEYRING_VERSION = (2, 3) |
| @@ -483,11 +483,6 @@ def InitParser(parser): | |||
| 483 | 483 | ||
| 484 | 484 | ||
| 485 | # This is a poor replacement for subprocess.run until we require Python 3.6+. | 485 | # 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 | |||
| 491 | class RunError(Exception): | 486 | class RunError(Exception): |
| 492 | """Error when running a command failed.""" | 487 | """Error when running a command failed.""" |
| 493 | 488 | ||
| @@ -526,7 +521,9 @@ def run_command(cmd, **kwargs): | |||
| 526 | elif stderr == subprocess.STDOUT: | 521 | elif stderr == subprocess.STDOUT: |
| 527 | dbg += " 2>&1" | 522 | dbg += " 2>&1" |
| 528 | trace.print(dbg) | 523 | 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 | ) | ||
| 530 | 527 | ||
| 531 | # If things failed, print useful debugging output. | 528 | # If things failed, print useful debugging output. |
| 532 | if check and ret.returncode: | 529 | if check and ret.returncode: |
| @@ -553,7 +550,6 @@ def run_command(cmd, **kwargs): | |||
| 553 | 550 | ||
| 554 | 551 | ||
| 555 | class CloneFailure(Exception): | 552 | class CloneFailure(Exception): |
| 556 | |||
| 557 | """Indicate the remote clone of repo itself failed.""" | 553 | """Indicate the remote clone of repo itself failed.""" |
| 558 | 554 | ||
| 559 | 555 | ||
diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index 8bebdf80..8bb5eb28 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | import io | 17 | import io |
| 18 | import os | 18 | import os |
| 19 | import re | 19 | import re |
| 20 | import subprocess | ||
| 20 | import sys | 21 | import sys |
| 21 | import tempfile | 22 | import tempfile |
| 22 | import unittest | 23 | import unittest |
| @@ -358,8 +359,8 @@ class VerifyRev(RepoWrapperTestCase): | |||
| 358 | 359 | ||
| 359 | def test_verify_passes(self): | 360 | def test_verify_passes(self): |
| 360 | """Check when we have a valid signed tag.""" | 361 | """Check when we have a valid signed tag.""" |
| 361 | desc_result = self.wrapper.RunResult(0, "v1.0\n", "") | 362 | desc_result = subprocess.CompletedProcess([], 0, "v1.0\n", "") |
| 362 | gpg_result = self.wrapper.RunResult(0, "", "") | 363 | gpg_result = subprocess.CompletedProcess([], 0, "", "") |
| 363 | with mock.patch.object( | 364 | with mock.patch.object( |
| 364 | self.wrapper, "run_git", side_effect=(desc_result, gpg_result) | 365 | self.wrapper, "run_git", side_effect=(desc_result, gpg_result) |
| 365 | ): | 366 | ): |
| @@ -370,8 +371,8 @@ class VerifyRev(RepoWrapperTestCase): | |||
| 370 | 371 | ||
| 371 | def test_unsigned_commit(self): | 372 | def test_unsigned_commit(self): |
| 372 | """Check we fall back to signed tag when we have an unsigned commit.""" | 373 | """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 | desc_result = subprocess.CompletedProcess([], 0, "v1.0-10-g1234\n", "") |
| 374 | gpg_result = self.wrapper.RunResult(0, "", "") | 375 | gpg_result = subprocess.CompletedProcess([], 0, "", "") |
| 375 | with mock.patch.object( | 376 | with mock.patch.object( |
| 376 | self.wrapper, "run_git", side_effect=(desc_result, gpg_result) | 377 | self.wrapper, "run_git", side_effect=(desc_result, gpg_result) |
| 377 | ): | 378 | ): |
| @@ -382,7 +383,7 @@ class VerifyRev(RepoWrapperTestCase): | |||
| 382 | 383 | ||
| 383 | def test_verify_fails(self): | 384 | def test_verify_fails(self): |
| 384 | """Check we fall back to signed tag when we have an unsigned commit.""" | 385 | """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", "") |
| 386 | gpg_result = Exception | 387 | gpg_result = Exception |
| 387 | with mock.patch.object( | 388 | with mock.patch.object( |
| 388 | self.wrapper, "run_git", side_effect=(desc_result, gpg_result) | 389 | self.wrapper, "run_git", side_effect=(desc_result, gpg_result) |
