forked from bchanot/claude
fix(tests): gate round, fail-closed sources and gitflow-test mktemp
gitflow-test aborts on a failed mktemp or newrepo before its reset --hard; helper sources exit on failure; no lint suppression left; T19c reads a real registry; doctrine rewrapped.
This commit is contained in:
1 parent
c5bd0f8312
commit
7ca6b18f08
11 files changed
+29
-21
No files matched your search
@@ -35,7 +35,7 @@ cat > "$FX/bin/claude" <<'EOT'
|
||||
EOT
|
||||
chmod +x "$FX/bin/"*
|
||||
# shellcheck source=lib/tests/claude-stub.sh
|
||||
. "$ROOT/lib/tests/claude-stub.sh"
|
||||
. "$ROOT/lib/tests/claude-stub.sh" || exit 1
|
||||
for c in claude systemd-run dtach; do
|
||||
PATH="$FX/bin:$PATH" stub_first_or_die "$c" "$FX/bin/$c"
|
||||
done
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# lib/tests/claude-stub.test.sh
|
||||
# Regression for BLK-043 residuals: claude_stub_install must fail closed
|
||||
# (never leave the real claude CLI first on PATH) and survive a relative dir.
|
||||
# shellcheck disable=SC1090,SC2329 # HELPER override; chmod shadow is called by the helper
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
HELPER="${CLAUDE_STUB_LIB:-$ROOT/lib/tests/claude-stub.sh}"
|
||||
@@ -17,8 +16,11 @@ check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
mkdir -p "$WORK/a/work" "$WORK/a/fake"
|
||||
printf '#!/bin/sh\ntouch "%s"\n' "$WORK/a/sentinel" >"$WORK/a/fake/claude"
|
||||
chmod +x "$WORK/a/fake/claude"
|
||||
err=$( ( chmod() { :; }; PATH="$WORK/a/fake:$PATH"
|
||||
. "$HELPER"; claude_stub_install "$WORK/a/work" ) 2>&1 >/dev/null )
|
||||
mkdir -p "$WORK/a/noop"
|
||||
printf '#!/bin/sh\nexit 0\n' >"$WORK/a/noop/chmod"
|
||||
/usr/bin/chmod +x "$WORK/a/noop/chmod"
|
||||
err=$( PATH="$WORK/a/noop:$WORK/a/fake:$PATH" bash -c \
|
||||
'. "$1"; claude_stub_install "$2"' _ "$HELPER" "$WORK/a/work" 2>&1 >/dev/null )
|
||||
rc=$?
|
||||
check Ta-rc "$rc" 1
|
||||
case "$err" in *"claude stub not first on PATH"*) m=yes ;; *) m=no ;; esac
|
||||
@@ -27,12 +29,14 @@ check Ta-sentinel-absent "$([ -e "$WORK/a/sentinel" ] && echo yes || echo no)" n
|
||||
|
||||
# (b) relative dir: the stub still resolves after a cd elsewhere.
|
||||
mkdir -p "$WORK/b/rel"
|
||||
# shellcheck source=lib/tests/claude-stub.sh
|
||||
got=$( cd "$WORK/b" && . "$HELPER" && claude_stub_install rel \
|
||||
&& cd / && command -v claude )
|
||||
check Tb-relative-resolves "$got" "$WORK/b/rel/stub/claude"
|
||||
|
||||
# (c) happy path
|
||||
mkdir -p "$WORK/c"
|
||||
# shellcheck source=lib/tests/claude-stub.sh
|
||||
out=$( . "$HELPER"; claude_stub_install "$WORK/c" && claude_stub_calls )
|
||||
check Tc-happy "$out" 0
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
|
||||
# Stub claude: logs every call, never starts a session; fails closed.
|
||||
# shellcheck source=lib/tests/claude-stub.sh
|
||||
. "$ROOT/lib/tests/claude-stub.sh"
|
||||
. "$ROOT/lib/tests/claude-stub.sh" || exit 1
|
||||
claude_stub_install "$WORK"
|
||||
|
||||
# detect_plan, no .claude.json: pro, no claude call.
|
||||
|
||||
@@ -4,7 +4,8 @@ set -u
|
||||
LIB="$(cd "$(dirname "$0")/../.." && pwd)/lib/graphify-gate.sh"
|
||||
WORK="$(mktemp -d)" || exit 1; trap 'rm -rf "$WORK"' EXIT
|
||||
pass=0; fail=0
|
||||
. "$(dirname "$0")/claude-stub.sh"
|
||||
# shellcheck source=lib/tests/claude-stub.sh
|
||||
. "$(dirname "$0")/claude-stub.sh" || exit 1
|
||||
mkdir -p "$WORK/cs" || exit 1
|
||||
claude_stub_install "$WORK/cs"
|
||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
|
||||
@@ -689,7 +689,7 @@ done
|
||||
# Stub work dir outside $FIX: the fixture repo's `git add -A` must not
|
||||
# commit the stub. Installed here so earlier cases see the repo unceilinged.
|
||||
# shellcheck source=lib/tests/claude-stub.sh
|
||||
. "$ROOT/lib/tests/claude-stub.sh"
|
||||
. "$ROOT/lib/tests/claude-stub.sh" || exit 1
|
||||
CSW=$(mktemp -d) || exit 1; trap 'rm -rf "$FIX" "$CSW"' EXIT
|
||||
claude_stub_install "$CSW"
|
||||
banner() { (cd "$1" && SESSION_START_OFFLINE=1 bash "$ROOT/hooks/session-start.sh" \
|
||||
@@ -722,9 +722,10 @@ check T19-assign-body-heading-rc "$?/$(cksum < .claude/memory/learnings.md)" "2/
|
||||
printf 'clean-eq-body\n' > 'x=1.md'
|
||||
bash "$MEM" add learning --title eq --body-file x=1.md </dev/null >/dev/null 2>&1
|
||||
check T19b-assign-body-written "$(grep -c '^clean-eq-body$' .claude/memory/learnings.md)" 1
|
||||
mkdir 'a=b' && printf '# Decisions\n\n## BDR-001 - legacy\n' > 'a=b/decisions.md'
|
||||
mkdir 'a=b'
|
||||
printf -- '---\nformat: 2\ntype: decisions_registry\nentry_prefix: BDR\n---\n\n# D\n\n## BDR-001 - bad\n' > 'a=b/decisions.md'
|
||||
err=$(bash "$MEM" check 'a=b' 2>&1 >/dev/null </dev/null)
|
||||
check T19c-assign-dir-read "$(printf '%s\n' "$err" | grep -c '^memory: v1: ./a=b/decisions.md$')" 1
|
||||
check T19c-assign-dir-read "$(printf '%s\n' "$err" | grep -c '^memory: ./a=b/decisions.md:9: heading shape: ## BDR-001 - bad$')" 1
|
||||
|
||||
check no-claude-calls "$(claude_stub_calls)" 0
|
||||
echo "PASS=$pass FAIL=$fail"
|
||||
|
||||
@@ -353,7 +353,7 @@ check T43b-clearance "$(grep -c "does not clear it: the user types \`! git push\
|
||||
|
||||
# ── session banner ──
|
||||
# shellcheck source=lib/tests/claude-stub.sh
|
||||
. "$ROOT/lib/tests/claude-stub.sh"
|
||||
. "$ROOT/lib/tests/claude-stub.sh" || exit 1
|
||||
mkdir -p "$WORK/cs" || exit 1
|
||||
claude_stub_install "$WORK/cs"
|
||||
banner() { # banner <dir>
|
||||
|
||||
@@ -13,7 +13,7 @@ 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.
|
||||
# shellcheck source=lib/tests/claude-stub.sh
|
||||
. "$ROOT/lib/tests/claude-stub.sh"
|
||||
. "$ROOT/lib/tests/claude-stub.sh" || exit 1
|
||||
claude_stub_install "$WORK"
|
||||
|
||||
# mkproj <name> -> path with an empty memory dir
|
||||
|
||||
Reference in new issue
Block a user