#!/usr/bin/env bash # # check-spec-refs-selftest.sh — check-spec-refs.py can fail. # # A check that cannot fail is decoration. This builds scratch standards under a # temporary root and asserts that the check # 1. passes when every cited section is a heading; # 2. fails when a cited section is not a heading (the case it exists for); # 3. accepts both heading spellings, `## 4.` and `## §4`; # 4. does NOT synthesise parents: a `## 4.10` heading alone must not satisfy a # `SPEC §4` citation, which is how a standard citing a section it never # wrote would otherwise pass; # 5. resolves a citation against the SPEC.md of the standard the file sits in, # so one standard's section cannot excuse another's citation; # 6. ignores `*.rs` under a `target/` directory, which is build output. # Nothing here reads the real tree, and nothing needs a network. set -uo pipefail here=$(cd "$(dirname "$0")" && pwd) check=$here/check-spec-refs.py tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT fails=0 # mk mk() { mkdir -p "$1/$2/$(dirname "$4")" printf '%s\n' "$3" > "$1/$2/SPEC.md" printf '%s\n' "$5" > "$1/$2/$4" } want() { # want