Skip to content

Commit bfe2994

Browse files
authored
[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> ```
1 parent e177dd6 commit bfe2994

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@
172172
WATCHPOINT_CREATED = "Watchpoint created successfully"
173173

174174

175-
def CMD_MSG(str):
175+
def CMD_MSG(command):
176176
"""A generic "Command '%s' did not return successfully" message generator."""
177-
return "Command '%s' did not return successfully" % str
177+
return f"Command '{command}' did not return successfully"
178178

179179

180180
def COMPLETION_MSG(str_before, str_after, completions):
@@ -990,16 +990,14 @@ def runCmd(self, cmd, msg=None, check=True, trace=False, inHistory=False):
990990
print("Command '" + cmd + "' failed!", file=sbuf)
991991

992992
if check:
993+
if not msg:
994+
msg = CMD_MSG(cmd)
993995
output = ""
994996
if self.res.GetOutput():
995997
output += "\nCommand output:\n" + self.res.GetOutput()
996998
if self.res.GetError():
997999
output += "\nError output:\n" + self.res.GetError()
998-
if msg:
999-
msg += output
1000-
if cmd:
1001-
cmd += output
1002-
self.assertTrue(self.res.Succeeded(), msg if (msg) else CMD_MSG(cmd))
1000+
self.assertTrue(self.res.Succeeded(), msg + output)
10031001

10041002
def HideStdout(self):
10051003
"""Hide output to stdout from the user.

0 commit comments

Comments
 (0)