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 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr49408') 21 @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) 22 def test_completion(self): 23 self.launch(dimensions=(100,500)) 24 25 # Start tab completion, go to the next page and then display all with 'a'. 26 self.child.send("\t\ta") 27 self.child.expect_exact("register") 28 29 # Try tab completing regi to register. 30 self.child.send("regi\t") 31 # editline might move the cursor back to the start of the line and 32 # then back to its original position. 33 self.child.expect(re.compile(b"regi(\r" + self.cursor_forward_escape_seq(len(self.PROMPT + "regi")) + b")?ster")) 34 self.child.send("\n") 35 self.expect_prompt() 36 37 # Try tab completing directories and files. Also tests the partial 38 # completion where LLDB shouldn't print a space after the directory 39 # completion (as it didn't completed the full token). 40 dir_without_slashes = os.path.realpath(os.path.dirname(__file__)).rstrip("/") 41 self.child.send("file " + dir_without_slashes + "\t") 42 self.child.expect_exact("iohandler/completion/") 43 # If we get a correct partial completion without a trailing space, then this 44 # should complete the current test file. 45 self.child.send("TestIOHandler\t") 46 # As above, editline might move the cursor to the start of the line and 47 # then back to its original position. We only care about the fact 48 # that this is completing a partial completion, so skip the exact cursor 49 # position calculation. 50 self.child.expect(re.compile(b"TestIOHandler(\r" + self.cursor_forward_escape_seq("\d+") + b")?Completion.py")) 51 self.child.send("\n") 52 self.expect_prompt() 53 54 # Start tab completion and abort showing more commands with 'n'. 55 self.child.send("\t") 56 self.child.expect_exact("More (Y/n/a)") 57 self.child.send("n") 58 self.expect_prompt() 59 60 # Shouldn't crash or anything like that. 61 self.child.send("regoinvalid\t") 62 self.expect_prompt() 63 64 self.quit() 65