Test: Isolate generated docs and settings fixtures

This commit is contained in:
Gabriel Brown
2026-08-26 22:59:28 -04:00
parent 68b6664111
commit 3839183401
3 changed files with 73 additions and 24 deletions
+16 -4
View File
@@ -49,12 +49,24 @@ grep -q 'cursor:zoom_factor' "$doc" \
# actually compares content rather than always returning success.
scratch="$(mktemp -d /tmp/panama-docs.XXXXXX)"
trap 'rm -rf "$scratch"' EXIT
git -C "$repo_dir" diff -- docs/settings.md >"$scratch/docs.diff.before"
cp "$doc" "$scratch/settings.md"
printf '\n<!-- drift -->\n' >>"$doc"
if "$generator" --check >/dev/null 2>&1; then
cp "$scratch/settings.md" "$doc"
printf '\n<!-- drift -->\n' >>"$scratch/settings.md"
if "$generator" --check --output "$scratch/settings.md" >/dev/null 2>&1; then
fail '--check reported success on a modified file, so staleness would never be caught'
fi
cp "$scratch/settings.md" "$doc"
# An explicit relative destination belongs to the caller's working directory,
# not the repository root.
(
cd "$scratch" || exit 1
"$generator" --output generated.md >/dev/null
) || fail 'a relative --output path did not resolve from the current directory'
cmp -s "$doc" "$scratch/generated.md" \
|| fail 'generation through a relative --output path produced different documentation'
git -C "$repo_dir" diff -- docs/settings.md >"$scratch/docs.diff.after"
cmp -s "$scratch/docs.diff.before" "$scratch/docs.diff.after" \
|| fail 'the contract changed tracked docs/settings.md'
printf 'settings docs contract: PASS (%d settings documented)\n' "$settings"