kb-test: exercise the git-path ledger and HEAD baseline in a throwaway repo
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
@@ -709,5 +709,39 @@ else
|
|||||||
ok "a recorded rm stays excused across the tool's later writes"
|
ok "a recorded rm stays excused across the tool's later writes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 25. The production paths, which every case above bypasses by setting KB_FILE:
|
||||||
|
# the baseline is `git show HEAD` and the ledger is `git rev-parse
|
||||||
|
# --git-path`. Run in a throwaway repo holding a copy of the tool.
|
||||||
|
r="$work/repo"
|
||||||
|
mkdir -p "$r/scripts" "$r/prolog-sessions"
|
||||||
|
cp "$here/kb" "$here/kb-merge.pl" "$r/scripts/"
|
||||||
|
cp "$KB" "$r/prolog-sessions/kb.pl"
|
||||||
|
g() { git -C "$r" -c user.name=kb-test -c user.email=kb-test@invalid "$@"; }
|
||||||
|
rkb() { (unset KB_FILE KB_BASELINE; "$r/scripts/kb" "$@"); }
|
||||||
|
if ! { g init -q && g add -A && g commit -qm base; } >/dev/null 2>&1; then
|
||||||
|
bad "could not build the throwaway repo -- case 25 proves nothing"
|
||||||
|
elif ! rkb rm "$work/drop-x.pl" >"$work/out" 2>&1; then
|
||||||
|
bad "rm in a real repo was refused: $(tail -1 "$work/out")"
|
||||||
|
else
|
||||||
|
ledger="$(g rev-parse --path-format=absolute --git-path kb-removed.pl)"
|
||||||
|
if ! grep -q "^location(cli_args," "$ledger" 2>/dev/null; then
|
||||||
|
bad "rm in a real repo did not record its removal at the git-path ledger"
|
||||||
|
elif [ "$(g status --porcelain --untracked-files=all)" != " M prolog-sessions/kb.pl" ]; then
|
||||||
|
bad "the real-repo write left something git sees: $(g status --porcelain --untracked-files=all | tr '\n' ' ')"
|
||||||
|
elif ! rkb add "$work/new.pl" >"$work/out" 2>&1; then
|
||||||
|
bad "the git-path ledger did not excuse its own rm: $(tail -1 "$work/out")"
|
||||||
|
else
|
||||||
|
g checkout -q -- prolog-sessions/kb.pl
|
||||||
|
cp "$work/lost-x.pl" "$r/prolog-sessions/kb.pl"
|
||||||
|
if rkb add "$work/new.pl" >"$work/out" 2>&1; then
|
||||||
|
bad "after git checkout restored the kb, the git-path ledger excused a new loss"
|
||||||
|
elif said "$work/out" "location(cli_args,'src/main.rs',clap)"; then
|
||||||
|
ok "the git-path ledger and HEAD baseline work, and a loss after a restore is refused"
|
||||||
|
else
|
||||||
|
bad "the real-repo loss was refused, but not by naming it"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
printf '\nkb-test: %d passed, %d failed\n' "$pass" "$fail"
|
printf '\nkb-test: %d passed, %d failed\n' "$pass" "$fail"
|
||||||
[ "$fail" -eq 0 ]
|
[ "$fail" -eq 0 ]
|
||||||
|
|||||||
Reference in New Issue
Block a user