[Lldb-commits] [lldb] [lldb][test] Print command output when it unexpectedly passes (PR #224021)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 16 06:51:51 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Raphael Isemann (Teemperor)
<details>
<summary>Changes</summary>
Some LLDB tests expect commands to fail. However, we do sometimes see these commands actually pass on the bots and the test output doesn't really indicate what is going on.
This patch adds the (error) output of commands that we expected to fail but didn't do the test output. This changes the dreaded `Command 'foo' is expected to fail!` error to:
```
Command 'foo' is expected to fail!
Output: bar
```
---
Full diff: https://github.com/llvm/llvm-project/pull/224021.diff
1 Files Affected:
- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+10-7)
``````````diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index bec50f806110b..16d224d01fc2b 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2529,6 +2529,14 @@ def switch_to_thread_with_stop_reason(self, stop_reason):
if matched:
self.runCmd("thread select %s" % matched.group(1))
+ def _assert_command_failed(self, command, res):
+ fail_msg = "Command '" + command + "' is expected to fail!"
+ if res.GetOutput():
+ fail_msg += "\nOutput: " + res.GetOutput()
+ if res.GetError():
+ fail_msg += "\nError: " + res.GetError()
+ self.assertFalse(res.Succeeded(), fail_msg)
+
def match(
self, str, patterns, msg=None, trace=False, error=False, matching=True, exe=True
):
@@ -2550,9 +2558,7 @@ def match(
# If error is True, the API client expects the command to fail!
if error:
- self.assertFalse(
- self.res.Succeeded(), "Command '" + str + "' is expected to fail!"
- )
+ self._assert_command_failed(str, self.res)
else:
# No execution required, just compare str against the golden input.
output = str
@@ -2887,10 +2893,7 @@ def expect(
# If error is True, the API client expects the command to fail!
if error:
- self.assertFalse(
- self.res.Succeeded(),
- "Command '" + string + "' is expected to fail!",
- )
+ self._assert_command_failed(string, self.res)
else:
# No execution required, just compare string against the golden input.
if isinstance(string, lldb.SBCommandReturnObject):
``````````
</details>
https://github.com/llvm/llvm-project/pull/224021
More information about the lldb-commits
mailing list