summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-16 15:09:41 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-16 19:28:03 -0500
commitd212cdfa6e07abb83e527dcd99d5f6638be942ea (patch)
treeeef1ac4b2b3af5d2530e317c11aa4074b229e914
parentd34a4fd17028e87d5b9402e59e84b803aa475635 (diff)
downloadbuildstream-tristan/error-message-regression.tar.gz
sandbox/sandbox.py: Display failed commands in the detail stringtristan/error-message-regression
We should only display commands in detail strings, not in the message texts. This also updates tests/integration/sandbox-bwrap.py to expect the new message string which only contains the command exit status and not the whole command itself, this does not alter the validity of the text case which is checking that we can obtain the expected return value.
-rw-r--r--buildstream/_exceptions.py4
-rw-r--r--buildstream/sandbox/sandbox.py9
-rw-r--r--tests/integration/sandbox-bwrap.py2
3 files changed, 8 insertions, 7 deletions
diff --git a/buildstream/_exceptions.py b/buildstream/_exceptions.py
index ea5ea62f2..6d8ea6d38 100644
--- a/buildstream/_exceptions.py
+++ b/buildstream/_exceptions.py
@@ -262,8 +262,8 @@ class PlatformError(BstError):
# Raised when errors are encountered by the sandbox implementation
#
class SandboxError(BstError):
- def __init__(self, message, reason=None):
- super().__init__(message, domain=ErrorDomain.SANDBOX, reason=reason)
+ def __init__(self, message, detail=None, reason=None):
+ super().__init__(message, detail=detail, domain=ErrorDomain.SANDBOX, reason=reason)
# ArtifactError
diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py
index 4a1e81008..cb6f43314 100644
--- a/buildstream/sandbox/sandbox.py
+++ b/buildstream/sandbox/sandbox.py
@@ -86,10 +86,11 @@ class SandboxCommandError(SandboxError):
Args:
message (str): The error message to report to the user
+ detail (str): The detailed error string
collect (str): An optional directory containing partial install contents
"""
- def __init__(self, message, *, collect=None):
- super().__init__(message, reason='command-failed')
+ def __init__(self, message, *, detail=None, collect=None):
+ super().__init__(message, detail=detail, reason='command-failed')
self.collect = collect
@@ -599,8 +600,8 @@ class _SandboxBatch():
if exitcode != 0:
cmdline = ' '.join(shlex.quote(cmd) for cmd in command.command)
label = command.label or cmdline
- raise SandboxCommandError("Command '{}' failed with exitcode {}".format(label, exitcode),
- collect=self.collect)
+ raise SandboxCommandError("Command failed with exitcode {}".format(exitcode),
+ detail=label, collect=self.collect)
def execute_call(self, call):
call.callback()
diff --git a/tests/integration/sandbox-bwrap.py b/tests/integration/sandbox-bwrap.py
index b77709c35..66e9f5b57 100644
--- a/tests/integration/sandbox-bwrap.py
+++ b/tests/integration/sandbox-bwrap.py
@@ -59,4 +59,4 @@ def test_sandbox_bwrap_return_subprocess(cli, tmpdir, datafiles):
result = cli.run(project=project, args=['build', element_name])
result.assert_task_error(error_domain=ErrorDomain.SANDBOX, error_reason="command-failed")
- assert "sandbox-bwrap/command-exit-42.bst|Command 'exit 42' failed with exitcode 42" in result.stderr
+ assert "sandbox-bwrap/command-exit-42.bst|Command failed with exitcode 42" in result.stderr