osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/41868?usp=email )
Change subject: testenv: less cluttered output for failed cmds ......................................................................
testenv: less cluttered output for failed cmds
The testenv.cmd.run() already prints the command to run at the start, prints the command output and blocks until the command is done.
If the command fails, do not print the command again, and do not print a python stack trace. The reason for the failure is most likely in the output shown by the program itself (e.g. a prepare= script that failed). Make it easier for the user to spot this error by uncluttering the output.
Change-Id: I508322b017e5ed9c21396384ef759a4c49c8d3da --- M _testenv/testenv/cmd.py 1 file changed, 4 insertions(+), 11 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/68/41868/1
diff --git a/_testenv/testenv/cmd.py b/_testenv/testenv/cmd.py index c14f694..bde0bf3 100644 --- a/_testenv/testenv/cmd.py +++ b/_testenv/testenv/cmd.py @@ -1,10 +1,11 @@ -# Copyright 2024 sysmocom - s.f.m.c. GmbH +# Copyright 2026 sysmocom - s.f.m.c. GmbH # SPDX-License-Identifier: GPL-3.0-or-later import logging import os import os.path import re import subprocess +import sys import testenv import testenv.testsuite
@@ -79,15 +80,6 @@ env_extra["TESTENV_QEMU_SCRIPTS"] = os.path.join(testenv.data_dir, "scripts/qemu")
-def exit_error_cmd(completed, error_msg): - """:param completed: return from run_cmd() below""" - - logging.error(error_msg) - logging.debug(f"Command: {completed.args}") - logging.debug(f"Returncode: {completed.returncode}") - raise RuntimeError("shell command related error, find details right above this python trace") - - def generate_env(env={}, podman=False): ret = dict(env_extra) path = os.path.join(testenv.data_dir, "scripts") @@ -139,4 +131,5 @@ if p.returncode == 0 or not check: return p
- exit_error_cmd(p, "Command failed unexpectedly") + logging.error(f"Command failed unexpectedly (returncode: {p.returncode})") + sys.exit(1)