Skip to content

Commit e10402c

Browse files
committed
added strictness
1 parent 1b77a12 commit e10402c

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

scripts/run_unit_tests.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare -A UT_TARGET_GROUPS=(
1313
-@score_baselibs//score/language/safecpp/aborts_upon_exception:abortsuponexception_toolchain_test \
1414
-@score_baselibs//score/containers:dynamic_array_test \
1515
-@score_baselibs//score/mw/log/configuration:* \
16-
-@score_baselibs//score/json/examples:*"
16+
-@score_baselibs//score/json/examples:*"
1717
[communication]="@score_communication//score/mw/com/impl/... -- \
1818
-@score_communication//score/mw/com/impl:unit_test_runtime_single_exec \
1919
-@score_communication//score/mw/com/impl/configuration:config_parser_test \
@@ -28,6 +28,9 @@ declare -A UT_TARGET_GROUPS=(
2828
# Markdown table header
2929
echo -e "Status\tPassed\tFailed\tSkipped\tTotal\tGroup\tDuration(s)" >> "${SUMMARY_FILE}"
3030

31+
# Track if any test failed
32+
any_failed=0
33+
3134
for group in "${!UT_TARGET_GROUPS[@]}"; do
3235
targets="${UT_TARGET_GROUPS[$group]}"
3336
command="bazel test --config="${CONFIG}" ${targets}"
@@ -36,11 +39,11 @@ for group in "${!UT_TARGET_GROUPS[@]}"; do
3639
echo "${command}"
3740
echo "==========================================="
3841
start_ts=$(date +%s)
39-
out=$(bazel test --test_summary=testcase --test_output=errors --nocache_test_results --config="${CONFIG}" ${targets} 2>&1 | tee "${LOG_DIR}/ut_${group}_output.log")
42+
out=$(bazel test --test_summary=testcase --test_output=errors --nocache_test_results --config="${CONFIG}" ${targets} 2>&1 | tee "${LOG_DIR}/ut_${group}_output.log")
4043
build_status=${PIPESTATUS[0]}
4144
end_ts=$(date +%s)
4245
duration=$(( end_ts - start_ts ))
43-
46+
4447
# Parse bazel output
4548
tests_passed=$(echo "$out" | grep -Eo '[0-9]+ passing' | grep -Eo '[0-9]+' | head -n1)
4649
tests_failed=$(echo "$out" | grep -Eo '[0-9]+ failing' | grep -Eo '[0-9]+' | head -n1)
@@ -50,13 +53,20 @@ for group in "${!UT_TARGET_GROUPS[@]}"; do
5053
status_symbol=""
5154
else
5255
status_symbol=""
56+
any_failed=1
5357
fi
54-
58+
5559
# Append as a markdown table row
56-
echo -e "${status_symbol}\t${tests_passed}\t${tests_failed}\t${tests_skipped}\t${tests_executed}\t${group}\t${duration}s" >> "${SUMMARY_FILE}"
60+
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}"
5761
echo "==========================================="
5862
echo -e "\n\n"
5963
done
6064

6165
# Align the summary table columns
6266
column -t -s $'\t' "${SUMMARY_FILE}" > "${SUMMARY_FILE}.tmp" && mv "${SUMMARY_FILE}.tmp" "${SUMMARY_FILE}"
67+
68+
# Final check: exit with non-zero if any test failed
69+
if [[ $any_failed -ne 0 ]]; then
70+
echo "Some unit test groups failed. Exiting with non-zero status."
71+
exit 1
72+
fi

0 commit comments

Comments
 (0)