osmith has submitted this change. ( 
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(-)

Approvals:
  osmith: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




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)

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/41868?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I508322b017e5ed9c21396384ef759a4c49c8d3da
Gerrit-Change-Number: 41868
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to