Commit ce91ce5d authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

Merge branch 'tristan/error-message-regression' into 'master'

sandbox/sandbox.py: Display failed commands in the detail string

See merge request BuildStream/buildstream!1081
parents d34a4fd1 d212cdfa
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -262,8 +262,8 @@ class PlatformError(BstError):
# Raised when errors are encountered by the sandbox implementation
# Raised when errors are encountered by the sandbox implementation
#
#
class SandboxError(BstError):
class SandboxError(BstError):
    def __init__(self, message, reason=None):
    def __init__(self, message, detail=None, reason=None):
        super().__init__(message, domain=ErrorDomain.SANDBOX, reason=reason)
        super().__init__(message, detail=detail, domain=ErrorDomain.SANDBOX, reason=reason)




# ArtifactError
# ArtifactError
+5 −4
Original line number Original line Diff line number Diff line
@@ -86,10 +86,11 @@ class SandboxCommandError(SandboxError):


    Args:
    Args:
       message (str): The error message to report to the user
       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
       collect (str): An optional directory containing partial install contents
    """
    """
    def __init__(self, message, *, collect=None):
    def __init__(self, message, *, detail=None, collect=None):
        super().__init__(message, reason='command-failed')
        super().__init__(message, detail=detail, reason='command-failed')


        self.collect = collect
        self.collect = collect


@@ -599,8 +600,8 @@ class _SandboxBatch():
        if exitcode != 0:
        if exitcode != 0:
            cmdline = ' '.join(shlex.quote(cmd) for cmd in command.command)
            cmdline = ' '.join(shlex.quote(cmd) for cmd in command.command)
            label = command.label or cmdline
            label = command.label or cmdline
            raise SandboxCommandError("Command '{}' failed with exitcode {}".format(label, exitcode),
            raise SandboxCommandError("Command failed with exitcode {}".format(exitcode),
                                      collect=self.collect)
                                      detail=label, collect=self.collect)


    def execute_call(self, call):
    def execute_call(self, call):
        call.callback()
        call.callback()
+1 −1
Original line number Original line Diff line number Diff line
@@ -59,4 +59,4 @@ def test_sandbox_bwrap_return_subprocess(cli, tmpdir, datafiles):


    result = cli.run(project=project, args=['build', element_name])
    result = cli.run(project=project, args=['build', element_name])
    result.assert_task_error(error_domain=ErrorDomain.SANDBOX, error_reason="command-failed")
    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