• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2Test completion in our IOHandlers.
3"""
4
5import os
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test.lldbpexpect import PExpectTest
11
12class IOHandlerCompletionTest(PExpectTest):
13
14    mydir = TestBase.compute_mydir(__file__)
15
16    # PExpect uses many timeouts internally and doesn't play well
17    # under ASAN on a loaded machine..
18    @skipIfAsan
19    @skipIfEditlineSupportMissing
20    def test_completion(self):
21        self.launch(dimensions=(100,500))
22
23        # Start tab completion, go to the next page and then display all with 'a'.
24        self.child.send("\t\ta")
25        self.child.expect_exact("register")
26
27        # Try tab completing regi to register.
28        self.child.send("regi\t")
29        # editline might move the cursor back to the start of the line and
30        # then back to its original position.
31        self.child.expect(re.compile(b"regi(\r" + self.cursor_forward_escape_seq(len(self.PROMPT + "regi")) + b")?ster"))
32        self.child.send("\n")
33        self.expect_prompt()
34
35        # Try tab completing directories and files. Also tests the partial
36        # completion where LLDB shouldn't print a space after the directory
37        # completion (as it didn't completed the full token).
38        dir_without_slashes = os.path.realpath(os.path.dirname(__file__)).rstrip("/")
39        self.child.send("file " + dir_without_slashes + "\t")
40        self.child.expect_exact("iohandler/completion/")
41        # If we get a correct partial completion without a trailing space, then this
42        # should complete the current test file.
43        self.child.send("TestIOHandler\t")
44        # As above, editline might move the cursor to the start of the line and
45        # then back to its original position. We only care about the fact
46        # that this is completing a partial completion, so skip the exact cursor
47        # position calculation.
48        self.child.expect(re.compile(b"TestIOHandler(\r" + self.cursor_forward_escape_seq("\d+") + b")?Completion.py"))
49        self.child.send("\n")
50        self.expect_prompt()
51
52        # Start tab completion and abort showing more commands with 'n'.
53        self.child.send("\t")
54        self.child.expect_exact("More (Y/n/a)")
55        self.child.send("n")
56        self.expect_prompt()
57
58        # Shouldn't crash or anything like that.
59        self.child.send("regoinvalid\t")
60        self.expect_prompt()
61
62        self.quit()
63