forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 339
[lldb] Rewrite Swift completion logic in REPL to not crash [WIP] #662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bd31559
[lldb/pexpect] Force-set the TERM environment variable
labath 0f32e4d
[lldb] Fix that CompletionRequestGetRawLineUntilCursor returns the wr…
Teemperor b8ea404
[lldb] Move REPL::CompleteCode interface to use CompletionRequest
Teemperor 28f284d
[lldb] Rewrite Swift REPL completion to use CompletionRequest
Teemperor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 34 additions & 14 deletions
48
lldb/packages/Python/lldbsuite/test/lang/swift/completion/TestSwiftREPLCompletion.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
from __future__ import print_function | ||
import pexpect | ||
import os | ||
|
||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
from lldbsuite.test.lldbpexpect import PExpectTest | ||
|
||
class SwiftCompletionTest(PExpectTest): | ||
|
||
class TestSwiftREPLCompletion(TestBase): | ||
mydir = TestBase.compute_mydir(__file__) | ||
|
||
# PExpect uses many timeouts internally and doesn't play well | ||
# under ASAN on a loaded machine.. | ||
@skipIfAsan | ||
@skipUnlessDarwin | ||
def test_repl_completion(self): | ||
prompt = "Welcome to" | ||
child = pexpect.spawn('%s --repl' % (lldbtest_config.lldbExec)) | ||
# Assign to make sure the sessions are killed during teardown | ||
self.child = child | ||
# Send a <TAB> and make sure we don't crash. | ||
child.sendline("import Foundatio\t") | ||
child.sendline("print(NSString(\"patatino\"))") | ||
child.expect("patatino") | ||
def test_basic_completion(self): | ||
|
||
self.launch(extra_args=["--repl"], executable=None, dimensions=(100,500)) | ||
|
||
# Wait on the first prompt | ||
self.child.expect_exact("1>") | ||
# Press tab a few times which should do nothing. | ||
# Note that we don't get any indentation whitespace as | ||
# pexpect is not recognized as a interactive terminal by pexpect it seems. | ||
self.child.send("\t\t\t") | ||
|
||
# Try completing something that only has one result "Hasabl" -> "Hashable". | ||
self.child.send("Hashabl\t") | ||
self.child.expect_exact("Hashable") | ||
self.child.sendline("") | ||
|
||
# Try completing something that has multiple completions. | ||
self.child.send("Hash\t") | ||
self.child.expect_exact("Available completions:") | ||
self.child.expect_exact("Hashable") | ||
self.child.expect_exact("Hasher") | ||
self.child.sendline("") | ||
|
||
def setUpCommands(self): | ||
return [] # REPL doesn't take any setup commands. | ||
|
||
def expect_prompt(self): | ||
pass # No constant prompt on the REPL. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a way to test this change? Is it tested as part of your other commits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two of the commits here are not Swift-specific so I'll make a separate PR for them to the stable branch once this passes the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, somehow my commented ended up in this thread.... I just pushed a unit test for this change too.