diff --git a/src/ethereum_clis/clis/geth.py b/src/ethereum_clis/clis/geth.py index 77e3e9fe205..1591086ebed 100644 --- a/src/ethereum_clis/clis/geth.py +++ b/src/ethereum_clis/clis/geth.py @@ -124,8 +124,28 @@ def _consume_debug_dump( fixture_path: Path, debug_output_path: Path, ): - debug_fixture_path = debug_output_path / "fixtures.json" - consume_direct_call = " ".join(command[:-1]) + f" {debug_fixture_path}" + # our assumption is that each command element is a string + assert all(isinstance(x, str) for x in command), ( + f"Not all elements of 'command' list are strings: {command}" + ) + + # remove element that holds path to cached_downloads json file + command = command[:-1] + + # for the now last element (value of --run) ensure it is wrapped in quotations (only relevant for blocktest) # noqa: E501 + if "blocktest" in command: + if command[-1][0] not in {"'", '"'}: + command[-1] = '"' + command[-1] + '"' + + # instead add path to fixtures.json file + debug_fixture_path = str(debug_output_path / "fixtures.json") + # but only after fixing the unescaped brackets + debug_fixture_path.replace("[", r"\[").replace("]", r"\]") + command.append(debug_fixture_path) + + # now turn list into a command string + consume_direct_call = " ".join(command) + consume_direct_script = textwrap.dedent( f"""\ #!/bin/bash diff --git a/src/ethereum_clis/clis/nethermind.py b/src/ethereum_clis/clis/nethermind.py index 86a1dd0c4de..f4099238405 100644 --- a/src/ethereum_clis/clis/nethermind.py +++ b/src/ethereum_clis/clis/nethermind.py @@ -55,13 +55,31 @@ def _consume_debug_dump( result: subprocess.CompletedProcess, debug_output_path: Path, ): - consume_direct_call = " ".join(command) + # our assumption is that each command element is a string + assert all(isinstance(x, str) for x in command), ( + f"Not all elements of 'command' list are strings: {command}" + ) + + # ensure that the --filter flag value is wrapped in double-quotes + consume_direct_call = "" + prev_command_was_filter_flag = False + for s in command: + if prev_command_was_filter_flag: + if s[0] != '"': + s = '"' + s + '"' + prev_command_was_filter_flag = False + consume_direct_call += s + " " + if s.strip() == "--filter": + prev_command_was_filter_flag = True + consume_direct_call = consume_direct_call.strip() + consume_direct_script = textwrap.dedent( f"""\ #!/bin/bash {consume_direct_call} """ ) + dump_files_to_directory( str(debug_output_path), {