tests: fail late with a well-formed partial doc, so committing early is caught by the globals check itself.
commit 57ee9e4527158c704b80144b4d0279aa6674730e · parent aec43e5485
· browse this tree
Ximianth, 2026-10-23 14:09:07 UTC
With an unclosed hunk, a commit moved before the late checks dies on its unset end line under set -u, which fails the script but never reaches the comparison. A dangling annotation after a good hunk leaves a partial doc the commit can copy.
diff --git a/tests/test-api.sh b/tests/test-api.sh index 03006fd..1c22dd4 100755 --- a/tests/test-api.sh +++ b/tests/test-api.sh @@ -64,7 +64,7 @@ expect_fail "a failed re-parse fails" 'testmark: missing.md: not a readable file expect_fail "and leaves its handle unusable" 'testmark: unknown handle "b"' testmark_names b # --- what a parse doesn't keep is gone: white-box, comparing every library global and its value --- -printf '[testmark]:# (x)\n```\nnever closed\n' >unclosed.md +printf '[testmark]:# (x)\n```\none\n```\n[testmark]:# (y)\n' >dangling.md ## - @stdout `declare -p` of every `_testmark_*` global globals() { local vars @@ -73,7 +73,7 @@ globals() { } before=$(globals) testmark_parse g a.md -expect_fail "a parse that fails late" 'testmark: unclosed.md:2: code block not closed' testmark_parse g unclosed.md +expect_fail "a parse that fails late" 'testmark: dangling.md:5: annotation not followed by a code block' testmark_parse g dangling.md expect_eq "leaves no globals for its handle, of the old doc or the partial one" "$(globals)" "$before" testmark_parse g b.md before=$(globals)