2 Test completion for multiline expressions.
6 from lldbsuite
.test
.decorators
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
.lldbpexpect
import PExpectTest
11 class MultilineCompletionTest(PExpectTest
):
12 def start_expression_editor(self
):
13 """Starts the multiline expression editor."""
14 self
.child
.send("expression\n")
15 self
.child
.expect_exact("terminate with an empty line to evaluate")
17 def exit_expression_editor(self
):
18 """Exits the multiline expression editor."""
19 # Send a newline to finish the current line. The second newline will
20 # finish the new empty line which will exit the editor. The space at the
21 # start prevents that the first newline already exits the editor (in
22 # case the current line of the editor is already empty when this
23 # function is called).
24 self
.child
.send(" \n\n")
27 # PExpect uses many timeouts internally and doesn't play well
28 # under ASAN on a loaded machine..
30 @skipIfEditlineSupportMissing
31 @expectedFailureAll(oslist
=["freebsd"], bugnumber
="llvm.org/pr49408")
32 @skipIf(oslist
=["linux"], archs
=["arm", "aarch64"])
33 def test_basic_completion(self
):
34 """Test that we can complete a simple multiline expression"""
37 self
.launch(executable
=self
.getBuildArtifact("a.out"), dimensions
=(100, 500))
38 self
.expect("b main", substrs
=["Breakpoint 1", "address ="])
39 self
.expect("run", substrs
=["stop reason = breakpoint 1"])
41 self
.start_expression_editor()
42 self
.child
.send("to_\t")
43 # editline might move the cursor back to the start of the line via \r
44 # and then back to its original position.
48 + self
.cursor_forward_escape_seq(len(" 1: to_"))
52 self
.exit_expression_editor()
54 # Check that completion empty input in a function with only one
55 # local variable works.
57 "breakpoint set -p 'break in single_local_func'", substrs
=["Breakpoint 2"]
59 self
.expect("continue", substrs
=["stop reason = breakpoint 2"])
60 self
.start_expression_editor()
62 # Only one local, so this will directly insert 'only_local' with a
63 # trailing space to signal a final completion.
64 self
.child
.expect_exact("only_local ")
65 self
.exit_expression_editor()