55# Environment variables (override as needed):
66# PARALLEL Go test -parallel value (default 6)
77# TIMEOUT Per test package timeout (default 30m)
8- # RERUN_MAX_TIMES How many times to re-run a failing test (default 2)
9- # RERUN_FAILS Max number of distinct failing tests eligible for rerun (default 50)
8+ # RERUN_MAX_TIMES How many *additional* times to re-run failing tests (default 2). Maps to gotestsum --rerun-fails (attempts = value )
9+ # RERUN_MAX_FAILURES Maximum number of initial failures to allow before giving up on reruns (default 50). Maps to gotestsum --rerun-fails-max-failures
1010# EXTRA_ARGS Extra args to pass through to `go test` after the rerun flags
1111# TF_ACC Forced to 1 if unset (enables acceptance tests)
1212#
@@ -21,7 +21,7 @@ set -euo pipefail
2121PARALLEL=${PARALLEL:- 6}
2222TIMEOUT=${TIMEOUT:- 30m}
2323RERUN_MAX_TIMES=${RERUN_MAX_TIMES:- 2}
24- RERUN_FAILS =${RERUN_FAILS :- 50}
24+ RERUN_MAX_FAILURES =${RERUN_MAX_FAILURES :- 50}
2525EXTRA_ARGS=${EXTRA_ARGS:- }
2626
2727export TF_ACC=${TF_ACC:- 1}
@@ -30,18 +30,33 @@ if ! command -v gotestsum >/dev/null 2>&1; then
3030 echo " [INFO] Installing gotestsum (not found in PATH)" >&2
3131 # Pin a version for reproducibility; update periodically.
3232 go install gotest.tools/gotestsum@v1.12.0
33+ # After installation, ensure GOPATH/bin (or GOBIN) is on PATH for this script execution.
34+ GOBIN_DIR=$( go env GOBIN 2> /dev/null || true)
35+ GOPATH_DIR=$( go env GOPATH 2> /dev/null || true)
36+ if [ -n " $GOBIN_DIR " ] && [ -d " $GOBIN_DIR " ]; then
37+ PATH=" $GOBIN_DIR :$PATH "
38+ elif [ -n " $GOPATH_DIR " ] && [ -d " $GOPATH_DIR /bin" ]; then
39+ PATH=" $GOPATH_DIR /bin:$PATH "
40+ fi
41+ fi
42+
43+ # Final defensive check
44+ if ! command -v gotestsum > /dev/null 2>&1 ; then
45+ echo " [ERROR] gotestsum still not found after installation. PATH=$PATH " >&2
46+ echo " You may need to export GOBIN or GOPATH before running this script." >&2
47+ exit 2
3348fi
3449
3550echo " [INFO] Running acceptance tests with selective reruns"
36- echo " parallel=${PARALLEL} timeout=${TIMEOUT} rerun_max_times=${RERUN_MAX_TIMES} rerun_fails =${RERUN_FAILS } " \
37- " extra_args='${EXTRA_ARGS} '"
51+ echo " parallel=${PARALLEL} timeout=${TIMEOUT} rerun_max_times=${RERUN_MAX_TIMES} rerun_max_failures =${RERUN_MAX_FAILURES } " \
52+ " extra_args='${EXTRA_ARGS} '"
3853
3954# We disable test caching (-count=1) to ensure fresh runs against live APIs.
4055set +e
4156gotestsum --format=short-verbose \
4257 --junitfile test-report.xml \
43- --rerun-fails=" ${RERUN_FAILS } " \
44- --rerun-fails-max-times =" ${RERUN_MAX_TIMES } " \
58+ --rerun-fails=" ${RERUN_MAX_TIMES } " \
59+ --rerun-fails-max-failures =" ${RERUN_MAX_FAILURES } " \
4560 --packages=" ./..." \
4661 -- -count=1 -parallel=" ${PARALLEL} " -timeout=" ${TIMEOUT} " ${EXTRA_ARGS}
4762status=$?
0 commit comments