feat(queue): queue as data A1, journal, lock, CLI and verify (#1508)
packages/queue, scripts/queue-commit.sh, scripts/git-hooks and scripts/test-queue.sh, plus docs/plans/BRIEF-TEMPLATE.md. There is no queue.json yet, so verify skips until the genesis commit after A2. Darkwing built it, and Filbert reviewed R0 (6933b885, changes requested) and r1 (e464be6c, approved). The 20 files match manifest 85a8a453. The nine suites passed on an index export, including the new queue suite. test-queue.sh joins the suite list in AGENTS.md. Lead decisions 20, 23 and 26. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
# Suite for packages/queue (issue #1508). Every test runs in scratch
|
||||
# repositories under the system temp directory; nothing touches this
|
||||
# checkout's .git, lock, witness or queue files.
|
||||
#
|
||||
# scripts/test-queue.sh full run
|
||||
# NO_COLOR=1 scripts/test-queue.sh plain output
|
||||
#
|
||||
# Once HEAD holds docs/plans/queue.json (the genesis commit), the suite also
|
||||
# runs `verify` on the live queue, which takes the queue lock for a moment
|
||||
# and writes nothing.
|
||||
set -uo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
SANDBOX="$(mktemp -d)"
|
||||
trap 'rm -rf "$SANDBOX"' EXIT
|
||||
PASS=0
|
||||
FAIL=0
|
||||
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
|
||||
C_OK=$'\033[0;32m'; C_FAIL=$'\033[0;31m'; C_RESET=$'\033[0m'
|
||||
else
|
||||
C_OK=""; C_FAIL=""; C_RESET=""
|
||||
fi
|
||||
check() {
|
||||
if [ "$2" = "0" ]; then PASS=$((PASS+1)); echo "${C_OK}OK${C_RESET} $1"; else FAIL=$((FAIL+1)); echo "${C_FAIL}FAIL${C_RESET} $1"; fi
|
||||
}
|
||||
|
||||
echo "toolchain: node $(node --version), $(git --version)"
|
||||
echo
|
||||
|
||||
# --- syntax ---
|
||||
for f in packages/queue/src/*.mjs packages/queue/tests/*.mjs packages/queue/tests/fixtures/*.mjs scripts/queue-commit.sh scripts/git-hooks/pre-commit; do
|
||||
case "$f" in
|
||||
*.sh) bash -n "$f" >/dev/null 2>&1 ;;
|
||||
*/pre-commit) sh -n "$f" >/dev/null 2>&1 ;;
|
||||
*) node --check "$f" >/dev/null 2>&1 ;;
|
||||
esac
|
||||
check "syntax: $f" $?
|
||||
done
|
||||
[ -x scripts/queue-commit.sh ] && [ -x scripts/git-hooks/pre-commit ]
|
||||
check "queue-commit.sh and the guard are executable" $?
|
||||
node -e 'const p=require("./packages/queue/package.json"); process.exit(p.dependencies||p.devDependencies?1:0)' >/dev/null 2>&1
|
||||
check "packages/queue declares no dependencies" $?
|
||||
|
||||
# --- the package tests ---
|
||||
env -u NODE_TEST_CONTEXT node --test --test-reporter=spec packages/queue/tests/ > "$SANDBOX/tests.log" 2>&1
|
||||
rc=$?
|
||||
grep -E '^ℹ (tests|pass|fail) ' "$SANDBOX/tests.log"
|
||||
if [ "$rc" != 0 ]; then grep -E '^✖|Error' "$SANDBOX/tests.log" | head -40; fi
|
||||
check "node --test packages/queue/tests/" "$rc"
|
||||
|
||||
# --- the live queue, once genesis is committed ---
|
||||
if git cat-file -e HEAD:docs/plans/queue.json 2>/dev/null; then
|
||||
node packages/queue/src/cli.mjs verify
|
||||
check "queue verify (live queue)" $?
|
||||
else
|
||||
echo "skip queue verify: HEAD has no docs/plans/queue.json (before the genesis commit)"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "queue suite: $PASS passed, $FAIL failed"
|
||||
[ "$FAIL" = 0 ]
|
||||
Reference in New Issue
Block a user