Files
clang-p2996/lldb/test/API/functionalities/ambigous_commands/TestAmbiguousCommands.py
Med Ismail Bennani 8334d2bfd3 [lldb/Interpreter] Fix ambiguous partial command resolution (#101934)
This patch is a follow-up to #97263 that fix ambigous abbreviated
command resolution.

When multiple commands are resolved, instead of failing to pick a
command to
run, this patch changes to resolution logic to check if there is a
single
alias match and if so, it will run the alias instead of the other
matches.

This has as a side-effect that we don't need to make aliases for every
substring of aliases to support abbrivated alias resolution.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-08-08 12:55:10 -07:00

36 lines
1.2 KiB
Python

"""
Test how lldb reacts to ambiguous commands
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class AmbiguousCommandTestCase(TestBase):
@no_debug_info_test
def test_ambiguous_command_with_alias(self):
command_interpreter = self.dbg.GetCommandInterpreter()
self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
result = lldb.SBCommandReturnObject()
command_interpreter.HandleCommand(
"command alias corefile target create -c %0", result
)
self.assertTrue(result.Succeeded())
command_interpreter.ResolveCommand("co", result)
self.assertFalse(result.Succeeded())
self.assertEqual(
result.GetError(),
"Ambiguous command 'co'. Possible matches:\n\tcommand\n\tcontinue\n\tcorefile\n",
)
command_interpreter.HandleCommand("command unalias continue", result)
self.assertTrue(result.Succeeded())
command_interpreter.ResolveCommand("co", result)
self.assertTrue(result.Succeeded())
self.assertEqual(result.GetOutput(), "target create -c %0")