AtlatestRepositorysigil-doc

sigil-doc / tree / testgate-semantic-structures.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
11gate_dir="$(mktemp -d "$repo_dir/build/semantic-structures-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-semantic-structures.sgl --report \
17 | tee "$gate_dir/tests.txt"
18rg -q '4 passed' "$gate_dir/tests.txt"
19echo SEMANTIC_STRUCTURES_GATE_01_MODEL_AUTHOR_HTML_TYPST_4_4
21bash test/gate-d0.sh | tee "$gate_dir/d0.txt"
22rg -q D0_GATE_GREEN "$gate_dir/d0.txt"
23echo SEMANTIC_STRUCTURES_GATE_02_D0_REGRESSION
25mkdir -p build/semantic-structures
26"$sigil" -L src -L "$sigil_sxml_root/src" eval -f test/build-semantic-structures.sgl
27"$typst_bin" compile --root "$repo_dir" --creation-timestamp 0 --pdf-standard a-2b --jobs 1 \
28 build/semantic-structures/document.typ "$gate_dir/document.pdf"
29"$pdftotext_bin" -layout "$gate_dir/document.pdf" "$gate_dir/document.txt"
30rg -q '3\. Nested three' "$gate_dir/document.txt"
31rg -q 'Action.*Binding' "$gate_dir/document.txt"
32# `if rg; then fail`, never a bare `! rg` -- bash exempts `!`-inverted
33# commands from `set -e`, so the bare form could never fail (inert 2026-08-24).
34# Subject presence: the positive assertions above prove document.txt exists.
35if rg -q 'demo-video-id' "$gate_dir/document.txt"; then
36 echo 'SEMANTIC-STRUCTURES: video id leaked into print output (video policy regression)' >&2
37 exit 1
38fi
39echo SEMANTIC_STRUCTURES_GATE_03_REAL_PDF_LIST_TABLE_VIDEO_POLICY
41echo SEMANTIC_STRUCTURES_GATE_GREEN