Files
clang-p2996/lldb/test/API/commands/command/regex/TestRegexCommand.py
Jonas Devlieghere 2238dcc393 [NFC][Py Reformat] Reformat python files in lldb
This is an ongoing series of commits that are reformatting our Python
code. Reformatting is done with `black` (23.1.0).

If you end up having problems merging this commit because you have made
changes to a python file, the best way to handle that is to run `git
checkout --ours <yourfile>` and then reformat it with black.

RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Differential revision: https://reviews.llvm.org/D151460
2023-05-25 12:54:09 -07:00

45 lines
1.3 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):
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")