[Notes] [Git][BuildStream/buildstream][master] 2 commits: sandbox/sandbox.py: Display failed commands in the detail string



Title: GitLab

Tristan Van Berkom pushed to branch master at BuildStream / buildstream

Commits:

3 changed files:

Changes:

  • buildstream/_exceptions.py
    ... ... @@ -262,8 +262,8 @@ class PlatformError(BstError):
    262 262
     # Raised when errors are encountered by the sandbox implementation
    
    263 263
     #
    
    264 264
     class SandboxError(BstError):
    
    265
    -    def __init__(self, message, reason=None):
    
    266
    -        super().__init__(message, domain=ErrorDomain.SANDBOX, reason=reason)
    
    265
    +    def __init__(self, message, detail=None, reason=None):
    
    266
    +        super().__init__(message, detail=detail, domain=ErrorDomain.SANDBOX, reason=reason)
    
    267 267
     
    
    268 268
     
    
    269 269
     # ArtifactError
    

  • buildstream/sandbox/sandbox.py
    ... ... @@ -86,10 +86,11 @@ class SandboxCommandError(SandboxError):
    86 86
     
    
    87 87
         Args:
    
    88 88
            message (str): The error message to report to the user
    
    89
    +       detail (str): The detailed error string
    
    89 90
            collect (str): An optional directory containing partial install contents
    
    90 91
         """
    
    91
    -    def __init__(self, message, *, collect=None):
    
    92
    -        super().__init__(message, reason='command-failed')
    
    92
    +    def __init__(self, message, *, detail=None, collect=None):
    
    93
    +        super().__init__(message, detail=detail, reason='command-failed')
    
    93 94
     
    
    94 95
             self.collect = collect
    
    95 96
     
    
    ... ... @@ -599,8 +600,8 @@ class _SandboxBatch():
    599 600
             if exitcode != 0:
    
    600 601
                 cmdline = ' '.join(shlex.quote(cmd) for cmd in command.command)
    
    601 602
                 label = command.label or cmdline
    
    602
    -            raise SandboxCommandError("Command '{}' failed with exitcode {}".format(label, exitcode),
    
    603
    -                                      collect=self.collect)
    
    603
    +            raise SandboxCommandError("Command failed with exitcode {}".format(exitcode),
    
    604
    +                                      detail=label, collect=self.collect)
    
    604 605
     
    
    605 606
         def execute_call(self, call):
    
    606 607
             call.callback()
    

  • tests/integration/sandbox-bwrap.py
    ... ... @@ -59,4 +59,4 @@ def test_sandbox_bwrap_return_subprocess(cli, tmpdir, datafiles):
    59 59
     
    
    60 60
         result = cli.run(project=project, args=['build', element_name])
    
    61 61
         result.assert_task_error(error_domain=ErrorDomain.SANDBOX, error_reason="command-failed")
    
    62
    -    assert "sandbox-bwrap/command-exit-42.bst|Command 'exit 42' failed with exitcode 42" in result.stderr
    62
    +    assert "sandbox-bwrap/command-exit-42.bst|Command failed with exitcode 42" in result.stderr



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]