From 75e13ee23543fbd301db2655693aabeb53d78a6b Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sat, 11 Feb 2017 13:19:49 -0800 Subject: [PATCH] test-lib-main.sh: keep same exit code with --tee Use of --tee (or --verbose-log) causes the test to be re-spawned to capature output (both stdout and stderr) into a file. Make sure that the same exit code is propagated up rather than stepping on it so that the same result occurs whether or not --tee is used. Signed-off-by: Kyle J. McKay --- t/test-lib-main.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/t/test-lib-main.sh b/t/test-lib-main.sh index 85d5427..65494ce 100644 --- a/t/test-lib-main.sh +++ b/t/test-lib-main.sh @@ -666,11 +666,12 @@ done,*) # Truncate before calling "tee -a" to get rid of the results # from any previous runs. >"$TESTLIB_TEST_TEE_OUTPUT_FILE" + >"$BASE.exit" - (TESTLIB_TEST_TEE_STARTED=done ${SHELL_PATH} "$0" "$@" 2>&1; - echo $? >"$BASE.exit") | tee -a "$TESTLIB_TEST_TEE_OUTPUT_FILE" - test "$(cat "$BASE.exit")" = 0 - exit + (ec=0; TESTLIB_TEST_TEE_STARTED=done ${SHELL_PATH} "$0" "$@" 2>&1 || ec=$? + echo $ec >"$BASE.exit") | tee -a "$TESTLIB_TEST_TEE_OUTPUT_FILE" + exitcode="$(cat "$BASE.exit" 2>/dev/null)" || : + exit ${exitcode:-1} ;; esac -- 2.11.4.GIT