check / check (push) Failing after 2s
script/test now runs the suite quietly first (with -race and -cover, 30s timeout) and re-runs it with -v only when that run fails, then exits non-zero. This is the pattern REPO_POLICIES.md mandates; before, every green run printed full per-test output. What a reader would trip over: the whole compound command is passed as one string to run_with_cgo_deps, so it behaves the same on the host path and under the nix-shell fallback. -cover is on the first run only; the verbose rerun exists for diagnostics. Disclosure: no test was written for the wrapper script itself; the failure path was exercised by hand by author and reviewer. Disclosure: the nix-shell fallback is kept; moving tests into Docker belongs to #101 and #104. Model: opus-4-8 (implementation, review); fable-5-1 (landing message)
28 lines
985 B
Bash
Executable File
28 lines
985 B
Bash
Executable File
#!/bin/sh
|
|
# script/test: run the test suite. CGO dependencies (pkg-config, vips,
|
|
# libheif) come from nix-shell when not already available (e.g. inside
|
|
# a Docker build or an existing nix-shell).
|
|
set -eu
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
|
|
|
run_with_cgo_deps() {
|
|
if command -v pkg-config >/dev/null 2>&1; then
|
|
sh -c "$1"
|
|
else
|
|
nix-shell -p pkg-config vips libheif golangci-lint git --run "$1"
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
cd "$ROOT"
|
|
echo "Running tests..."
|
|
# Run without -v first for clean output on success; on failure rerun
|
|
# with -v for full diagnostics, then exit non-zero (REPO_POLICIES.md
|
|
# conditional-verbose-rerun pattern). The first run already proved the
|
|
# tests broken, so the build fails even if the rerun happens to pass.
|
|
run_with_cgo_deps "CGO_ENABLED=1 go test -timeout 30s -race -cover ./... || { echo '--- Rerunning with -v for details ---'; CGO_ENABLED=1 go test -timeout 30s -race -v ./...; exit 1; }"
|
|
}
|
|
|
|
main "$@"
|