chore: scripts/hammer.sh — flake-hammer for conn-lifecycle discipline
Default run encodes the pre-commit ritual: 35x the lifecycle-sensitive integration subset (shutdown timeout reaped slowloris streaming chunked sse stalled), fail-fast, then 3x the full suite. -n/-f override counts, '-- <words>' overrides the filter. Failing run's output lands in target/hammer-fail.log.
This commit is contained in:
Executable
+59
@@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Flake hammer: the conn-lifecycle test discipline, in one command.
|
||||||
|
#
|
||||||
|
# Default (no args) = the full pre-commit ritual for conn-lifecycle changes:
|
||||||
|
# 1. N x the lifecycle-sensitive integration subset (fail-fast)
|
||||||
|
# 2. M x the full suite (unit + integration + doc)
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# scripts/hammer.sh # 35x subset + 3x full
|
||||||
|
# scripts/hammer.sh -n 50 -f 5 # override counts
|
||||||
|
# scripts/hammer.sh -n 20 -f 0 -- shutdown sse # custom filter, skip full runs
|
||||||
|
#
|
||||||
|
# On failure: stops immediately, output of the failing run is in $LOG.
|
||||||
|
|
||||||
|
set -u
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
export PATH="$HOME/.cargo/bin:$PATH"
|
||||||
|
|
||||||
|
N=35
|
||||||
|
FULL=3
|
||||||
|
SUBSET=(shutdown timeout reaped slowloris streaming chunked sse stalled)
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-n) N="$2"; shift 2 ;;
|
||||||
|
-f) FULL="$2"; shift 2 ;;
|
||||||
|
--) shift; SUBSET=("$@"); break ;;
|
||||||
|
*) echo "unknown arg: $1" >&2; exit 2 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
LOG=target/hammer-fail.log
|
||||||
|
mkdir -p target
|
||||||
|
|
||||||
|
echo "== build once =="
|
||||||
|
cargo test --no-run --quiet || exit 1
|
||||||
|
|
||||||
|
fail() { # $1 = label
|
||||||
|
echo
|
||||||
|
echo "FAILED at $1 — output in $LOG"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "== ${N}x subset: ${SUBSET[*]} =="
|
||||||
|
for ((i = 1; i <= N; i++)); do
|
||||||
|
printf '\r subset %d/%d ' "$i" "$N"
|
||||||
|
cargo test --quiet --test integration -- "${SUBSET[@]}" >"$LOG" 2>&1 \
|
||||||
|
|| fail "subset run $i/$N"
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "== ${FULL}x full suite =="
|
||||||
|
for ((i = 1; i <= FULL; i++)); do
|
||||||
|
printf ' full %d/%d\n' "$i" "$FULL"
|
||||||
|
cargo test --quiet >"$LOG" 2>&1 || fail "full run $i/$FULL"
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -f "$LOG"
|
||||||
|
echo "hammer green: ${N}x subset + ${FULL}x full"
|
||||||
Reference in New Issue
Block a user