diff options
| -rwxr-xr-x | repo | 13 | ||||
| -rw-r--r-- | tests/test_wrapper.py | 2 |
2 files changed, 6 insertions, 9 deletions
| @@ -482,11 +482,6 @@ def InitParser(parser): | |||
| 482 | return parser | 482 | return parser |
| 483 | 483 | ||
| 484 | 484 | ||
| 485 | # This is a poor replacement for subprocess.run until we require Python 3.6+. | ||
| 486 | class RunError(Exception): | ||
| 487 | """Error when running a command failed.""" | ||
| 488 | |||
| 489 | |||
| 490 | def run_command(cmd, **kwargs): | 485 | def run_command(cmd, **kwargs): |
| 491 | """Run |cmd| and return its output.""" | 486 | """Run |cmd| and return its output.""" |
| 492 | check = kwargs.pop("check", False) | 487 | check = kwargs.pop("check", False) |
| @@ -544,7 +539,8 @@ def run_command(cmd, **kwargs): | |||
| 544 | 539 | ||
| 545 | _print_output("stdout", ret.stdout) | 540 | _print_output("stdout", ret.stdout) |
| 546 | _print_output("stderr", ret.stderr) | 541 | _print_output("stderr", ret.stderr) |
| 547 | raise RunError(ret) | 542 | # This will raise subprocess.CalledProcessError for us. |
| 543 | ret.check_returncode() | ||
| 548 | 544 | ||
| 549 | return ret | 545 | return ret |
| 550 | 546 | ||
| @@ -668,7 +664,7 @@ def run_git(*args, **kwargs): | |||
| 668 | file=sys.stderr, | 664 | file=sys.stderr, |
| 669 | ) | 665 | ) |
| 670 | sys.exit(1) | 666 | sys.exit(1) |
| 671 | except RunError: | 667 | except subprocess.CalledProcessError: |
| 672 | raise CloneFailure() | 668 | raise CloneFailure() |
| 673 | 669 | ||
| 674 | 670 | ||
| @@ -850,7 +846,8 @@ def _GetRepoConfig(name): | |||
| 850 | f"repo: error: git {' '.join(cmd)} failed:\n{ret.stderr}", | 846 | f"repo: error: git {' '.join(cmd)} failed:\n{ret.stderr}", |
| 851 | file=sys.stderr, | 847 | file=sys.stderr, |
| 852 | ) | 848 | ) |
| 853 | raise RunError() | 849 | # This will raise subprocess.CalledProcessError for us. |
| 850 | ret.check_returncode() | ||
| 854 | 851 | ||
| 855 | 852 | ||
| 856 | def _InitHttp(): | 853 | def _InitHttp(): |
diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index 8bb5eb28..77ceda8f 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py | |||
| @@ -126,7 +126,7 @@ class RunCommand(RepoWrapperTestCase): | |||
| 126 | self.wrapper.run_command(["true"], check=False) | 126 | self.wrapper.run_command(["true"], check=False) |
| 127 | self.wrapper.run_command(["true"], check=True) | 127 | self.wrapper.run_command(["true"], check=True) |
| 128 | self.wrapper.run_command(["false"], check=False) | 128 | self.wrapper.run_command(["false"], check=False) |
| 129 | with self.assertRaises(self.wrapper.RunError): | 129 | with self.assertRaises(subprocess.CalledProcessError): |
| 130 | self.wrapper.run_command(["false"], check=True) | 130 | self.wrapper.run_command(["false"], check=True) |
| 131 | 131 | ||
| 132 | 132 | ||
