Files
superpaper/scripts/test.sh
T
dela 3a322aa8dc feat: land superpaper v1 notes scaffold
Add the ledger schema, class router, lint codes, ingest/build
pipeline, and three work-tree examples: align derivation,
superfig delegation, and supertensor delegation.
2026-08-17 10:01:30 +08:00

92 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Superpaper v1 checks: router unit tests, ledger codes, work-tree builds.
set -uo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PY="$ROOT/scripts/python"
LINT=("$PY" "$ROOT/scripts/lint.py")
fail=0
ok() { echo " ok $*"; }
bad() { echo " FAIL $*"; fail=$((fail+1)); }
echo "==> router_test"
if "$PY" "$ROOT/tests/router_test.py"; then ok router_test.py; else bad router_test.py; fi
echo "==> ledger-valid"
if "${LINT[@]}" --ledger "$ROOT/tests/ledger-valid.yaml" >/dev/null 2>&1; then
ok ledger-valid.yaml
else
bad ledger-valid.yaml
fi
expect_ledger() {
local file="$1" code="$2"
local out
out=$("${LINT[@]}" --ledger "$file" 2>&1) || true
if echo "$out" | grep -q "$code"; then
ok "$(basename "$file") ($code)"
else
bad "$(basename "$file") (wanted $code)"
echo "$out" | sed 's/^/ /'
fi
}
echo "==> ledger-invalid"
for spec in \
"missing-paper-id.yaml:SP001" \
"bad-toolkit.yaml:SP001" \
"duplicate-id.yaml:SP002" \
"mixed-signals.yaml:SP011" \
"toolkit-mismatch.yaml:SP010" \
"none-not-dropped.yaml:SP013" \
"align-has-include.yaml:SP014" \
"included-null-include.yaml:SP015" \
"screenshot-bad-include.yaml:SP016" \
"superderive-v1.yaml:SP022" \
"retired-reuse.yaml:SP023" \
"dangling-claim.yaml:SP024"
do
f="${spec%%:*}"; c="${spec##*:}"
expect_ledger "$ROOT/tests/ledger-invalid/$f" "$c"
done
expect_work() {
local dir="$1" code="$2"
local out
out=$("${LINT[@]}" --work "$dir" 2>&1) || true
if echo "$out" | grep -q "$code"; then
ok "$(basename "$dir") ($code)"
else
bad "$(basename "$dir") (wanted $code)"
echo "$out" | sed 's/^/ /'
fi
}
echo "==> work-tree lint"
expect_work "$ROOT/tests/loads-sty" SP003
expect_work "$ROOT/tests/missing-request" SP012
expect_work "$ROOT/tests/unlabeled-core" SP020
expect_work "$ROOT/tests/missing-include" SP021
echo "==> compile"
for dir in \
"$ROOT/tests/notes-smoke" \
"$ROOT/examples/excerpt-toy" \
"$ROOT/examples/pipeline-delegate" \
"$ROOT/examples/tensor-delegate"
do
name="$(basename "$dir")"
if "$ROOT/scripts/build.sh" --work "$dir" >/dev/null 2>&1; then
ok "$name (build)"
else
bad "$name (build)"
"$ROOT/scripts/build.sh" --work "$dir" || true
fi
done
if [[ $fail -gt 0 ]]; then
echo "$fail failing check(s)" >&2
exit 1
fi
echo "all v1 checks passed"