Test: Isolate generated docs and settings fixtures
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user