Skip to content

Commit 09a1faa

Browse files
sawenzelclaude
andcommitted
Add a regression guard for the dropped-aggregate exit-code bug
This adds a static test that catches an aggregate return-code variable being dropped from run_workflow_tests.sh's final RET= line, the exact bug class Task 1 fixed for ret_global_pwg. - test/tests/exit_code_aggregation.sh checks that RET= includes all three known aggregate variables (ret_global_pwg, ret_analysis_qc, ret_global_anchored), by an explicit hard-coded list. - It also checks that each of the three is actually assigned somewhere in the script, since a name missing from the RET= line and a name never assigned are different bugs with the same symptom. - No refactor of run_workflow_tests.sh; the guard reads it as a fixture, it does not stub or execute it. - test/README.md now lists the new harness beside run_tests_selection.sh. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent d16fc4c commit 09a1faa

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎test/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ exit-code aggregation without needing an O2 environment:
7373

7474
```bash
7575
bash test/tests/run_tests_selection.sh
76+
bash test/tests/exit_code_aggregation.sh
7677
```
7778

7879
### Keeping all test artifacts
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# Static guard against the exit-code-aggregation bug in run_workflow_tests.sh:
3+
# the final RET=$(( ... )) line must include every aggregate return-code
4+
# variable the script computes, and each of those variables must actually be
5+
# assigned somewhere in the script.
6+
7+
set -u
8+
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
9+
SCRIPT=${O2DPG_TEST_WORKFLOW_SCRIPT:-"${HERE}/../run_workflow_tests.sh"}
10+
FAILURES=0
11+
12+
check()
13+
{
14+
local label=$1 expected=$2 actual=$3
15+
if [[ "${expected}" == "${actual}" ]] ; then
16+
echo "ok - ${label}"
17+
else
18+
echo "FAIL - ${label}: expected '${expected}', got '${actual}'"
19+
FAILURES=$((FAILURES + 1))
20+
fi
21+
}
22+
23+
# The three aggregate return-code variables the final exit code must include.
24+
# Explicit and hard-coded on purpose: a fourth aggregate added later must make
25+
# whoever adds it come here and update this list.
26+
REQUIRED_VARS="ret_global_pwg ret_analysis_qc ret_global_anchored"
27+
28+
RET_LINE=$(grep -m1 -E '^RET=\$\(\(' "${SCRIPT}")
29+
30+
for var in ${REQUIRED_VARS} ; do
31+
present=$(grep -c -- "${var}" <<< "${RET_LINE}")
32+
check "RET= line includes ${var}" 1 "${present}"
33+
done
34+
35+
for var in ${REQUIRED_VARS} ; do
36+
assigned=$(grep -c -E "^[[:space:]]*${var}=" "${SCRIPT}")
37+
check "${var} is assigned in the script" 1 "$( [[ "${assigned}" -ge 1 ]] && echo 1 || echo 0 )"
38+
done
39+
40+
echo
41+
if [[ "${FAILURES}" == "0" ]] ; then
42+
echo "All exit-code aggregation checks passed"
43+
else
44+
echo "${FAILURES} test(s) failed"
45+
fi
46+
exit $(( FAILURES > 0 ? 1 : 0 ))

0 commit comments

Comments
 (0)