Skip to content

Commit e0d229f

Browse files
committed
test(hook): assert the seam precondition and self-diagnose CI failures
The conflict regression went red on six CI legs with an unhelpful message: every probe produced empty stderr, which reads as "the notice is missing" when it actually means no conflict was ever raised. Three changes, all diagnosis rather than tolerance: - Assert the binary carries the hook-client seam up front, failing with the rebuild hint, exactly as tests/test_worker_watchdog.sh does for the crash-orphan probe. A seam-less binary can never raise the conflict, and that must be said plainly rather than inferred from a silent backstop expiry. - Drop the `seq`-derived fingerprint for a literal 64-char constant (length-checked), removing a dependency on a tool whose presence varies across the MSYS2/macOS/Linux legs. - On backstop expiry, dump stdout, the forced fingerprint and its length, and daemon status, so the next run names the cause instead of requiring another round trip. Still green locally (seam-bearing binary): the conflict is observed and the systemMessage asserted. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 92e5983 commit e0d229f

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

‎tests/test_hook_conflict_notice.sh‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ if [[ ! -x "${BINARY}" ]]; then
1616
exit 2
1717
fi
1818

19+
# PRECONDITION, not a skip (same doctrine as tests/test_worker_watchdog.sh): this
20+
# test drives the hook-client build seam, which is compiled out of ordinary
21+
# builds. Against a seam-less binary no conflict can ever occur and the failure
22+
# would read as "the notice is missing" instead of "the capability is absent".
23+
if ! LC_ALL=C grep -a -q -F 'CBM_TEST_HOOK_CLIENT_BUILD' "${BINARY}"; then
24+
echo "binary lacks the hook-client build seam: ${BINARY}" >&2
25+
echo " rebuild it with: make -f Makefile.cbm cbm TEST_SEAMS=1" >&2
26+
echo " or run this test through scripts/test.sh, which does that for you." >&2
27+
exit 2
28+
fi
29+
1930
tmpdir="$(mktemp -d)"
2031
cleanup() {
2132
CBM_CACHE_DIR="${tmpdir}/cache" "${BINARY}" daemon stop >/dev/null 2>&1 || true
@@ -29,7 +40,11 @@ if ! CBM_CACHE_DIR="${tmpdir}/cache" "${BINARY}" daemon start >"${tmpdir}/daemon
2940
exit 2
3041
fi
3142
payload='{"session_id":"probe","hook_event_name":"PreToolUse","tool_name":"Grep","tool_input":{"pattern":"x","path":"/tmp"},"cwd":"/tmp"}'
32-
forced_build="$(printf 'f%.0s' $(seq 1 64))"
43+
forced_build="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
44+
if [[ ${#forced_build} -ne 64 ]]; then
45+
echo "internal: forced fingerprint must be 64 hex chars, got ${#forced_build}" >&2
46+
exit 2
47+
fi
3348

3449
# The daemon's cohort join completes asynchronously after `daemon start`
3550
# returns. Wait for the STATE the assertion needs - a probe that observes the
@@ -62,8 +77,14 @@ if ! grep -q "conflicting CBM process" "${tmpdir}/probe.err"; then
6277
echo "never became active, or this is not a TEST_SEAMS=1 binary" >&2
6378
echo "--- daemon-start.log ---" >&2
6479
cat "${tmpdir}/daemon-start.log" >&2
65-
echo "--- last probe stderr ---" >&2
80+
echo "--- last probe stderr (empty means no conflict was raised) ---" >&2
6681
cat "${tmpdir}/probe.err" >&2
82+
echo "--- last probe stdout ---" >&2
83+
printf '%s\n' "${out}" >&2
84+
echo "--- diagnosis ---" >&2
85+
echo "forced_build=${forced_build} (len ${#forced_build})" >&2
86+
echo "seam present in binary: yes (asserted above)" >&2
87+
CBM_CACHE_DIR="${tmpdir}/cache" "${BINARY}" daemon status >&2 2>&1 || true
6788
exit 2
6889
fi
6990
if ! printf '%s' "${out}" | grep -q "systemMessage"; then

0 commit comments

Comments
 (0)