AtlatestRepositorysigil-doc
1
#!/usr/bin/env bash2
# SD-P2 print-toolchain arms. Run under: guix shell typst poppler qpdf -- bash test/gate-sd-p2-print.sh3
#4
# TWO INDEPENDENT REASONS FOR THE PDF TO CHANGE ON THIS BRANCH, and they are5
# checked separately rather than letting one clean run stand in for the pair:6
#7
# 1. the D13 rename changes the admonition's default label, so the book PDF8
# MUST differ from the pre-rename output and MUST now read "aside";9
# 2. the video work adds a check on the constructed Typst destination, which10
# for every valid source is a pass-through, so the emitted source for11
# existing video content MUST be byte-identical.12
#13
# One expectation is "this changed", the other is "this did not change". A14
# single diff cannot demonstrate both, and a gate that only asserted "the PDF15
# still builds" would be blind to either going wrong.16
set -euo pipefail18
repo_dir="$(cd "$(dirname "$0")/.." && pwd)"19
cd "$repo_dir"20
sigil="${SIGIL_D1_COMPILER:-$repo_dir/../task-sigil-language-readers/build/dev/bin/sigil}"21
sigil_sxml_root="${SIGIL_SXML_ROOT:-$repo_dir/../sigil-sxml}"22
export SIGIL_REDIRECTS="${SIGIL_D1_REDIRECTS:-$repo_dir/dev-redirects.sgl}"23
gate_dir="$(mktemp -d "$repo_dir/build/sd-p2-print.XXXXXX")"24
export XDG_CACHE_HOME="$gate_dir/cache"26
for tool in typst pdftotext rg git; do27
command -v "$tool" >/dev/null \28
|| { echo "gate-sd-p2-print: $tool is missing; run under guix shell typst poppler qpdf" >&2; exit 1; }29
done30
typst --version | tee "$gate_dir/toolchain.txt"31
echo SD_P2_PRINT_00_TOOLCHAIN33
# ---------------------------------------------------------------------------34
# Arm P1 - the rename reached the typeset page, not merely the source tree.35
# The renderers derive this label from the kind symbol, so nothing in the36
# renderer diff proves the output moved; only the artifact does.37
# ---------------------------------------------------------------------------38
"$sigil" -L src -L book tools/build-practical-sigil-print.sgl "$gate_dir/book.typ"39
typst compile --root "$repo_dir" --creation-timestamp 0 --pdf-standard a-2b --jobs 1 \40
"$gate_dir/book.typ" "$gate_dir/book.pdf"41
pdftotext -layout "$gate_dir/book.pdf" "$gate_dir/book.txt"42
# Positive control first: the admonition block must actually be on the page, or43
# the absence assertion below would pass on a document that simply lost it.44
rg -q 'Keep the first version direct' "$gate_dir/book.txt" \45
|| { echo "gate-sd-p2-print: the admonition body is missing from the PDF; the check below would be vacuous" >&2; exit 1; }46
# Whole-word matching is precise here because neither word occurs in the book's47
# prose: `rg -w` over book/practical-sigil/*.sgd finds them only on the two48
# admonition delimiter lines. So a hit is the label and nothing else.49
rg -qw aside "$gate_dir/book.txt" \50
|| { echo "gate-sd-p2-print: the renamed label does not appear in the typeset output" >&2; exit 1; }51
if rg -nw note "$gate_dir/book.txt"; then52
echo "gate-sd-p2-print: the old label is still on the typeset page, at the lines above" >&2; exit 153
fi54
echo SD_P2_PRINT_01_RENAME_REACHED_THE_PAGE56
# ---------------------------------------------------------------------------57
# Arm P2 - the video destination check is a pass-through for valid sources.58
# Emitted source for the shipped video shapes must be EXACTLY these bytes; if59
# the check ever starts rewriting or dropping a destination, this goes red.60
# ---------------------------------------------------------------------------61
"$sigil" -L "$sigil_sxml_root/src" -L src -L test test test/test-video-destination.sgl --report \62
| tee "$gate_dir/video.txt"63
rg -q '5 passed' "$gate_dir/video.txt"64
echo SD_P2_PRINT_02_VIDEO_DESTINATIONS_UNCHANGED_FOR_VALID_SOURCES66
# ---------------------------------------------------------------------------67
# Arm P3 - the reviewed print gates still pass end to end.68
# ---------------------------------------------------------------------------69
bash test/gate-d6.sh >"$gate_dir/d6.txt" 2>&170
rg -q D6_GATE_GREEN "$gate_dir/d6.txt"71
bash test/gate-d6-customization.sh >"$gate_dir/d6c.txt" 2>&172
rg -q D6_CUSTOMIZATION_GATE_GREEN "$gate_dir/d6c.txt"73
bash test/gate-glossary.sh >"$gate_dir/glossary.txt" 2>&174
rg -q GLOSSARY_GATE_GREEN "$gate_dir/glossary.txt"75
bash test/gate-semantic-structures.sh >"$gate_dir/structures.txt" 2>&176
rg -q SEMANTIC_STRUCTURES_GATE_GREEN "$gate_dir/structures.txt"77
echo SD_P2_PRINT_03_D6_CUSTOMIZATION_GLOSSARY_STRUCTURES_GREEN79
printf 'SD_P2_PRINT_GATE_GREEN artifacts=%s\n' "$gate_dir"