Skip to content

Commit 65ea52b

Browse files
sawenzelclaude
andcommitted
Replace the flag-forwarding grep heuristic with an explicit table
This fixes run_tests.sh forwarding flags to sub-test scripts by grepping their source instead of knowing which flags each one accepts. - The grep matched a flag string in a comment as readily as in real argument parsing, and never matched at all against the selection harness's stub scripts, so the forwarding logic was untested. - Only run_generator_tests.sh accepts --fail-immediately and --keep-artifacts; run_workflow_tests.sh and run_relval_tests.sh only accept --help/-h. Forwarding is now a plain case on the sub-test name. - Extended the stub scripts in the selection harness to record their received arguments, and added a case asserting --keep-artifacts reaches the generator stub and not the workflow or relval stubs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 6dbec8d commit 65ea52b

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎test/run_tests.sh‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ for subtest in "${selected[@]}" ; do
6868
fi
6969
echo
7070
echo "==> START SUBTEST: ${subtest} <=="
71-
forward=()
72-
for arg in "${subtest_args[@]:-}" ; do
73-
[[ -z "${arg}" ]] && continue
74-
grep -q -- "${arg}" "${script}" && forward+=("${arg}")
75-
done
71+
# Only run_generator_tests.sh accepts --fail-immediately/--keep-artifacts;
72+
# run_workflow_tests.sh and run_relval_tests.sh accept only --help/-h.
73+
case ${subtest} in
74+
generator ) forward=("${subtest_args[@]:-}") ;;
75+
* ) forward=() ;;
76+
esac
7677
"${script}" "${forward[@]}"
7778
ret_this=$?
7879
echo "==> END SUBTEST: ${subtest} (exit ${ret_this}) <=="

‎test/tests/run_tests_selection.sh‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ check()
1818
fi
1919
}
2020

21-
# A stub directory with three scripts whose exit codes we control via env vars.
21+
# A stub directory with three scripts whose exit codes we control via env
22+
# vars, and which each record the arguments they received to a sibling
23+
# "*.args" file (one per line) so forwarding can be checked.
2224
make_stubs()
2325
{
2426
local dir=$1
@@ -27,6 +29,7 @@ make_stubs()
2729
cat > "${dir}/run_${name}_tests.sh" <<EOF
2830
#!/bin/bash
2931
echo "STUB ${name} ran"
32+
printf '%s\n' "\$@" > '${dir}/run_${name}_tests.args'
3033
exit \${STUB_${name^^}_RC:-0}
3134
EOF
3235
chmod +x "${dir}/run_${name}_tests.sh"
@@ -73,6 +76,15 @@ check "fail-immediately stops early" 0 "$(grep -c 'STUB relval ran' <<< "${OUT}"
7376
STUB_RELVAL_RC=4 run_entry "${TMP}/subtests"
7477
check "late failure propagates" 4 "${RC}"
7578

79+
# 6. flag forwarding is per sub-test: only "generator" accepts these flags
80+
run_entry "${TMP}/subtests" --keep-artifacts
81+
check "keep-artifacts reaches generator" \
82+
1 "$(grep -cx -- '--keep-artifacts' "${TMP}/subtests/run_generator_tests.args")"
83+
check "keep-artifacts does not reach workflow" \
84+
0 "$(grep -cx -- '--keep-artifacts' "${TMP}/subtests/run_workflow_tests.args")"
85+
check "keep-artifacts does not reach relval" \
86+
0 "$(grep -cx -- '--keep-artifacts' "${TMP}/subtests/run_relval_tests.args")"
87+
7688
echo
7789
if [[ "${FAILURES}" == "0" ]] ; then
7890
echo "All run_tests.sh selection tests passed"

0 commit comments

Comments
 (0)