Files
cli/scripts/test-generate-check.sh
zeekay 57c9521f14 The engine rides with hanzo; one gen pin; the lane's check stops depending on the day
hanzo.sh installs `dev` with `hanzo` and lists it nowhere, so `upgrade` names
hanzo and brings the engine (with_engine) and refuses `dev` as a name; the
install hints say "run the installer", not "-- dev". hanzo-gen is pinned once, in
[workspace.dependencies], at 41cb6d8 (0.1.3: a run's commit says Hanzo, not Hanzo
Dev); the identity crate had its own rev and linked a second copy.

generate.sh --check handed genspec the document api.hanzo.ai serves now, which
moves every few hours, so every push went red once cloud shipped (a8c4fe1,
adeb1c4). It rules on spec/cloud.json only while that document is the one
.spec-lock names; moved, it says a re-pin is due and still checks the generated
tree. 34d5ec2c made `chain up` need a network and left one parse test on it:
`chain status` there.

hanzoai/cli#64.

Claude-Session: https://claude.ai/code/session_015XYKLn69gF4x75RWePpDBV
2026-11-21 02:51:20 -08:00

36 lines
1.3 KiB
Bash

#!/bin/sh
# generate.sh --check against a document that matches the lock, one that moved, and a
# committed spec that is stale: cargo is a stub that records what it was asked.
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT HUP INT TERM
mkdir -p "$work/bin" "$work/tree/scripts"
cp "$root/scripts/generate.sh" "$work/tree/scripts/"
printf 'ref=r\nsha256=%s\nrepo=x\npath=y\n' "$(printf locked | sha256sum | cut -d' ' -f1)" > "$work/tree/.spec-lock"
cat > "$work/bin/cargo" <<'SH'
#!/bin/sh
case "$*" in *genproduct*) bin=genproduct ;; *) bin=genspec ;; esac
echo "$bin" >> "$CALLS"
[ "$bin" != "${FAIL:-}" ]
SH
chmod +x "$work/bin/cargo"
PATH="$work/bin:$PATH"
CALLS="$work/calls"
export CALLS PATH
check() { : > "$CALLS"; SPEC="$1" sh "$work/tree/scripts/generate.sh" --check; }
printf locked > "$work/same"
check "$work/same" > /dev/null
[ "$(tr '\n' ' ' < "$CALLS")" = "genproduct genspec " ]
printf moved > "$work/moved"
check "$work/moved" > "$work/out"
[ "$(tr '\n' ' ' < "$CALLS")" = "genproduct " ]
grep -q 're-pin is due' "$work/out"
if FAIL=genproduct check "$work/moved" > /dev/null 2>&1; then exit 1; fi
if FAIL=genspec check "$work/same" > /dev/null 2>&1; then exit 1; fi
echo "generate --check: current, moved and stale all ruled"