diff options
author | Dave Lee <davelee.com@gmail.com> | 2024-09-26 13:39:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-26 13:39:54 -0700 |
commit | bfe29945603e2040cc56d9e30f05da0627c819cd (patch) | |
tree | f9282171b7263f1f8168ee6dcf442e9f10dfe8f1 /lldb/packages/Python/lldbsuite/test/lldbtest.py | |
parent | e177dd6fbbfa998751fafdeb445b83d1b0c04fbc (diff) | |
download | llvm-bfe29945603e2040cc56d9e30f05da0627c819cd.zip llvm-bfe29945603e2040cc56d9e30f05da0627c819cd.tar.gz llvm-bfe29945603e2040cc56d9e30f05da0627c819cd.tar.bz2 |
[lldb] Fix minor runCmd error message formatting (#110150)
This tweaks the construction of the error message when using `expect`/`runCmd`. With
this change, the stdout/stderr is placed after the message "Command '<command>' did not
return successfully".
Before:
```
AssertionError: False is not True : Command 'p whatever
Error output:
error: <some error message>
' did not return successfully
```
After:
```
AssertionError: False is not True : Command 'p whatever' did not return successfully
Error output:
error: <some error message>
```
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbtest.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lldbtest.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index c6b7ce8..8884ef5 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -172,9 +172,9 @@ VARIABLES_DISPLAYED_CORRECTLY = "Variable(s) displayed correctly" WATCHPOINT_CREATED = "Watchpoint created successfully" -def CMD_MSG(str): +def CMD_MSG(command): """A generic "Command '%s' did not return successfully" message generator.""" - return "Command '%s' did not return successfully" % str + return f"Command '{command}' did not return successfully" def COMPLETION_MSG(str_before, str_after, completions): @@ -990,16 +990,14 @@ class Base(unittest.TestCase): print("Command '" + cmd + "' failed!", file=sbuf) if check: + if not msg: + msg = CMD_MSG(cmd) output = "" if self.res.GetOutput(): output += "\nCommand output:\n" + self.res.GetOutput() if self.res.GetError(): output += "\nError output:\n" + self.res.GetError() - if msg: - msg += output - if cmd: - cmd += output - self.assertTrue(self.res.Succeeded(), msg if (msg) else CMD_MSG(cmd)) + self.assertTrue(self.res.Succeeded(), msg + output) def HideStdout(self): """Hide output to stdout from the user. |