Skip to content

Commit 205473a

Browse files
committed
strict UTs execution
propagate non-zero exit code if any of the tests failed
1 parent 7219fc7 commit 205473a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/run_unit_tests.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ declare -A UT_TARGET_GROUPS=(
2222
# Markdown table header
2323
echo -e "Status\tPassed\tFailed\tSkipped\tTotal\tGroup\tDuration(s)" >> "${SUMMARY_FILE}"
2424

25+
# Track if any test failed
26+
any_failed=0
27+
2528
for group in "${!UT_TARGET_GROUPS[@]}"; do
2629
targets="${UT_TARGET_GROUPS[$group]}"
2730
command="bazel test --config="${CONFIG}" ${targets}"
@@ -44,13 +47,20 @@ for group in "${!UT_TARGET_GROUPS[@]}"; do
4447
status_symbol=""
4548
else
4649
status_symbol=""
50+
any_failed=1
4751
fi
4852

4953
# Append as a markdown table row
50-
echo -e "${status_symbol}\t${tests_passed}\t${tests_failed}\t${tests_skipped}\t${tests_executed}\t${group}\t${duration}s" >> "${SUMMARY_FILE}"
54+
echo -e "${status_symbol}\t${tests_passed}\t${tests_failed}\t${tests_skipped}\t${tests_executed}\t${group}\t${duration}s" | tee -a "${SUMMARY_FILE}"
5155
echo "==========================================="
5256
echo -e "\n\n"
5357
done
5458

5559
# Align the summary table columns
5660
column -t -s $'\t' "${SUMMARY_FILE}" > "${SUMMARY_FILE}.tmp" && mv "${SUMMARY_FILE}.tmp" "${SUMMARY_FILE}"
61+
62+
# Final check: exit with non-zero if any test failed
63+
if [[ $any_failed -ne 0 ]]; then
64+
echo "Some unit test groups failed. Exiting with non-zero status."
65+
exit 1
66+
fi

0 commit comments

Comments
 (0)