45 lines · python
1"""2This tests some simple examples of parsing regex commands3"""4 5import os6import lldb7import lldbsuite.test.lldbutil as lldbutil8from lldbsuite.test.lldbtest import *9 10 11class TestCommandRegexParsing(TestBase):12 NO_DEBUG_INFO_TESTCASE = True13 14 def test_sample_rename_this(self):15 """Try out some simple regex commands, make sure they parse correctly."""16 self.runCmd(17 "command regex one-substitution 's/(.+)/echo-cmd %1-first %1-second %1-third/'"18 )19 self.expect(20 "one-substitution ASTRING",21 substrs=["ASTRING-first", "ASTRING-second", "ASTRING-third"],22 )23 24 self.runCmd(25 "command regex two-substitution 's/([^ ]+) ([^ ]+)/echo-cmd %1-first %2-second %1-third %2-fourth/'"26 )27 self.expect(28 "two-substitution ASTRING BSTRING",29 substrs=[30 "ASTRING-first",31 "BSTRING-second",32 "ASTRING-third",33 "BSTRING-fourth",34 ],35 )36 37 def setUp(self):38 # Call super's setUp().39 TestBase.setUp(self)40 self.runCmd(41 "command script import "42 + os.path.join(self.getSourceDir(), "echo_command.py")43 )44 self.runCmd("command script add echo-cmd -f echo_command.echo_command")45