ckb/tests/smoke.sh
Michał Kopeć 27d84fe008 Template 1.11.0: optional Python with degraded fallbacks; lint check 13 per-block Crux matching
- D-0003: <python> interpreter resolution, per-OS install guide, lint_quick.sh/.ps1
  session-start fallback, manual lint checklist, no-script retrieval path,
  exporters declare Python a hard requirement
- Lint check 13 pairs each Crux quote block with the attribution under it, so a
  multi-source Crux no longer cross-fails; fixture KB gains a second source
- Session summaries for 2026-09-29 and 2026-10-01

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-01 21:26:43 +02:00

36 lines
1.8 KiB
Bash
Executable file

#!/usr/bin/env bash
# Template smoke test: run the deterministic scripts against the fixture KB and
# compare with the golden output. Exit non-zero on any drift.
#
# tests/smoke.sh # check
# tests/smoke.sh --update # regenerate the golden files after an intended change
set -euo pipefail
cd "$(dirname "$0")/.."
FIX=tests/fixtures/minimal-kb
TODAY=2026-09-24
LINT=.agents/skills/ckb-lint/scripts/lint_report.py
RETR=.agents/skills/ckb-retrieve/scripts/retrieve_candidates.py
TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT
QUICK=.agents/skills/ckb-lint/scripts/lint_quick.sh
( cd "$FIX" && python3 "../../../$LINT" --json --today "$TODAY" ) > "$TMP/lint.json"
# The no-Python fallback must agree with the reference on the three counts it covers.
( cd "$FIX" && python3 "../../../$LINT" --quick --today "$TODAY" || true ) > "$TMP/quick.py.txt"
( cd "$FIX" && bash "../../../$QUICK" --today "$TODAY" || true ) | sed 's/ (fallback:.*//' > "$TMP/quick.sh.txt"
python3 "$RETR" "how many times does Atlas retry a failed batch" --root "$FIX" --today "$TODAY" --json > "$TMP/retrieve.json"
if [[ "${1:-}" == "--update" ]]; then
cp "$TMP/lint.json" tests/expected/lint.json
cp "$TMP/retrieve.json" tests/expected/retrieve.json
echo "golden files updated"; exit 0
fi
fail=0
for f in lint retrieve; do
if ! diff -u "tests/expected/$f.json" "$TMP/$f.json"; then echo "DRIFT: $f"; fail=1; fi
done
if ! diff -u "$TMP/quick.py.txt" "$TMP/quick.sh.txt"; then echo "DRIFT: lint_quick.sh disagrees with lint_report.py --quick"; fail=1; fi
top=$(python3 -c "import json;print(json.load(open('$TMP/retrieve.json'))['candidates'][0]['path'])")
[[ "$top" == "wiki/entities/atlas-retry-policy.md" ]] || { echo "retrieve: expected atlas-retry-policy first, got $top"; fail=1; }
[[ $fail -eq 0 ]] && echo "smoke: OK"
exit $fail