61 lines
2.3 KiB
Bash
61 lines
2.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Probe battery for the repaired posts-census CHECK.
|
|
# Each cell is run in a throwaway copy; the expected rc is asserted.
|
|
set -u
|
|
SRC=/root/troupe-standup/wizard-work/ledger
|
|
W=$(mktemp -d /root/.hermes/profiles/volt/cache/scratch/posts-probe.XXXXXX)
|
|
UNEXPECTED=0
|
|
cell() { # name expected_rc cmd...
|
|
local name="$1" want="$2"; shift 2
|
|
local got=0
|
|
( "$@" ) >"$W/$name.out" 2>&1 || got=$?
|
|
if [ "$got" -eq "$want" ]; then
|
|
echo "OK $name rc=$got"
|
|
else
|
|
echo "BAD $name rc=$got want=$want"
|
|
sed 's/^/ /' "$W/$name.out" | head -4
|
|
UNEXPECTED=$((UNEXPECTED+1))
|
|
fi
|
|
}
|
|
|
|
mk() { # make a fresh copy at $W/t
|
|
rm -rf "$W/t"; mkdir -p "$W/t"
|
|
cp "$SRC/CHECK-2026-11-01-posts-census" "$SRC/grade_posts_census.py" \
|
|
"$SRC/2026-11-01-posts-census.csv" "$SRC/2026-11-01-posts-census.md" \
|
|
"$SRC/2026-11-01-posts-census.json" "$W/t/"
|
|
}
|
|
|
|
mk; cell baseline 0 bash "$W/t/CHECK-2026-11-01-posts-census"
|
|
mk; ( cd / && bash "$W/t/CHECK-2026-11-01-posts-census" >"$W/cwd.out" 2>&1 ); rc=$?
|
|
if [ "$rc" -eq 0 ]; then echo "OK cwd-root rc=0"; else
|
|
echo "BAD cwd-root rc=$rc want=0"; sed 's/^/ /' "$W/cwd.out" | head -3
|
|
UNEXPECTED=$((UNEXPECTED+1)); fi
|
|
mk; cell dir-flag 0 bash "$W/t/CHECK-2026-11-01-posts-census" --dir "$W/t"
|
|
|
|
mk; sed -i 's/^1,Leanne Graham/1,Leanne Grahamm/' "$W/t/2026-11-01-posts-census.csv"
|
|
cell csv-cell-moved 1 bash "$W/t/CHECK-2026-11-01-posts-census"
|
|
|
|
mk; sed -i 's/Gwenborough | 10 |/Gwenborough | 11 |/' "$W/t/2026-11-01-posts-census.md"
|
|
cell md-cell-moved 1 bash "$W/t/CHECK-2026-11-01-posts-census"
|
|
|
|
mk; sed -i 's/(10 users, 100 posts total)/(10 users, 101 posts total)/' "$W/t/2026-11-01-posts-census.md"
|
|
cell md-headline-moved 1 bash "$W/t/CHECK-2026-11-01-posts-census"
|
|
|
|
mk; python3 - "$W/t/2026-11-01-posts-census.json" <<'PY'
|
|
import json,sys
|
|
p=sys.argv[1]; j=json.load(open(p)); j["total_posts"]=101; json.dump(j,open(p,"w"),indent=2)
|
|
PY
|
|
cell json-total-moved 1 bash "$W/t/CHECK-2026-11-01-posts-census"
|
|
|
|
mk; rm -f "$W/t/2026-11-01-posts-census.csv"
|
|
cell artifact-missing 2 bash "$W/t/CHECK-2026-11-01-posts-census"
|
|
|
|
mk; printf 'not json' > "$W/t/2026-11-01-posts-census.json"
|
|
cell json-unparseable 2 bash "$W/t/CHECK-2026-11-01-posts-census"
|
|
|
|
mk; cell live-still-green 0 bash "$W/t/CHECK-2026-11-01-posts-census" --live
|
|
|
|
echo "UNEXPECTED=$UNEXPECTED"
|
|
rm -rf "$W"
|
|
exit "$UNEXPECTED"
|