[Lldb-commits] [lldb] Add the ability for Script based commands to specify their "repeat command" (PR #94823)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 7 17:46:52 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r 435dd9746107e13c2ad019be3bd34815f7d2360d...c2fea75364a0017be5e59020467d661bd00122ba lldb/examples/python/cmdtemplate.py lldb/test/API/commands/command/script/add/TestAddParsedCommand.py lldb/test/API/commands/command/script/add/test_commands.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- test/API/commands/command/script/add/TestAddParsedCommand.py 2024-06-08 00:36:34.000000 +0000
+++ test/API/commands/command/script/add/TestAddParsedCommand.py 2024-06-08 00:46:28.088059 +0000
@@ -38,37 +38,38 @@
self.expect("help " + cmd_name, substrs=substrs)
def run_one_repeat(self, commands, expected_num_errors):
with open(self.stdin_path, "w") as input_handle:
input_handle.write(commands)
-
+
in_fileH = open(self.stdin_path, "r")
self.dbg.SetInputFileHandle(in_fileH, False)
-
+
out_fileH = open(self.stdout_path, "w")
self.dbg.SetOutputFileHandle(out_fileH, False)
self.dbg.SetErrorFileHandle(out_fileH, False)
-
+
options = lldb.SBCommandInterpreterRunOptions()
options.SetEchoCommands(False)
options.SetPrintResults(True)
options.SetPrintErrors(True)
options.SetAllowRepeats(True)
-
+
n_errors, quit_requested, has_crashed = self.dbg.RunCommandInterpreter(
- True, False, options, 0, False, False)
-
+ True, False, options, 0, False, False
+ )
+
in_fileH.close()
out_fileH.close()
-
+
results = None
with open(self.stdout_path, "r") as out_fileH:
results = out_fileH.read()
print(f"RESULTS:\n{results}\nDONE")
self.assertEqual(n_errors, expected_num_errors)
-
+
return results
def pycmd_tests(self):
source_dir = self.getSourceDir()
test_file_path = os.path.join(source_dir, "test_commands.py")
@@ -245,10 +246,12 @@
results = self.run_one_repeat("one-arg-no-opt ONE_ARG\n\n", 0)
self.assertEqual(results.count("ONE_ARG"), 2, "We did a normal repeat")
# two-args adds an argument:
results = self.run_one_repeat("two-args FIRST_ARG SECOND_ARG\n\n", 0)
- self.assertEqual(results.count("FIRST_ARG"), 2, "Passed first arg to both commands")
- self.assertEqual(results.count("SECOND_ARG"), 2, "Passed second arg to both commands")
+ self.assertEqual(
+ results.count("FIRST_ARG"), 2, "Passed first arg to both commands"
+ )
+ self.assertEqual(
+ results.count("SECOND_ARG"), 2, "Passed second arg to both commands"
+ )
self.assertEqual(results.count("THIRD_ARG"), 1, "Passed third arg in repeat")
-
-
--- test/API/commands/command/script/add/test_commands.py 2024-06-08 00:36:34.000000 +0000
+++ test/API/commands/command/script/add/test_commands.py 2024-06-08 00:46:28.168289 +0000
@@ -207,11 +207,11 @@
def get_repeat_command(self, command):
global two_arg_repeat
two_arg_repeat = command
return command + " THIRD_ARG"
-
+
def get_short_help(self):
return "This is my short help string"
def get_long_help(self):
return self.help_string
``````````
</details>
https://github.com/llvm/llvm-project/pull/94823
More information about the lldb-commits
mailing list