Files
troupe-standup/wizard-work/volt/CHECK-q169
T

82 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# CHECK-q169 -- the compile sweep still answers its question.
#
# Legs
# selftest every fixture cell green (22 today), and the cell count pinned
# worktree every tracked *.py on disk parses, rc 0
# head every tracked *.py at HEAD parses, rc 0
# historic 99eba1e -- the rev carrying a bash script under a .py name --
# reads rc 1 with exactly one fault, and no file is called
# UNREADABLE (the pre-repair batch framing reported seven)
# wiring tools/verify.py names the leg and runs it at WORKTREE
#
# rc 0 every leg as expected | 1 a graded fault | 2 could not grade.
# Run from anywhere; paths resolve from $0, the repo from this file's place.
set -u
HERE="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)"
REPO="$(cd "$HERE/../.." && pwd)"
TOOL="$HERE/q169_compile_sweep.py"
CELLS="22 cells, 22 passed, 0 failed"
legs=0
faults=0
ok() { legs=$((legs + 1)); printf 'ok %-9s %s\n' "$1" "$2"; }
bad() { legs=$((legs + 1)); faults=$((faults + 1)); printf 'FAULT %-9s %s\n' "$1" "$2"; }
skip(){ legs=$((legs + 1)); printf 'skip %-9s %s\n' "$1" "$2"; }
[ -f "$TOOL" ] || { echo "cannot grade -- no tool: $TOOL"; exit 2; }
command -v python3 >/dev/null || { echo "cannot grade -- no python3"; exit 2; }
# selftest -- the fixture corpus, and the pin on its size
out="$(python3 "$TOOL" --selftest 2>&1)"; rc=$?
if [ $rc -eq 0 ] && printf '%s' "$out" | grep -qF "$CELLS"; then
ok selftest "$CELLS, rc 0"
else
bad selftest "rc $rc, want 0 and '$CELLS'; last: $(printf '%s' "$out" | tail -n 1)"
fi
# worktree -- the tree about to be committed
out="$(python3 "$TOOL" --repo "$REPO" 2>&1)"; rc=$?
line="$(printf '%s' "$out" | tail -n 1)"
if [ $rc -eq 0 ] && printf '%s' "$line" | grep -q ', 0 fault(s)$'; then
ok worktree "$line"
else
bad worktree "rc $rc: $line"
fi
# head -- the commit
out="$(python3 "$TOOL" --repo "$REPO" --rev HEAD 2>&1)"; rc=$?
line="$(printf '%s' "$out" | tail -n 1)"
if [ $rc -eq 0 ] && printf '%s' "$line" | grep -q ', 0 fault(s)$'; then
ok head "$line"
else
bad head "rc $rc: $line"
fi
# historic -- the red reading the batch framing used to bend
if git -C "$REPO" cat-file -e '99eba1e^{commit}' 2>/dev/null; then
out="$(python3 "$TOOL" --repo "$REPO" --rev 99eba1e 2>&1)"; rc=$?
if [ $rc -eq 1 ] && printf '%s' "$out" | grep -q ', 1 fault(s)$' \
&& ! printf '%s' "$out" | grep -q UNREADABLE; then
ok historic "rc 1, 1 fault, no UNREADABLE: $(printf '%s' "$out" | head -n 1 | cut -c1-60)..."
else
bad historic "rc $rc, want 1 and exactly one fault, no UNREADABLE"
fi
else
skip historic "99eba1e not in this clone (shallow?) -- not a pass, not a fault"
fi
# wiring -- the gate names the leg and runs it at the worktree
if grep -q '"compile-sweep"' "$REPO/tools/verify.py" \
&& grep -q 'q169_compile_sweep.py' "$REPO/tools/verify.py" \
&& grep -q '"--rev", "WORKTREE"' "$REPO/tools/verify.py"; then
ok wiring "tools/verify.py: leg compile-sweep -> q169_compile_sweep.py at WORKTREE"
else
bad wiring "tools/verify.py no longer names the compile-sweep leg at WORKTREE"
fi
echo "CHECK-q169: $legs leg(s), $faults fault(s)"
[ $faults -eq 0 ] || exit 1
exit 0