Files
patterm/cmd/spike/testdata/run-matrix.sh
2026-05-14 13:37:20 +01:00

83 lines
2.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Spike test matrix. Runs ./bin/spike against each target in sequence so a
# human can confirm by eye that the grid dump matches what the program would
# render in their own terminal.
#
# Run this from the project root:
# make spike
# ./cmd/spike/testdata/run-matrix.sh
#
# Each target's raw PTY recording lands in spike-<pid>.bytes and the final
# grid dump is appended to spike-report-<timestamp>.txt.
set -u
ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
BIN=${SPIKE_BIN:-$ROOT/bin/spike}
REPORT=$ROOT/spike-report-$(date +%Y%m%dT%H%M%S).txt
if [[ ! -x "$BIN" ]]; then
echo "spike binary not found at $BIN — run 'make spike' first" >&2
exit 1
fi
note() { printf '\n=== %s ===\n' "$*" | tee -a "$REPORT"; }
have() { command -v "$1" >/dev/null 2>&1; }
run_case() {
local label=$1; shift
note "$label"
printf 'argv: %q ' "$@" | tee -a "$REPORT"
printf '\n'
printf 'Press Ctrl-] in the spike to dump the grid.\n'
printf 'Grid dumps go to spike-<pid>.grid.log (tail -f in another terminal to watch live).\n'
printf 'The child must exit cleanly to advance.\n'
printf 'Press Enter when ready to start this case (or s to skip)... '
read -r ans
if [[ "$ans" == "s" ]]; then
echo 'skipped' | tee -a "$REPORT"
return
fi
# Tee spike's stderr so grid dumps are visible AND captured in the report.
# Without this, Ctrl-] dumps end up in $REPORT silently and look like
# the hotkey did nothing.
"$BIN" -- "$@" 2> >(tee -a "$REPORT" >&2)
echo "---" >> "$REPORT"
}
note "spike test matrix — $(date -Is)"
"$BIN" -h 2>>"$REPORT" || true
# 1. Trivial stream-mode sanity check.
run_case "echo + sleep (stream sanity)" sh -c 'echo hello; sleep 1'
# 2. Interactive shell.
run_case "bash -i (prompt + history)" bash -i
# 3. Alt-screen line editor.
if have vim; then
run_case "vim README.md (alt-screen)" vim "$ROOT/SPEC.md"
else
echo "skip vim: not installed" | tee -a "$REPORT"
fi
# 4. Alt-screen continuous redraw.
if have htop; then
run_case "htop (alt-screen, redraw)" htop
else
echo "skip htop: not installed" | tee -a "$REPORT"
fi
# 57. Real targets — the actual point of the spike.
for agent in claude opencode codex; do
if have "$agent"; then
run_case "$agent (real target)" "$agent"
else
echo "skip $agent: not installed" | tee -a "$REPORT"
fi
done
note "matrix complete. report: $REPORT"
echo
echo "Next step: write up the per-target verdict in SPIKE-REPORT.md."