Skip to content

Commit 8012518

Browse files
committed
Revert "[lldb] Improve completion tests (#65973)"
This reverts commit 2378ba6. I need to fix the x86 specific register tests.
1 parent 5378117 commit 8012518

File tree

3 files changed

+76
-66
lines changed

3 files changed

+76
-66
lines changed

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,15 +2223,12 @@ def check_completion_with_desc(
22232223
)
22242224
self.assertFalse(got_failure, error_msg)
22252225

2226-
def complete_from_to(self, str_input, patterns):
2227-
"""Test that the completion mechanism completes str_input to patterns,
2228-
where patterns could be a single pattern-string or a list of
2229-
pattern-strings.
2230-
2231-
If there is only one pattern and it is exactly equal to str_input, this
2232-
assumes that there should be no completions provided and that the result
2233-
should be the same as the input."""
2226+
def complete_exactly(self, str_input, patterns):
2227+
self.complete_from_to(str_input, patterns, True)
22342228

2229+
def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
2230+
"""Test that the completion mechanism completes str_input to patterns,
2231+
where patterns could be a pattern-string or a list of pattern-strings"""
22352232
# Patterns should not be None in order to proceed.
22362233
self.assertFalse(patterns is None)
22372234
# And should be either a string or list of strings. Check for list type
@@ -2257,16 +2254,21 @@ def complete_from_to(self, str_input, patterns):
22572254
for idx in range(1, num_matches + 1):
22582255
compare_string += match_strings.GetStringAtIndex(idx) + "\n"
22592256

2260-
if len(patterns) == 1 and str_input == patterns[0] and num_matches:
2261-
self.fail("Expected no completions but got:\n" + compare_string)
2262-
22632257
for p in patterns:
2264-
self.expect(
2265-
compare_string,
2266-
msg=COMPLETION_MSG(str_input, p, match_strings),
2267-
exe=False,
2268-
substrs=[p],
2269-
)
2258+
if turn_off_re_match:
2259+
self.expect(
2260+
compare_string,
2261+
msg=COMPLETION_MSG(str_input, p, match_strings),
2262+
exe=False,
2263+
substrs=[p],
2264+
)
2265+
else:
2266+
self.expect(
2267+
compare_string,
2268+
msg=COMPLETION_MSG(str_input, p, match_strings),
2269+
exe=False,
2270+
patterns=[p],
2271+
)
22702272

