From e218c9814c3cc8d50a8cab23c2bb69061b3b9be9 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 30 Aug 2019 15:03:39 -0400 Subject: [PATCH] ansible-test - Continue if the git command returns an error (#61605) * ansible-test - Contiune if the git command returns an error * Just return stdout * Use to_text() when displaying exception * Add a message property to SubprocessError --- test/lib/ansible_test/_internal/git.py | 8 +++++++- test/lib/ansible_test/_internal/util.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/lib/ansible_test/_internal/git.py b/test/lib/ansible_test/_internal/git.py index b7bb3339e93..31eef59eb5a 100644 --- a/test/lib/ansible_test/_internal/git.py +++ b/test/lib/ansible_test/_internal/git.py @@ -8,7 +8,9 @@ from . import types as t from .util import ( SubprocessError, + display, raw_command, + to_text, ) @@ -124,4 +126,8 @@ class Git: :type str_errors: str :rtype: str """ - return raw_command([self.git] + cmd, cwd=self.root, capture=True, str_errors=str_errors)[0] + try: + return raw_command([self.git] + cmd, cwd=self.root, capture=True, str_errors=str_errors)[0] + except SubprocessError as spe: + display.warning(to_text(spe.message)) + return spe.stdout diff --git a/test/lib/ansible_test/_internal/util.py b/test/lib/ansible_test/_internal/util.py index fce04ad0af1..e8488498515 100644 --- a/test/lib/ansible_test/_internal/util.py +++ b/test/lib/ansible_test/_internal/util.py @@ -754,6 +754,7 @@ class SubprocessError(ApplicationError): super(SubprocessError, self).__init__(message) self.cmd = cmd + self.message = message self.status = status self.stdout = stdout self.stderr = stderr