forked from bchanot/claude
fix(tests): hook-running suites stub the claude CLI fail-closed
Inline stubs ran claude probe before checking the stub won PATH, and three suites ran the hook with no stub. A shared helper checks resolution, controls from another cwd and exits on any miss (BLK-043 family).
This commit is contained in:
1 parent
d93f06cb9b
commit
dc5f127ea5
8 files changed
+124
-34
No files matched your search
@@ -4,7 +4,7 @@
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
SS="$ROOT/hooks/session-start.sh"
|
||||
WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
|
||||
WORK="$(mktemp -d)" || exit 1; trap 'rm -rf "$WORK"' EXIT
|
||||
export SESSION_START_OFFLINE=1
|
||||
pass=0; fail=0
|
||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
@@ -12,16 +12,9 @@ check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
|
||||
# Stub claude (BLK-043): a hook run that calls the CLI logs a line here
|
||||
# instead of starting a session that re-runs this hook.
|
||||
CLAUDE_LOG="$WORK/claude.log"; : >"$CLAUDE_LOG"
|
||||
mkdir -p "$WORK/stub"
|
||||
printf '#!/bin/sh\necho "$*" >>"%s"\n' "$CLAUDE_LOG" >"$WORK/stub/claude"
|
||||
chmod +x "$WORK/stub/claude"
|
||||
export PATH="$WORK/stub:$PATH"
|
||||
calls() { wc -l <"$CLAUDE_LOG" | tr -d ' '; }
|
||||
# SD0: positive control, the stub is reached through PATH
|
||||
claude probe
|
||||
check SD0-stub-reached "$(calls)" 1
|
||||
: >"$CLAUDE_LOG"
|
||||
# shellcheck source=lib/tests/claude-stub.sh
|
||||
. "$ROOT/lib/tests/claude-stub.sh"
|
||||
claude_stub_install "$WORK"
|
||||
|
||||
# mkproj <name> -> path with an empty memory dir
|
||||
mkproj() {
|
||||
@@ -251,7 +244,7 @@ check SD14d-banner "$(run "$p" "$WORK/startup.json" | grep -c '^$')" \
|
||||
"$(run "$p" "$WORK/startup.json" | grep -c '^$')"
|
||||
|
||||
# SD15: no hook run of this suite called the claude CLI (BLK-043)
|
||||
check SD15-no-claude-calls "$(calls)" 0
|
||||
check SD15-no-claude-calls "$(claude_stub_calls)" 0
|
||||
|
||||
printf 'session-digest: %d passed, %d failed\n' "$pass" "$fail"
|
||||
[ "$fail" -eq 0 ]
|
||||
Reference in new issue
Block a user