summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/tools
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/tools')
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/Makefile3
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py117
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp16
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py2
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py2
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py16
6 files changed, 154 insertions, 2 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/Makefile b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/Makefile
new file mode 100644
index 00000000000..99998b20bcb
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
new file mode 100644
index 00000000000..4500a809392
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
@@ -0,0 +1,117 @@
+"""
+Test lldb-vscode completions request
+"""
+
+from __future__ import print_function
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def verify_completions(self, actual_list, expected_list, not_expected_list=[]):
+ for expected_item in expected_list:
+ self.assertTrue(expected_item in actual_list)
+
+ for not_expected_item in not_expected_list:
+ self.assertFalse(not_expected_item in actual_list)
+
+ @skipIfWindows
+ @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots
+ @no_debug_info_test
+ def test_completions(self):
+ """
+ Tests the completion request at different breakpoints
+ """
+ program = self.getBuildArtifact("a.out")
+ self.build_and_launch(program)
+ source = "main.cpp"
+ breakpoint1_line = line_number(source, "// breakpoint 1")
+ breakpoint2_line = line_number(source, "// breakpoint 2")
+ breakpoint_ids = self.set_source_breakpoints(
+ source, [breakpoint1_line, breakpoint2_line]
+ )
+ self.continue_to_next_stop()
+
+ # shouldn't see variables inside main
+ self.verify_completions(
+ self.vscode.get_completions("var"),
+ [
+ {
+ "text": "var",
+ "label": "var -- vector<basic_string<char, char_traits<char>, allocator<char> >, allocator<basic_string<char, char_traits<char>, allocator<char> > > > &",
+ }
+ ],
+ [{"text": "var1", "label": "var1 -- int &"}],
+ )
+
+ # should see global keywords but not variables inside main
+ self.verify_completions(
+ self.vscode.get_completions("str"),
+ [{"text": "struct", "label": "struct"}],
+ [{"text": "str1", "label": "str1 -- std::string &"}],
+ )
+
+ self.continue_to_next_stop()
+
+ # should see variables from main but not from the other function
+ self.verify_completions(
+ self.vscode.get_completions("var"),
+ [
+ {"text": "var1", "label": "var1 -- int &"},
+ {"text": "var2", "label": "var2 -- int &"},
+ ],
+ [
+ {
+ "text": "var",
+ "label": "var -- vector<basic_string<char, char_traits<char>, allocator<char> >, allocator<basic_string<char, char_traits<char>, allocator<char> > > > &",
+ }
+ ],
+ )
+
+ self.verify_completions(
+ self.vscode.get_completions("str"),
+ [
+ {"text": "struct", "label": "struct"},
+ {"text": "str1", "label": "str1 -- string &"},
+ ],
+ )
+
+ # should complete arbitrary commands including word starts
+ self.verify_completions(
+ self.vscode.get_completions("`log enable "),
+ [{"text": "gdb-remote", "label": "gdb-remote"}],
+ )
+
+ # should complete expressions with quotes inside
+ self.verify_completions(
+ self.vscode.get_completions('`expr " "; typed'),
+ [{"text": "typedef", "label": "typedef"}],
+ )
+
+ # should complete an incomplete quoted token
+ self.verify_completions(
+ self.vscode.get_completions('`setting "se'),
+ [
+ {
+ "text": "set",
+ "label": "set -- Set the value of the specified debugger setting.",
+ }
+ ],
+ )
+ self.verify_completions(
+ self.vscode.get_completions("`'comm"),
+ [
+ {
+ "text": "command",
+ "label": "command -- Commands for managing custom LLDB commands.",
+ }
+ ],
+ )
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
new file mode 100644
index 00000000000..14a8815a524
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
@@ -0,0 +1,16 @@
+#include <string>
+#include <vector>
+
+int fun(std::vector<std::string> var) {
+ return var.size(); // breakpoint 1
+}
+
+int main(int argc, char const *argv[]) {
+ int var1 = 0;
+ int var2 = 1;
+ std::string str1 = "a";
+ std::string str2 = "b";
+ std::vector<std::string> vec;
+ fun(vec);
+ return 0; // breakpoint 2
+}
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index 04ca8d9b755..b0f69b283fd 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -254,7 +254,7 @@ class VSCodeTestCaseBase(TestBase):
'''Sending launch request to vscode
'''
- # Make sure we disconnet and terminate the VSCode debug adaptor,
+ # Make sure we disconnect and terminate the VSCode debug adapter,
# if we throw an exception during the test case
def cleanup():
self.vscode.request_disconnect(terminateDebuggee=True)
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py
index 6d29e742564..770d58dc715 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -85,7 +85,7 @@ class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
source = 'main.cpp'
breakpoint1_line = line_number(source, '// breakpoint 1')
lines = [breakpoint1_line]
- # Set breakoint in the thread function so we can step the threads
+ # Set breakpoint in the thread function so we can step the threads
breakpoint_ids = self.set_source_breakpoints(source, lines)
self.assertTrue(len(breakpoint_ids) == len(lines),
"expect correct number of breakpoints")
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index b4e21989463..1110ad36c0f 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -348,6 +348,10 @@ class DebugCommunication(object):
print('invalid response')
return None
+ def get_completions(self, text):
+ response = self.request_completions(text)
+ return response['body']['targets']
+
def get_scope_variables(self, scope_name, frameIndex=0, threadId=None):
stackFrame = self.get_stackFrame(frameIndex=frameIndex,
threadId=threadId)
@@ -715,6 +719,18 @@ class DebugCommunication(object):
}
return self.send_recv(command_dict)
+ def request_completions(self, text):
+ args_dict = {
+ 'text': text,
+ 'column': len(text)
+ }
+ command_dict = {
+ 'command': 'completions',
+ 'type': 'request',
+ 'arguments': args_dict
+ }
+ return self.send_recv(command_dict)
+
def request_stackTrace(self, threadId=None, startFrame=None, levels=None,
dump=False):
if threadId is None:
OpenPOWER on IntegriCloud