22712273
def completions_match(self, command, completions):
22722274
"""Checks that the completions for the given command are equal to the

lldb/test/API/commands/expression/completion/TestExprCompletion.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,34 @@ def test_expr_completion(self):
2929
)
3030

3131
# Completing member functions
32-
self.complete_from_to(
32+
self.complete_exactly(
3333
"expr some_expr.FooNoArgs", "expr some_expr.FooNoArgsBar()"
3434
)
35-
self.complete_from_to(
35+
self.complete_exactly(
3636
"expr some_expr.FooWithArgs", "expr some_expr.FooWithArgsBar("
3737
)
38-
self.complete_from_to(
38+
self.complete_exactly(
3939
"expr some_expr.FooWithMultipleArgs",
4040
"expr some_expr.FooWithMultipleArgsBar(",
4141
)
42-
self.complete_from_to(
42+
self.complete_exactly(
4343
"expr some_expr.FooUnderscore", "expr some_expr.FooUnderscoreBar_()"
4444
)
45-
self.complete_from_to(
45+
self.complete_exactly(
4646
"expr some_expr.FooNumbers", "expr some_expr.FooNumbersBar1()"
4747
)
48-
self.complete_from_to(
48+
self.complete_exactly(
4949
"expr some_expr.StaticMemberMethod",
5050
"expr some_expr.StaticMemberMethodBar()",
5151
)
5252

5353
# Completing static functions
54-
self.complete_from_to(
54+
self.complete_exactly(
5555
"expr Expr::StaticMemberMethod", "expr Expr::StaticMemberMethodBar()"
5656
)
5757

5858
# Completing member variables
59-
self.complete_from_to(
59+
self.complete_exactly(
6060
"expr some_expr.MemberVariab", "expr some_expr.MemberVariableBar"
6161
)
6262

@@ -94,43 +94,43 @@ def test_expr_completion(self):
9494
self.completions_contain("expr 1+", ["1+some_expr", "1+static_cast"])
9595

9696
# Test with spaces
97-
self.complete_from_to(
97+
self.complete_exactly(
9898
"expr some_expr .FooNoArgs", "expr some_expr .FooNoArgsBar()"
9999
)
100-
self.complete_from_to(
100+
self.complete_exactly(
101101
"expr some_expr .FooNoArgs", "expr some_expr .FooNoArgsBar()"
102102
)
103-
self.complete_from_to(
103+
self.complete_exactly(
104104
"expr some_expr .FooNoArgs", "expr some_expr .FooNoArgsBar()"
105105
)
106-
self.complete_from_to(
106+
self.complete_exactly(
107107
"expr some_expr. FooNoArgs", "expr some_expr. FooNoArgsBar()"
108108
)
109-
self.complete_from_to(
109+
self.complete_exactly(
110110
"expr some_expr . FooNoArgs", "expr some_expr . FooNoArgsBar()"
111111
)
112-
self.complete_from_to(
112+
self.complete_exactly(
113113
"expr Expr :: StaticMemberMethod", "expr Expr :: StaticMemberMethodBar()"
114114
)
115-
self.complete_from_to(
115+
self.complete_exactly(
116116
"expr Expr ::StaticMemberMethod", "expr Expr ::StaticMemberMethodBar()"
117117
)
118-
self.complete_from_to(
118+
self.complete_exactly(
119119
"expr Expr:: StaticMemberMethod", "expr Expr:: StaticMemberMethodBar()"
120120
)
121121

122122
# Test that string literals don't break our parsing logic.
123-
self.complete_from_to(
123+
self.complete_exactly(
124124
'expr const char *cstr = "some_e"; char c = *cst',
125125
'expr const char *cstr = "some_e"; char c = *cstr',
126126
)
127-
self.complete_from_to(
127+
self.complete_exactly(
128128
'expr const char *cstr = "some_e" ; char c = *cst',
129129
'expr const char *cstr = "some_e" ; char c = *cstr',
130130
)
131131
# Requesting completions inside an incomplete string doesn't provide any
132132
# completions.
133-
self.complete_from_to(
133+
self.complete_exactly(
134134
'expr const char *cstr = "some_e', 'expr const char *cstr = "some_e'
135135
)
136136

@@ -139,110 +139,110 @@ def test_expr_completion(self):
139139
self.assume_no_completions("expr -i0 -- some_expr.", 11)
140140

141141
# Test with expr arguments
142-
self.complete_from_to(
142+
self.complete_exactly(
143143
"expr -i0 -- some_expr .FooNoArgs", "expr -i0 -- some_expr .FooNoArgsBar()"
144144
)
145-
self.complete_from_to(
145+
self.complete_exactly(
146146
"expr -i0 -- some_expr .FooNoArgs",
147147
"expr -i0 -- some_expr .FooNoArgsBar()",
148148
)
149149

150150
# Addrof and deref
151-
self.complete_from_to(
151+
self.complete_exactly(
152152
"expr (*(&some_expr)).FooNoArgs", "expr (*(&some_expr)).FooNoArgsBar()"
153153
)
154-
self.complete_from_to(
154+
self.complete_exactly(
155155
"expr (*(&some_expr)) .FooNoArgs", "expr (*(&some_expr)) .FooNoArgsBar()"
156156
)
157-
self.complete_from_to(
157+
self.complete_exactly(
158158
"expr (* (&some_expr)) .FooNoArgs", "expr (* (&some_expr)) .FooNoArgsBar()"
159159
)
160-
self.complete_from_to(
160+
self.complete_exactly(
161161
"expr (* (& some_expr)) .FooNoArgs",
162162
"expr (* (& some_expr)) .FooNoArgsBar()",
163163
)
164164

165165
# Addrof and deref (part 2)
166-
self.complete_from_to(
166+
self.complete_exactly(
167167
"expr (&some_expr)->FooNoArgs", "expr (&some_expr)->FooNoArgsBar()"
168168
)
169-
self.complete_from_to(
169+
self.complete_exactly(
170170
"expr (&some_expr) ->FooNoArgs", "expr (&some_expr) ->FooNoArgsBar()"
171171
)
172-
self.complete_from_to(
172+
self.complete_exactly(
173173
"expr (&some_expr) -> FooNoArgs", "expr (&some_expr) -> FooNoArgsBar()"
174174
)
175-
self.complete_from_to(
175+
self.complete_exactly(
176176
"expr (&some_expr)-> FooNoArgs", "expr (&some_expr)-> FooNoArgsBar()"
177177
)
178178

179179
# Builtin arg
180-
self.complete_from_to("expr static_ca", "expr static_cast")
180+
self.complete_exactly("expr static_ca", "expr static_cast")
181181

182182
# From other files
183-
self.complete_from_to(
183+
self.complete_exactly(
184184
"expr fwd_decl_ptr->Hidden", "expr fwd_decl_ptr->HiddenMember"
185185
)
186186

187187
# Types
188-
self.complete_from_to("expr LongClassNa", "expr LongClassName")
189-
self.complete_from_to(
188+
self.complete_exactly("expr LongClassNa", "expr LongClassName")
189+
self.complete_exactly(
190190
"expr LongNamespaceName::NestedCla", "expr LongNamespaceName::NestedClass"
191191
)
192192

193193
# Namespaces
194-
self.complete_from_to("expr LongNamespaceNa", "expr LongNamespaceName::")
194+
self.complete_exactly("expr LongNamespaceNa", "expr LongNamespaceName::")
195195

196196
# Multiple arguments
197-
self.complete_from_to(
197+
self.complete_exactly(
198198
"expr &some_expr + &some_e", "expr &some_expr + &some_expr"
199199
)
200-
self.complete_from_to(
200+
self.complete_exactly(
201201
"expr SomeLongVarNameWithCapitals + SomeLongVarName",
202202
"expr SomeLongVarNameWithCapitals + SomeLongVarNameWithCapitals",
203203
)
204-
self.complete_from_to(
204+
self.complete_exactly(
205205
"expr SomeIntVar + SomeIntV", "expr SomeIntVar + SomeIntVar"
206206
)
207207

208208
# Multiple statements
209-
self.complete_from_to(
209+
self.complete_exactly(
210210
"expr long LocalVariable = 0; LocalVaria",
211211
"expr long LocalVariable = 0; LocalVariable",
212212
)
213213

214214
# Custom Decls
215-
self.complete_from_to(
215+
self.complete_exactly(
216216
"expr auto l = [](int LeftHandSide, int bx){ return LeftHandS",
217217
"expr auto l = [](int LeftHandSide, int bx){ return LeftHandSide",
218218
)
219-
self.complete_from_to(
219+
self.complete_exactly(
220220
"expr struct LocalStruct { long MemberName; } ; LocalStruct S; S.Mem",
221221
"expr struct LocalStruct { long MemberName; } ; LocalStruct S; S.MemberName",
222222
)
223223

224224
# Completing function call arguments
225-
self.complete_from_to(
225+
self.complete_exactly(
226226
"expr some_expr.FooWithArgsBar(some_exp",
227227
"expr some_expr.FooWithArgsBar(some_expr",
228228
)
229-
self.complete_from_to(
229+
self.complete_exactly(
230230
"expr some_expr.FooWithArgsBar(SomeIntV",
231231
"expr some_expr.FooWithArgsBar(SomeIntVar",
232232
)
233-
self.complete_from_to(
233+
self.complete_exactly(
234234
"expr some_expr.FooWithMultipleArgsBar(SomeIntVar, SomeIntVa",
235235
"expr some_expr.FooWithMultipleArgsBar(SomeIntVar, SomeIntVar",
236236
)
237237

238238
# Function return values
239-
self.complete_from_to(
239+
self.complete_exactly(
240240
"expr some_expr.Self().FooNoArgs", "expr some_expr.Self().FooNoArgsBar()"
241241
)
242-
self.complete_from_to(
242+
self.complete_exactly(
243243
"expr some_expr.Self() .FooNoArgs", "expr some_expr.Self() .FooNoArgsBar()"
244244
)
245-
self.complete_from_to(
245+
self.complete_exactly(
246246
"expr some_expr.Self(). FooNoArgs", "expr some_expr.Self(). FooNoArgsBar()"
247247
)
248248

lldb/test/API/functionalities/completion/TestCompletion.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,18 @@ def test_log_file(self):
235235
def test_log_dir(self):
236236
# Complete our source directory.
237237
src_dir = os.path.dirname(os.path.realpath(__file__))
238-
self.complete_from_to("log enable lldb expr -f " + src_dir, [src_dir + os.sep])
238+
self.complete_from_to(
239+
"log enable lldb expr -f " + src_dir,
240+
[src_dir + os.sep],
241+
turn_off_re_match=True,
242+
)
239243

240244
# <rdar://problem/11052829>
241245
def test_infinite_loop_while_completing(self):
242246
"""Test that 'process print hello\' completes to itself and does not infinite loop."""
243-
self.complete_from_to("process print hello\\", "process print hello\\")
247+
self.complete_from_to(
248+
"process print hello\\", "process print hello\\", turn_off_re_match=True
249+
)
244250

245251
def test_watchpoint_co(self):
246252
"""Test that 'watchpoint co' completes to 'watchpoint command '."""
@@ -720,7 +726,9 @@ def test_symbol_name(self):
720726
self.build()
721727
self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
722728
self.complete_from_to(
723-
"breakpoint set -n Fo", "breakpoint set -n Foo::Bar(int,\\ int)"
729+
"breakpoint set -n Fo",
730+
"breakpoint set -n Foo::Bar(int,\\ int)",
731+
turn_off_re_match=True,
724732
)
725733
# No completion for Qu because the candidate is
726734
# (anonymous namespace)::Quux().

0 commit comments

Comments
 (0)