8af37d44a1
The stamp gate is scripts/assemble-stamp.sh, taking FILE PATTERN pairs, and scripts/assemble-stamp-test.sh is its check_the_checker. Deleting the final `test -z "$missing"` makes four of its eight cases fail; before the extraction that same deletion was invisible, both misses printing while assemble.sh exited 0. It is a separate script because exercising it inside assemble.sh would need a fabricated web/pkg, which is a second answer to "what does the site assemble from" (improvise-vvl3). Wired into the `build` job, first, because it needs nothing and guards a step in that job. web/tests/bundle_freedom.test.js refuses a flat web/tests/ file that names the bundle directory -- the constraint keeping the `js` job at seconds rather than ~4m30s, stated in prose and checked by nothing. It scans its own filename too, so it cannot become the place a violation hides, and its companion asserts web/tests/bundle/ still holds a test that DOES use the bundle: a scoping rule is uninteresting if nothing falls outside it. Both faults were injected and watched to fail; evidence in context/test-evidence/tooling.md. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FC2jVn8Au7E9JPkw6bwXXH
74 lines
3.1 KiB
Bash
Executable File
74 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# check_the_checker for scripts/assemble-stamp.sh. The gate it holds was
|
|
# deleted on PR #69 by injection and the assembly still exited 0 with both
|
|
# failures printed -- a guard nobody had watched fail (improvise-w8ih).
|
|
set -uo pipefail
|
|
|
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
RUN="$here/assemble-stamp.sh"
|
|
work="$(mktemp -d)"
|
|
trap 'rm -rf "$work"' EXIT
|
|
|
|
pass=0; fail=0
|
|
ok() { printf ' ok %s\n' "$1"; pass=$((pass+1)); }
|
|
bad() { printf ' FAIL %s (exit %s, wanted %s)\n' "$1" "$2" "$3"; fail=$((fail+1)); }
|
|
|
|
# $1 name, $2 expected exit, $3 expected stderr substring ("" for none), rest: args
|
|
run_case() {
|
|
local name="$1" want="$2" says="$3"; shift 3
|
|
local err
|
|
err="$(sh "$RUN" "$@" 2>&1 >/dev/null)"
|
|
local got=$?
|
|
if [ "$got" != "$want" ]; then
|
|
bad "$name" "$got" "$want"
|
|
elif [ -n "$says" ] && [[ "$err" != *"$says"* ]]; then
|
|
bad "$name: stderr did not name it" "$err" "$says"
|
|
else
|
|
ok "$name"
|
|
fi
|
|
}
|
|
|
|
printf 'import "./pkg/improvise_wasm_client.js?v=abc";\n' > "$work/stamped.js"
|
|
printf 'import "./worker-pkg/improvise_worker_server.js?v=abc";\n' > "$work/stamped2.js"
|
|
printf 'import "./pkg/improvise_wasm_client.js";\n' > "$work/bare.js"
|
|
printf 'import "./worker-pkg/improvise_worker_server.js";\n' > "$work/bare2.js"
|
|
|
|
run_case "a stamped file passes" 0 "" \
|
|
"$work/stamped.js" "pkg/improvise_wasm_client.js?v=abc"
|
|
|
|
run_case "an unstamped file is refused and named" 1 "bare.js" \
|
|
"$work/bare.js" "pkg/improvise_wasm_client.js?v=abc"
|
|
|
|
# The bug the gate exists for: without the final `test -z`, the misses print
|
|
# and the script exits 0. Both must be NAMED, which is what exiting on the
|
|
# first one cost.
|
|
run_case "two misses are both named, not just the first" 1 "bare2.js" \
|
|
"$work/bare.js" "pkg/improvise_wasm_client.js?v=abc" \
|
|
"$work/bare2.js" "worker-pkg/improvise_worker_server.js?v=abc"
|
|
|
|
run_case "a miss among hits is still refused" 1 "bare2.js" \
|
|
"$work/stamped.js" "pkg/improvise_wasm_client.js?v=abc" \
|
|
"$work/bare2.js" "worker-pkg/improvise_worker_server.js?v=abc"
|
|
|
|
run_case "all four stamped is the shipping case" 0 "" \
|
|
"$work/stamped.js" "pkg/improvise_wasm_client.js?v=abc" \
|
|
"$work/stamped2.js" "worker-pkg/improvise_worker_server.js?v=abc"
|
|
|
|
# A file the assembly never copied is indistinguishable from an unstamped one
|
|
# to `grep`, which errors rather than failing quietly -- but only because the
|
|
# -f test runs first. Without it `set -e` would abort mid-list and the later
|
|
# files would go unreported, which is the failure this gate was built to end.
|
|
run_case "a file that does not exist is a miss, not an abort" 1 "vanished.js" \
|
|
"$work/vanished.js" "anything" \
|
|
"$work/bare2.js" "worker-pkg/improvise_worker_server.js?v=abc"
|
|
|
|
# A caller that drops one argument would otherwise have the last FILE read as
|
|
# a PATTERN over the file before it -- a check that passes by accident.
|
|
run_case "an odd number of arguments is a usage error" 2 "pairs" \
|
|
"$work/stamped.js" "pkg/improvise_wasm_client.js?v=abc" "$work/bare.js"
|
|
|
|
run_case "no arguments at all is a usage error, not a pass" 2 "usage"
|
|
|
|
printf '\nassemble-stamp-test: %d passed, %d failed\n' "$pass" "$fail"
|
|
[ "$fail" -eq 0 ]
|