Skip to content

Commit

Permalink
fix: Properly propagate test exit status through the script chain. Pa…
Browse files Browse the repository at this point in the history
…ss executable path instead of target
  • Loading branch information
gr0vity committed Dec 9, 2024
1 parent 80212f4 commit 948662a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
20 changes: 13 additions & 7 deletions ci/tests/run-gtest-parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
test_status=$?
fi

# Return the original test exit status
exit $test_status
5 changes: 3 additions & 2 deletions ci/tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 948662a

Please sign in to comment.