From 6ded240089afd29af3c050ad19a5d4a5e0db647d Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 14 Mar 2023 14:46:36 -0700 Subject: [PATCH] Add t_rc test execution helper function Add a quick wrapper to run commands whose output is saved while only echoing their return code. Signed-off-by: Zach Brown --- tests/funcs/exec.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/funcs/exec.sh b/tests/funcs/exec.sh index 379f1ea5..06d4c96b 100644 --- a/tests/funcs/exec.sh +++ b/tests/funcs/exec.sh @@ -39,6 +39,18 @@ t_quiet() t_fail "quiet command failed" } +# +# Quietly run a command during a test. The output is logged but only +# the return code is printed, presumably because the output contains +# a lot of invocation specific text that is difficult to filter. +# +t_rc() +{ + echo "# $*" >> "$T_TMP.rc.log" + "$@" >> "$T_TMP.rc.log" 2>&1 + echo "rc: $?" +} + # # redirect test output back to the output of the invoking script intead # of the compared output.