| 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 | swift_cmd=${PET_SWIFTC:-swiftc} |
| 9 | cargo_cmd=${PET_CARGO:-cargo} |
| 10 | |
| 11 | printf '%s\n' '── canonical TypeScript core ──' |
| 12 | "$node_cmd" scripts/build-pet.mjs |
| 13 | |
| 14 | printf '%s\n' '── rust (zero deps) ──' |
| 15 | "$rust_cmd" --edition 2024 -O rs/main.rs -o rs/petsim |
| 16 | with_swift=true |
| 17 | case "${1:-}" in --no-swift) with_swift=false ;; '') ;; *) printf 'Usage: %s [--no-swift]\n' "$0" >&2; exit 2 ;; esac |
| 18 | if "$with_swift"; then |
| 19 | printf '%s\n' '── swift ──' |
| 20 | (cd swift && "$swift_cmd" -O PetSim.swift main.swift -o petsim) |
| 21 | else |
| 22 | printf '%s\n' 'Swift explicitly omitted; this run proves only TypeScript/Rust parity.' |
| 23 | fi |
| 24 | |
| 25 | checkpoints=0 |
| 26 | for expression in v1 v2; do |
| 27 | for tape in tape.tsv tapes/edge-cases.tsv; do |
| 28 | case "$tape" in tape.tsv) name=baseline ;; *) name=edge-cases ;; esac |
| 29 | for mode in animated reduced-motion; do |
| 30 | set -- |
| 31 | if [ "$mode" = reduced-motion ]; then set -- --reduced-motion; fi |
| 32 | if [ "$expression" = v1 ]; then set -- "$@" --legacy; fi |
| 33 | stem="conformance-results/$expression-$name-$mode" |
| 34 | "$node_cmd" run-tape.ts run "$@" < "$tape" > "$stem-ts.txt" |
| 35 | (cd rs && ./petsim "$@" < "../$tape") > "$stem-rs.txt" |
| 36 | if "$with_swift"; then (cd swift && ./petsim --tape "../$tape" "$@") > "$stem-swift.txt"; fi |
| 37 | if [ "$expression" = v1 ]; then diff -u "tests/fixtures/v1-$name-$mode.txt" "$stem-ts.txt"; fi |
| 38 | diff -u "$stem-ts.txt" "$stem-rs.txt" |
| 39 | if "$with_swift"; then diff -u "$stem-ts.txt" "$stem-swift.txt"; fi |
| 40 | count=$(wc -l < "$stem-ts.txt" | tr -d ' ') |
| 41 | [ "$count" -gt 1 ] |
| 42 | checkpoints=$((checkpoints + count)) |
| 43 | printf 'PASS %s %s %s: %s matching checkpoints\n' "$expression" "$name" "$mode" "$count" |
| 44 | done |
| 45 | done |
| 46 | done |
| 47 | printf 'Core conformance: %s checkpoints across 2 expression versions and 4 tapes/modes\n' "$checkpoints" |
| 48 | printf '%s\n' '── ratatui widget (offline, locked) ──' |
| 49 | (cd tui && "$cargo_cmd" build --offline --locked -q) |
| 50 | printf '%s\n' 'ratatui crate: built' |
| 51 | printf 'PASS — all core checkpoints and the ratatui widget build\n' |
| 52 |