aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite/test/lldbtest.py
diff options
context:
space:
mode:
authorDavid Spickett <david.spickett@linaro.org>2023-09-12 08:28:31 +0100
committerDavid Spickett <david.spickett@linaro.org>2023-09-12 08:40:43 +0100
commit6bf6c4762c355ce4f4fb976039375a2c8ff6038f (patch)
treeb45d0b761fa27f7dde122ec9635919a5b1878c10 /lldb/packages/Python/lldbsuite/test/lldbtest.py
parent5b6f3fcb48e9476c8780f7c5f4abb8f2e348fc0d (diff)
downloadllvm-6bf6c4762c355ce4f4fb976039375a2c8ff6038f.zip
llvm-6bf6c4762c355ce4f4fb976039375a2c8ff6038f.tar.gz
llvm-6bf6c4762c355ce4f4fb976039375a2c8ff6038f.tar.bz2
Reland "[lldb] Improve completion tests (#65973)"
This reverts commit 8012518f600bebaa4ed99a57d553eeea25c2d0c9. The x86 register write test had one that expected "\$rax" so on. As these patterns were previously regex, the $ had to be escaped. Now they are just plain strings to this is not needed.
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbtest.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbtest.py36
1 files changed, 17 insertions, 19 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 49355d6..50e8ad0 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2223,12 +2223,15 @@ class TestBase(Base, metaclass=LLDBTestCaseFactory):
)
self.assertFalse(got_failure, error_msg)
- def complete_exactly(self, str_input, patterns):
- self.complete_from_to(str_input, patterns, True)
-
- def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
+ def complete_from_to(self, str_input, patterns):
"""Test that the completion mechanism completes str_input to patterns,
- where patterns could be a pattern-string or a list of pattern-strings"""
+ where patterns could be a single pattern-string or a list of
+ pattern-strings.
+
+ If there is only one pattern and it is exactly equal to str_input, this
+ assumes that there should be no completions provided and that the result
+ should be the same as the input."""
+
# Patterns should not be None in order to proceed.
self.assertFalse(patterns is None)
# And should be either a string or list of strings. Check for list type
@@ -2254,21 +2257,16 @@ class TestBase(Base, metaclass=LLDBTestCaseFactory):
for idx in range(1, num_matches + 1):
compare_string += match_strings.GetStringAtIndex(idx) + "\n"
+ if len(patterns) == 1 and str_input == patterns[0] and num_matches:
+ self.fail("Expected no completions but got:\n" + compare_string)
+
for p in patterns:
- if turn_off_re_match:
- self.expect(
- compare_string,
- msg=COMPLETION_MSG(str_input, p, match_strings),
- exe=False,
- substrs=[p],
- )
- else:
- self.expect(
- compare_string,
- msg=COMPLETION_MSG(str_input, p, match_strings),
- exe=False,
- patterns=[p],
- )
+ self.expect(
+ compare_string,
+ msg=COMPLETION_MSG(str_input, p, match_strings),
+ exe=False,
+ substrs=[p],
+ )
def completions_match(self, command, completions):
"""Checks that the completions for the given command are equal to the