Files
feuerwerk/e2e.sh
T
rootandClaude Opus 5 fe3c63c48c Collapse Tetris' variable clusters, and give the long runs a home
Next move held four clusters of Set variable in a row, fourteen single nodes
in all; clear-lines read three variables one after the other. They are now
one plural node each, which takes Next move 40 -> 30 nodes and clear-lines
25 -> 23. Every remaining single node was checked and really is single: ok/no
are the same variable in opposite branches, take/keep the same one across a
write, and the three key setters hang on three different events.

Two contracts carry those merges, both pinned as tests. Set variables writes
per port with writeTyped exactly as the singular node does, so a Pack{rot}
still merges instead of overwriting - without it, turning would have erased
the other three fields. And the interpreter collects every input before the
node runs, so no input may come from a variable the same node writes; a data
node is evaluated once per pulse and keeps its answer. That second rule is
invisible in the game, because OnUpdate re-reads each frame and heals it, so
it lives in a unit test rather than in the smoke.

/opt/node22 and /opt/npm are gone from the tree. build.sh ran into the empty
path once they were moved away; the other seven mentions were documentation.

e2e.sh and check.sh replace the bare npm calls. A long run does not survive
the end of its shell - four full e2e runs died mid-suite with oom_kill 0 -
so e2e.sh start hands the run to a transient game-maker-e2e.service, which
does. e2e.sh status reports the running job or the last result, and calls a
log without a closing line ABORTED rather than reporting the passes it got
to. Both scripts end on an explicit exit line, because set -o pipefail inside
a script does not protect the caller: measured, ./check.sh | tail still
reports 0. Logs carry a timestamp and land in logs/, which is ignored.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 16:00:28 +02:00

110 lines
4.0 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.
#!/bin/bash
# Runs the editor e2e suite in a transient systemd unit, which outlives the calling shell.
# A plain background job is not enough: when the caller exits, its whole process group is
# killed and the run dies mid-suite with no closing line.
#
# Usage: ./e2e.sh start [GM_STEPS] e.g. ./e2e.sh start 1-12
# ./e2e.sh status live progress, or the result of the last run
#
# Logs land in logs/e2e-<date>_<time>.log (gitignored) and end in "=== E2E EXIT n ===".
set -u
UNIT=game-maker-e2e
DIR=$(dirname "$(readlink -f "$0")")
LOGDIR=$DIR/logs
running() { systemctl is-active --quiet "$UNIT.service"; }
rel() { echo "${1#"$DIR"/}"; }
# Newest by name, not by mtime: the timestamped names sort chronologically and a share-mounted
# worktree can hand out surprising mtimes. The glob demands that shape, so a hand-dropped file
# in logs/ cannot outsort the newest run.
latest_log() { ls -1 "$LOGDIR"/e2e-[0-9]*.log 2>/dev/null | tail -1; }
start() {
if running; then
echo "$UNIT.service is still running – ./e2e.sh status, or systemctl stop $UNIT.service" >&2
exit 1
fi
systemctl reset-failed "$UNIT.service" 2>/dev/null
mkdir -p "$LOGDIR"
local log="$LOGDIR/e2e-$(date '+%Y-%m-%d_%H%M%S').log"
local steps=()
if [ $# -gt 0 ]; then steps=(--setenv=GM_STEPS="$1"); fi
systemd-run --unit="$UNIT" --working-directory="$DIR" \
--property=StandardOutput=append:"$log" \
--property=StandardError=append:"$log" \
"${steps[@]}" \
bash -c 'node tools/seed-e2e.mjs && node tools/e2e.mjs; echo "=== E2E EXIT $? ==="' || exit 1
echo "$UNIT.service started${1:+ with GM_STEPS=$1}, logging to $(rel "$log")"
echo " status: ./e2e.sh status"
echo " follow: tail -f $(rel "$log")"
echo " stop: systemctl stop $UNIT.service"
}
# Wall-clock seconds as "2m 14s".
span() { printf '%dm %02ds' $(($1 / 60)) $(($1 % 60)); }
status() {
local log pass fail
log=$(latest_log)
if [ -z "$log" ]; then
running && echo "running – but logs/ is empty, follow: journalctl -u $UNIT.service -f" ||
echo "idle – no run logged yet, start one with ./e2e.sh start"
return
fi
pass=$(grep -c '^PASS' "$log")
fail=$(grep -c '^FAIL' "$log")
if running; then
local since=0 now
now=$(systemctl show "$UNIT.service" -p ActiveEnterTimestamp --value)
[ -n "$now" ] && since=$(($(date +%s) - $(date -d "$now" +%s)))
echo "running – $(span "$since") elapsed"
echo " log: $(rel "$log")"
echo " checks: $pass PASS, $fail FAIL"
local at
at=$(grep -E '^(PASS|FAIL)' "$log" | tail -1)
[ -n "$at" ] && echo " at: $at"
echo " follow: tail -f $(rel "$log")"
return
fi
# Started per the file name, ended when the file was last written to; an unparsable name
# costs the duration, not the line.
local name started epoch took verdict exit_line
name=$(basename "$log" .log)
started=$(echo "${name#e2e-}" | tr '_' ' ' | sed -E 's/(..)(..)(..)$/\1:\2:\3/')
epoch=$(date -d "$started" +%s 2>/dev/null)
took=""
[ -n "$epoch" ] && took=$(($(date -r "$log" +%s) - epoch))
verdict=$(grep -E '^(ALL PASSED|[0-9]+ FAILED|RUN DIED)' "$log" | tail -1)
exit_line=$(grep -E '^=== E2E EXIT' "$log" | tail -1 | sed -E 's/^=== (.*) ===$/\1/')
echo "idle – last run $started$([ -n "$took" ] && [ "$took" -ge 0 ] && echo ", $(span "$took")")"
echo " log: $(rel "$log")"
if [ -z "$exit_line" ]; then
# No closing line means the run was cut short. Reporting its PASS count as a result would
# claim a suite that never finished, so say so instead.
echo " result: ABORTED – no closing line, so this is not a result. Run it again."
else
echo " result: ${verdict:-no summary} ($exit_line)"
fi
echo " checks: $pass PASS, $fail FAIL"
[ "$fail" -gt 0 ] && grep -E '^FAIL' "$log" | head -20 | sed 's/^/ /'
return 0
}
case "${1:-}" in
start) shift; start "$@" ;;
status) status ;;
*)
echo "usage: ./e2e.sh start [GM_STEPS] e.g. ./e2e.sh start 1-12" >&2
echo " ./e2e.sh status" >&2
exit 2
;;
esac