Skip to content

Commit c51a758

Browse files
authored
[lldb][test] Add SBExpressionOptions parameter to expect_expr (llvm#177920)
Allows API tests to pass `SBExpressionOptions` when testing a successful expression evaluation with `expect_expr`. Currently one would have to use `SBFrame::EvaluateExpression` or pass the option as an argument to the raw command (via `expect()` or `HandleCommand()`). Chose not to do the `SetIgnoreBreakpoints`/`SetAutoApplyFixIts` with the assumption that most expression evaluation tests don't actually need to care about these. If the options are passed explicitly, lets use them as-is. Otherwise default to the old options. First usage of this new parameter would be in llvm#177926
1 parent 00e2649 commit c51a758

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,6 +2575,7 @@ def expect_expr(
25752575
result_value=None,
25762576
result_type=None,
25772577
result_children=None,
2578+
options=None,
25782579
):
25792580
"""
25802581
Evaluates the given expression and verifies the result.
@@ -2584,20 +2585,23 @@ def expect_expr(
25842585
:param result_type: The type that the expression result should have. None if the type should not be checked.
25852586
:param result_children: The expected children of the expression result
25862587
as a list of ValueChecks. None if the children shouldn't be checked.
2588+
:param options: Expression evaluation options. None if a default set of options should be used.
25872589
"""
25882590
self.assertTrue(
25892591
expr.strip() == expr,
25902592
"Expression contains trailing/leading whitespace: '" + expr + "'",
25912593
)
25922594

25932595
frame = self.frame()
2594-
options = lldb.SBExpressionOptions()
25952596

2596-
# Disable fix-its that tests don't pass by accident.
2597-
options.SetAutoApplyFixIts(False)
2597+
if not options:
2598+
options = lldb.SBExpressionOptions()
25982599

2599-
# Set the usual default options for normal expressions.
2600-
options.SetIgnoreBreakpoints(True)
2600+
# Disable fix-its that tests don't pass by accident.
2601+
options.SetAutoApplyFixIts(False)
2602+
2603+
# Set the usual default options for normal expressions.
2604+
options.SetIgnoreBreakpoints(True)
26012605

26022606
if self.frame().IsValid():
26032607
options.SetLanguage(frame.GuessLanguage())

0 commit comments

Comments
 (0)