aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gbp/command_wrappers.py2
-rw-r--r--gbp/pkg/pristinetar.py4
-rw-r--r--gbp/rpm/__init__.py2
-rw-r--r--tests/21_test_command_wrappers.py15
4 files changed, 20 insertions, 3 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index e16c1080..f4b00b89 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -140,8 +140,10 @@ class Command(object):
"""
stdout = self.stdout.rstrip() if self.stdout else self.stdout
stderr = self.stderr.rstrip() if self.stderr else self.stderr
+ stderr_or_reason = self.stderr.rstrip() if self.stderr else self.err_reason
return self.run_error.format(stdout=stdout,
stderr=stderr,
+ stderr_or_reason=stderr_or_reason,
err_reason=self.err_reason)
def __call__(self, args=[], quiet=False):
diff --git a/gbp/pkg/pristinetar.py b/gbp/pkg/pristinetar.py
index ac24998f..79e1334e 100644
--- a/gbp/pkg/pristinetar.py
+++ b/gbp/pkg/pristinetar.py
@@ -64,7 +64,7 @@ class PristineTar(Command):
@param archive: the name of the orig archive
@type archive: C{str}
"""
- self.run_error = 'Pristine-tar couldn\'t checkout "%s": {stderr}' % os.path.basename(archive)
+ self.run_error = 'Pristine-tar couldn\'t checkout "%s": {stderr_or_reason}' % os.path.basename(archive)
self.__call__(['checkout', archive])
def commit(self, archive, upstream):
@@ -77,6 +77,6 @@ class PristineTar(Command):
@param upstream: the upstream branch to diff against
@type upstream: C{str}
"""
- self.run_error = ("Couldn't commit to '%s' with upstream '%s': {stderr}" %
+ self.run_error = ("Couldn't commit to '%s' with upstream '%s': {stderr_or_reason}" %
(self.branch, upstream))
self.__call__(['commit', archive, upstream])
diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py
index 119d55ed..5a9a6688 100644
--- a/gbp/rpm/__init__.py
+++ b/gbp/rpm/__init__.py
@@ -99,7 +99,7 @@ class SrcRpmFile(object):
c = gbpc.RunAtCommand('rpm2cpio',
[self.srpmfile, '|', 'cpio', '-id'],
shell=True, capture_stderr=True)
- c.run_error = "'%s' failed: {stderr}" % (" ".join([c.cmd] + c.args))
+ c.run_error = "'%s' failed: {stderr_or_reason}" % (" ".join([c.cmd] + c.args))
c(dir=dest_dir)
diff --git a/tests/21_test_command_wrappers.py b/tests/21_test_command_wrappers.py
index 4dfbb48e..fd442c82 100644
--- a/tests/21_test_command_wrappers.py
+++ b/tests/21_test_command_wrappers.py
@@ -63,6 +63,21 @@ class TestCommandWrapperFailures(unittest.TestCase, GbpLogTester):
self.assertEqual(self.false.stderr, '')
self.assertEqual(self.false.stdout, 'we have a problem')
+ def test_log_use_err_or_reason_for_error_messge_reason(self):
+ self.false.run_error = "AFAIK {stderr_or_reason}"
+ with self.assertRaises(CommandExecFailed):
+ self.false.__call__()
+ self.log_tester._check_log(0, "gbp:error: AFAIK execution failed: .Errno 2. No such file or directory")
+ self.assertEqual(self.false.retcode, 1)
+
+ @patch_popen(stderr='we have a problem', returncode=1)
+ def test_log_use_err_or_reason_for_error_messge_error(self, create_mock):
+ self.false.run_error = "Erpel {stderr_or_reason}"
+ with self.assertRaises(CommandExecFailed):
+ self.false.__call__()
+ self.log_tester._check_log(0, "gbp:error: Erpel we have a problem")
+ self.assertEqual(self.false.retcode, 1)
+
@patch_popen(returncode=0)
def test_no_log_on_success(self, create_mock):
self.false.__call__()