| 1 | #!/bin/sh |
| 2 | # Exit on every build/runner failure; compare the same tape across all cores. |
| 3 | set -eu |
| 4 | cd "$(dirname "$0")" |
| 5 | mkdir -p conformance-results |
| 6 | node_cmd=${PET_NODE:-node} |
| 7 | rust_cmd=${PET_RUSTC:-rustc} |
| 8 | cargo_cmd=${PET_CARGO:-cargo} |
| 9 | |
| 10 | printf '%s\n' '── canonical TypeScript core ──' |
| 11 | "$node_cmd" scripts/build-pet.mjs |
| 12 | |
| 13 | printf '%s\n' '── rust (zero deps) ──' |
| 14 | "$rust_cmd" --edition 2024 -O rs/main.rs -o rs/petsim |
| 15 | if [ "$#" -ne 0 ]; then printf 'Usage: %s\n' "$0" >&2; exit 2; fi |
| 16 | |
| 17 | checkpoints=0 |
| 18 | for expression in v1 v2; do |
| 19 | for tape in tape.tsv tapes/edge-cases.tsv; do |
| 20 | case "$tape" in tape.tsv) name=baseline ;; *) name=edge-cases ;; esac |
| 21 | for mode in animated reduced-motion; do |
| 22 | set -- |
| 23 | if [ "$mode" = reduced-motion ]; then set -- --reduced-motion; fi |
| 24 | if [ "$expression" = v1 ]; then set -- "$@" --legacy; fi |
| 25 | stem="conformance-results/$expression-$name-$mode" |
| 26 | "$node_cmd" run-tape.ts run "$@" < "$tape" > "$stem-ts.txt" |
| 27 | (cd rs && ./petsim "$@" < "../$tape") > "$stem-rs.txt" |
| 28 | if [ "$expression" = v1 ]; then diff -u "tests/fixtures/v1-$name-$mode.txt" "$stem-ts.txt"; fi |
| 29 | diff -u "$stem-ts.txt" "$stem-rs.txt" |
| 30 | count=$(wc -l < "$stem-ts.txt" | tr -d ' ') |
| 31 | [ "$count" -gt 1 ] |
| 32 | checkpoints=$((checkpoints + count)) |
| 33 | printf 'PASS %s %s %s: %s matching checkpoints\n' "$expression" "$name" "$mode" "$count" |
| 34 | done |
| 35 | done |
| 36 | done |
| 37 | printf 'Core conformance: %s checkpoints across 2 expression versions and 4 tapes/modes\n' "$checkpoints" |
| 38 | printf '%s\n' '── ratatui widget (offline, locked) ──' |
| 39 | (cd tui && "$cargo_cmd" build --offline --locked -q) |
| 40 | printf '%s\n' 'ratatui crate: built' |
| 41 | printf 'PASS — all core checkpoints and the ratatui widget build\n' |
| 42 |