1"""
2This tests some simple examples of parsing regex commands
3"""
4
5import os
6import lldb
7import lldbsuite.test.lldbutil as lldbutil
8from lldbsuite.test.lldbtest import *
9
10
11class TestCommandRegexParsing(TestBase):
12
13    NO_DEBUG_INFO_TESTCASE = True
14
15    def test_sample_rename_this(self):
16        """Try out some simple regex commands, make sure they parse correctly."""
17        self.runCmd("command regex one-substitution 's/(.+)/echo-cmd %1-first %1-second %1-third/'")
18        self.expect("one-substitution ASTRING",
19                    substrs = ["ASTRING-first", "ASTRING-second", "ASTRING-third"])
20
21        self.runCmd("command regex two-substitution 's/([^ ]+) ([^ ]+)/echo-cmd %1-first %2-second %1-third %2-fourth/'")
22        self.expect("two-substitution ASTRING BSTRING",
23                    substrs = ["ASTRING-first", "BSTRING-second", "ASTRING-third", "BSTRING-fourth"])
24
25    def setUp(self):
26        # Call super's setUp().
27        TestBase.setUp(self)
28        self.runCmd("command script import " + os.path.join(self.getSourceDir(), "echo_command.py"))
29        self.runCmd("command script add echo-cmd -f echo_command.echo_command")
30