AtlatestRepositorysigil-doc

sigil-doc / tree / testgate-d1.sh

1#!/usr/bin/env bash
2set -euo pipefail
3repo_dir="$(cd "$(dirname "$0")/.." && pwd)"
4cd "$repo_dir"
5mkdir -p "$repo_dir/build"
6sigil="${SIGIL_D1_COMPILER:-$repo_dir/../task-sigil-language-readers/build/dev/bin/sigil}"
7cache_dir=$(mktemp -d "$repo_dir/build/d1-cache.XXXXXX")
8export XDG_CACHE_HOME="$cache_dir"
9export SIGIL_REDIRECTS="${SIGIL_D1_REDIRECTS:-$repo_dir/dev-redirects.sgl}"
11test/gate-d0.sh
12"$sigil" -L src -L test test test/test-reader.sgl --report
14# Exercise the public reader through direct-file evaluation and public load.
15"$sigil" -L src -L test eval -f test/fixtures/practical-sigil-chapter.sgd
16observed=$("$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)))))')
17case "$observed" in
18 *"A Useful First Script|2|"*"Computed Section 2"*) ;;
19 *) echo "real #lang load did not produce the Practical Sigil document" >&2; exit 1 ;;
20esac
22# The second run must reuse unchanged reader/compiler-input artifacts.
23reader_sgb=$(find "$cache_dir" -path '*/sigil/doc/reader.sgb' -print -quit)
24test -n "$reader_sgb"
25before=$(stat -c '%Y:%s' "$reader_sgb")
26"$sigil" -L src -L test eval -f test/fixtures/practical-sigil-chapter.sgd
27after=$(stat -c '%Y:%s' "$reader_sgb")
28test "$before" = "$after"
30echo "D1_GATE_GREEN"