From 948662a3b9de1c3f229c2c4ec9ec120cdc982e09 Mon Sep 17 00:00:00 2001 From: gr0vity Date: Mon, 9 Dec 2024 06:57:04 +0100 Subject: [PATCH] fix: Properly propagate test exit status through the script chain. Pass executable path instead of target --- ci/tests/run-gtest-parallel.sh | 20 +++++++++++++------- ci/tests/run-tests.sh | 5 +++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ci/tests/run-gtest-parallel.sh b/ci/tests/run-gtest-parallel.sh index 082197e138..d48abd2cb3 100755 --- a/ci/tests/run-gtest-parallel.sh +++ b/ci/tests/run-gtest-parallel.sh @@ -3,23 +3,29 @@ set -euo pipefail source "$(dirname "$BASH_SOURCE")/common.sh" -target=$1 -if [ -z "${target-}" ]; then - echo "Target not specified" +executable=$1 +if [ -z "${executable-}" ]; then + echo "Executable not specified" exit 1 fi shift -executable=./${target}$(get_exec_extension) # Get the project root directory (2 levels up from ci/tests) PROJECT_ROOT="$(cd "$(dirname "$BASH_SOURCE")/../.." && pwd)" GTEST_PARALLEL="${PROJECT_ROOT}/submodules/gtest-parallel/gtest-parallel" if [ -f "${GTEST_PARALLEL}" ]; then - echo "Running tests with gtest-parallel for target: ${target}" + echo "Running tests with gtest-parallel for executable: ${executable}" + # Redirect stderr to both stderr and a file to capture sanitizer output "${GTEST_PARALLEL}" "${executable}" --worker=1 "$@" + test_status=$? else - echo "gtest-parallel not found at ${GTEST_PARALLEL}, running tests directly for target: ${target}" + echo "gtest-parallel not found at ${GTEST_PARALLEL}, running tests directly for executable: ${executable}" + # Redirect stderr to both stderr and a file to capture sanitizer output "${executable}" "$@" -fi \ No newline at end of file + test_status=$? +fi + +# Return the original test exit status +exit $test_status \ No newline at end of file diff --git a/ci/tests/run-tests.sh b/ci/tests/run-tests.sh index 4d95f861d4..c322bba26c 100755 --- a/ci/tests/run-tests.sh +++ b/ci/tests/run-tests.sh @@ -46,10 +46,11 @@ case "$(uname -s)" in ;; esac -# Run the test using gtest-parallel helper shift executable=./${target}$(get_exec_extension) -"$(dirname "$BASH_SOURCE")/run-gtest-parallel.sh" "${target}" "$@" + +# Run the test using gtest-parallel helper +"$(dirname "$BASH_SOURCE")/run-gtest-parallel.sh" "${executable}" "$@" status=$? if [ $status -ne 0 ]; then