diff options
author | David Spickett <david.spickett@linaro.org> | 2023-09-11 18:26:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-11 18:26:51 +0100 |
commit | 2378ba632e5cdc761584a4154449833ac0f86384 (patch) | |
tree | dba6c152b2f09262415b70794c744ba8f0124cf5 /lldb/packages/Python/lldbsuite/test/lldbtest.py | |
parent | a4d14011e57b91f8040ac08fd3496780aee3c253 (diff) | |
download | llvm-2378ba632e5cdc761584a4154449833ac0f86384.zip llvm-2378ba632e5cdc761584a4154449833ac0f86384.tar.gz llvm-2378ba632e5cdc761584a4154449833ac0f86384.tar.bz2 |
[lldb] Improve completion tests (#65973)
* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.
This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbtest.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lldbtest.py | 36 |
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 |