We just forget to check for interrupt while waiting for the answer to the prompt. But if we are in the interrupt state then the lower layers of the EditLine code just eat all characters so we never get out of the query prompt. You're pretty much stuck and have to kill lldb. The solution is to check for the interrupt. The patch is a little bigger because where I needed to check the Interrupt state I only had the ::EditLine object, but the editor state is held in lldb's EditLine wrapper, so I had to do a little work to get my hands on it.
89 lines
3.2 KiB
Python
89 lines
3.2 KiB
Python
"""
|
|
Test completion in our IOHandlers.
|
|
"""
|
|
|
|
import os
|
|
|
|
import lldb
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test.lldbpexpect import PExpectTest
|
|
|
|
|
|
class IOHandlerCompletionTest(PExpectTest):
|
|
# PExpect uses many timeouts internally and doesn't play well
|
|
# under ASAN on a loaded machine..
|
|
@skipIfAsan
|
|
@skipIfEditlineSupportMissing
|
|
@expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr49408")
|
|
@skipIf(oslist=["linux"], archs=["arm", "aarch64"])
|
|
def test_completion(self):
|
|
self.build()
|
|
self.launch(dimensions=(100, 500), executable=self.getBuildArtifact("a.out"))
|
|
|
|
# Start tab completion, go to the next page and then display all with 'a'.
|
|
self.child.send("\t\ta")
|
|
self.child.expect_exact("register")
|
|
|
|
# Try tab completing regi to register.
|
|
self.child.send("regi\t")
|
|
# editline might move the cursor back to the start of the line and
|
|
# then back to its original position.
|
|
self.child.expect(
|
|
re.compile(
|
|
b"regi(\r"
|
|
+ self.cursor_forward_escape_seq(len(self.PROMPT + "regi"))
|
|
+ b")?ster"
|
|
)
|
|
)
|
|
self.child.send("\n")
|
|
self.expect_prompt()
|
|
|
|
# Try tab completing directories and files. Also tests the partial
|
|
# completion where LLDB shouldn't print a space after the directory
|
|
# completion (as it didn't completed the full token).
|
|
dir_without_slashes = os.path.realpath(os.path.dirname(__file__)).rstrip("/")
|
|
self.child.send("file " + dir_without_slashes + "\t")
|
|
self.child.expect_exact("iohandler/completion/")
|
|
# If we get a correct partial completion without a trailing space, then this
|
|
# should complete the current test file.
|
|
self.child.send("TestIOHandler\t")
|
|
# As above, editline might move the cursor to the start of the line and
|
|
# then back to its original position. We only care about the fact
|
|
# that this is completing a partial completion, so skip the exact cursor
|
|
# position calculation.
|
|
self.child.expect(
|
|
re.compile(
|
|
b"TestIOHandler(\r"
|
|
+ self.cursor_forward_escape_seq("\d+")
|
|
+ b")?Completion.py"
|
|
)
|
|
)
|
|
self.child.send("\n")
|
|
self.expect_prompt()
|
|
|
|
# Complete a file path.
|
|
# FIXME: This should complete to './main.c' and not 'main.c'
|
|
self.child.send("breakpoint set --file ./main\t")
|
|
self.child.expect_exact("main.c")
|
|
self.child.send("\n")
|
|
self.expect_prompt()
|
|
|
|
# Start tab completion and abort showing more commands with 'n'.
|
|
self.child.send("\t")
|
|
self.child.expect_exact("More (Y/n/a)")
|
|
self.child.send("n")
|
|
self.expect_prompt()
|
|
|
|
# Start tab completion and abort showing more commands with '^C'.
|
|
self.child.send("\t")
|
|
self.child.expect_exact("More (Y/n/a)")
|
|
self.child.sendcontrol("c")
|
|
self.expect_prompt()
|
|
|
|
# Shouldn't crash or anything like that.
|
|
self.child.send("regoinvalid\t")
|
|
self.expect_prompt()
|
|
|
|
self.quit()
|