Files
clang-p2996/lldb/test/API/commands/command/regex/TestRegexCommand.py
Jim Ingham 3c45476923 Fix a thinko in the parsing of substitutions in CommandObjectRegexCommand.
The old code incorrectly calculated the start position for the search
for the third (and subsequent) instance of a particular substitution
pattern (e.g. %1).

I also added a few test cases for this parsing covering this failure.
2021-07-27 18:58:56 -07:00

32 lines
1.2 KiB
Python

"""
This tests some simple examples of parsing regex commands
"""
import os
import lldb
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
class TestCommandRegexParsing(TestBase):
mydir = TestBase.compute_mydir(__file__)
NO_DEBUG_INFO_TESTCASE = True
def test_sample_rename_this(self):
"""Try out some simple regex commands, make sure they parse correctly."""
self.runCmd("command regex one-substitution 's/(.+)/echo-cmd %1-first %1-second %1-third/'")
self.expect("one-substitution ASTRING",
substrs = ["ASTRING-first", "ASTRING-second", "ASTRING-third"])
self.runCmd("command regex two-substitution 's/([^ ]+) ([^ ]+)/echo-cmd %1-first %2-second %1-third %2-fourth/'")
self.expect("two-substitution ASTRING BSTRING",
substrs = ["ASTRING-first", "BSTRING-second", "ASTRING-third", "BSTRING-fourth"])
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
self.runCmd("command script import " + os.path.join(self.getSourceDir(), "echo_command.py"))
self.runCmd("command script add echo-cmd -f echo_command.echo_command")