2 Test lldb-vscode completions request
6 import lldbvscode_testcase
9 from lldbsuite.test import lldbutil
10 from lldbsuite.test.decorators import *
11 from lldbsuite.test.lldbtest import *
14 class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
16 mydir = TestBase.compute_mydir(__file__)
18 def verify_completions(self, actual_list, expected_list, not_expected_list=[]):
19 for expected_item in expected_list:
20 self.assertTrue(expected_item in actual_list)
22 for not_expected_item in not_expected_list:
23 self.assertFalse(not_expected_item in actual_list)
26 @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots
27 def test_completions(self):
29 Tests the completion request at different breakpoints
31 program = self.getBuildArtifact("a.out")
32 self.build_and_launch(program)
34 breakpoint1_line = line_number(source, "// breakpoint 1")
35 breakpoint2_line = line_number(source, "// breakpoint 2")
36 breakpoint_ids = self.set_source_breakpoints(
37 source, [breakpoint1_line, breakpoint2_line]
39 self.continue_to_next_stop()
41 # shouldn't see variables inside main
42 self.verify_completions(
43 self.vscode.get_completions("var"),
47 "label": "var -- vector<basic_string<char, char_traits<char>, allocator<char> >, allocator<basic_string<char, char_traits<char>, allocator<char> > > > &",
50 [{"text": "var1", "label": "var1 -- int &"}],
53 # should see global keywords but not variables inside main
54 self.verify_completions(
55 self.vscode.get_completions("str"),
56 [{"text": "struct", "label": "struct"}],
57 [{"text": "str1", "label": "str1 -- std::string &"}],
60 self.continue_to_next_stop()
62 # should see variables from main but not from the other function
63 self.verify_completions(
64 self.vscode.get_completions("var"),
66 {"text": "var1", "label": "var1 -- int &"},
67 {"text": "var2", "label": "var2 -- int &"},
72 "label": "var -- vector<basic_string<char, char_traits<char>, allocator<char> >, allocator<basic_string<char, char_traits<char>, allocator<char> > > > &",
77 self.verify_completions(
78 self.vscode.get_completions("str"),
80 {"text": "struct", "label": "struct"},
81 {"text": "str1", "label": "str1 -- string &"},
85 # should complete arbitrary commands including word starts
86 self.verify_completions(
87 self.vscode.get_completions("`log enable "),
88 [{"text": "gdb-remote", "label": "gdb-remote"}],
91 # should complete expressions with quotes inside
92 self.verify_completions(
93 self.vscode.get_completions('`expr " "; typed'),
94 [{"text": "typedef", "label": "typedef"}],
97 # should complete an incomplete quoted token
98 self.verify_completions(
99 self.vscode.get_completions('`setting "se'),
103 "label": "set -- Set the value of the specified debugger setting.",
107 self.verify_completions(
108 self.vscode.get_completions("`'comm"),
112 "label": "command -- Commands for managing custom LLDB commands.",