AtlatestRepositorysigil-doc
1
#!/usr/bin/env bash2
set -euo pipefail3
repo_dir="$(cd "$(dirname "$0")/.." && pwd)"4
cd "$repo_dir"5
mkdir -p "$repo_dir/build"6
sigil="${SIGIL_D1_COMPILER:-$repo_dir/../task-sigil-language-readers/build/dev/bin/sigil}"7
cache_dir=$(mktemp -d "$repo_dir/build/d1-cache.XXXXXX")8
export XDG_CACHE_HOME="$cache_dir"9
export SIGIL_REDIRECTS="${SIGIL_D1_REDIRECTS:-$repo_dir/dev-redirects.sgl}"11
test/gate-d0.sh12
"$sigil" -L src -L test test test/test-reader.sgl --report14
# Exercise the public reader through direct-file evaluation and public load.15
"$sigil" -L src -L test eval -f test/fixtures/practical-sigil-chapter.sgd16
observed=$("$sigil" -L src -L test eval '(begin (import (sigil doc)) (load "test/fixtures/practical-sigil-chapter.sgd") (display (document-title (eval (quote document)))) (display "|") (display (eval (quote tip-calls))) (display "|") (display (document->plain (eval (quote document)))))')17
case "$observed" in18
*"A Useful First Script|2|"*"Computed Section 2"*) ;;19
*) echo "real #lang load did not produce the Practical Sigil document" >&2; exit 1 ;;20
esac22
# The second run must reuse unchanged reader/compiler-input artifacts.23
reader_sgb=$(find "$cache_dir" -path '*/sigil/doc/reader.sgb' -print -quit)24
test -n "$reader_sgb"25
before=$(stat -c '%Y:%s' "$reader_sgb")26
"$sigil" -L src -L test eval -f test/fixtures/practical-sigil-chapter.sgd27
after=$(stat -c '%Y:%s' "$reader_sgb")28
test "$before" = "$after"30
echo "D1_GATE_GREEN"