AtlatestRepositorysigil-doc

sigil-doc / tree / testgate-glossary.sh

1#!/usr/bin/env bash
2set -euo pipefail
3
4repo_dir="$(cd "$(dirname "$0")/.." && pwd)"
5cd "$repo_dir"
6sigil="${SIGIL_D1_COMPILER:-$repo_dir/../task-sigil-language-readers/build/dev/bin/sigil}"
7sigil_sxml_root="${SIGIL_SXML_ROOT:-$repo_dir/../sigil-sxml}"
8typst_bin="${TYPST_BIN:-typst}"
9pdftotext_bin="${PDFTOTEXT_BIN:-pdftotext}"
10mkdir -p build/glossary
11gate_dir="$(mktemp -d "$repo_dir/build/glossary-gate.XXXXXX")"
12export XDG_CACHE_HOME="$gate_dir/cache"
13export SIGIL_REDIRECTS="${SIGIL_D1_REDIRECTS:-$repo_dir/dev-redirects.sgl}"
14export SIGIL_D1_COMPILER="$sigil"
16"$sigil" -L src -L "$sigil_sxml_root/src" test test/test-glossary.sgl --report \
17 | tee "$gate_dir/tests.txt"
18rg -q '8 passed' "$gate_dir/tests.txt"
19echo GLOSSARY_GATE_01_MODEL_INDEX_HTML_TYPST_8_8
21bash test/gate-semantic-structures.sh | tee "$gate_dir/structures.txt"
22rg -q SEMANTIC_STRUCTURES_GATE_GREEN "$gate_dir/structures.txt"
23echo GLOSSARY_GATE_02_SEMANTIC_STRUCTURES_REGRESSION
25"$sigil" -L src -L "$sigil_sxml_root/src" eval -f test/build-glossary.sgl
26"$typst_bin" compile --root "$repo_dir" --creation-timestamp 0 --pdf-standard a-2b --jobs 1 \
27 build/glossary/document.typ "$gate_dir/document.pdf"
28"$pdftotext_bin" -layout "$gate_dir/document.pdf" "$gate_dir/document.txt"
29rg -q '2\.1\. B' "$gate_dir/document.txt"
30rg -q '2\.2\. E' "$gate_dir/document.txt"
31rg -q 'binding \(page 4\)' "$gate_dir/document.txt"
32rg -q 'links a symbol to a location' "$gate_dir/document.txt"
33# `if rg; then fail`, never a bare `! rg` -- bash exempts `!`-inverted
34# commands from `set -e`, so the bare form could never fail (inert 2026-08-24).
35# Subject presence: the positive assertions above prove document.txt exists
36# and carries real glossary content.
37if rg -q '2\.[0-9]+\. A$' "$gate_dir/document.txt"; then
38 echo 'GLOSSARY: a bare "A" entry appears in the rendered list (alphabetization/filter regression)' >&2
39 exit 1
40fi
41echo GLOSSARY_GATE_03_REAL_ALPHABETIZED_LINKED_PDF
43echo GLOSSARY_GATE_GREEN