Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cardano_node_tests/utils/cluster_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def start_cluster(cmd: str, args: list[str]) -> clusterlib.ClusterLib:
args_str = " ".join(args)
args_str = f" {args_str}" if args_str else ""
LOGGER.info(f"Starting cluster with `{cmd}{args_str}`.")
helpers.run_command(f"{cmd}{args_str}", workdir=get_cluster_env().work_dir)
helpers.run_command(f"{cmd}{args_str}", workdir=get_cluster_env().work_dir, merge_stderr=True)
LOGGER.info("Cluster started.")
return get_cluster_type().get_cluster_obj()

Expand Down
11 changes: 7 additions & 4 deletions cardano_node_tests/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def run_command(
workdir: ttypes.FileType = "",
ignore_fail: bool = False,
shell: bool = False,
merge_stderr: bool = False,
) -> bytes:
"""Run command."""
cmd: str | list
if isinstance(command, str):
cmd = command if shell else command.split()
cmd_str = command
Expand All @@ -94,14 +94,17 @@ def run_command(
LOGGER.debug("Running `%s`", cmd_str)

with subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=shell, cwd=workdir or None
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT if merge_stderr else subprocess.PIPE,
shell=shell,
cwd=workdir or None,
) as p:
stdout, stderr = p.communicate()
retcode = p.returncode

if not ignore_fail and retcode != 0:
err_dec = stderr.decode()
err_dec = err_dec or stdout.decode()
err_dec = (stderr or stdout).decode()
msg = f"An error occurred while running `{cmd_str}`: {err_dec}"
raise RuntimeError(msg)

Expand Down
Loading