From c171be7ddcfa3f402305bc5c4c6b8b92aab0a1af Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 12 Jun 2026 09:10:17 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20scripts/hammer.sh=20=E2=80=94=20flake-?= =?UTF-8?q?hammer=20for=20conn-lifecycle=20discipline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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, '-- ' overrides the filter. Failing run's output lands in target/hammer-fail.log. --- scripts/hammer.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 scripts/hammer.sh diff --git a/scripts/hammer.sh b/scripts/hammer.sh new file mode 100755 index 0000000..113541c --- /dev/null +++ b/scripts/hammer.sh @@ -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"