Files
pixa/script/test
T
sneak 2dbc76fa36
check / check (push) Successful in 2m29s
fix: script/test conditional-verbose-rerun with -cover (closes #59)
Run the suite without -v first so a passing build shows only per-package
summaries; on failure rerun with -v for full diagnostics and exit
non-zero, matching the conditional-verbose-rerun pattern in
REPO_POLICIES.md. Add -cover to the first run per the policy's Go
example; keep -race (added in #55) and the existing nix-shell CGO
fallback for hosts without pkg-config/vips.

Model: opus-4-8
2026-09-21 17:11:41 +00:00

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 "$@"