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