2019-10-15 16:15:33 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
set -eux -o pipefail
|
|
|
|
|
|
2025-08-26 10:13:01 +00:00
|
|
|
# check for local installation of go-junit-report otherwise install locally
|
2022-02-02 02:59:58 +00:00
|
|
|
which go-junit-report || go install github.com/jstemmer/go-junit-report@latest
|
2020-05-31 21:11:28 +00:00
|
|
|
|
2025-08-26 10:13:01 +00:00
|
|
|
# check for local installation of gotestsum otherwise install locally
|
|
|
|
|
which gotestsum || go install gotest.tools/gotestsum@latest
|
|
|
|
|
|
2019-10-15 16:15:33 +00:00
|
|
|
TEST_RESULTS=${TEST_RESULTS:-test-results}
|
2024-06-05 02:45:53 +00:00
|
|
|
TEST_FLAGS=${TEST_FLAGS:-}
|
2025-12-19 16:34:06 +00:00
|
|
|
DIST_DIR=${DIST_DIR:-dist}
|
|
|
|
|
|
|
|
|
|
# Add DIST_DIR to PATH so binaries installed for argo are found first
|
|
|
|
|
export PATH="${DIST_DIR}:${PATH}"
|
2020-03-27 18:36:20 +00:00
|
|
|
|
|
|
|
|
if test "${ARGOCD_TEST_PARALLELISM:-}" != ""; then
|
|
|
|
|
TEST_FLAGS="$TEST_FLAGS -p $ARGOCD_TEST_PARALLELISM"
|
|
|
|
|
fi
|
|
|
|
|
if test "${ARGOCD_TEST_VERBOSE:-}" != ""; then
|
|
|
|
|
TEST_FLAGS="$TEST_FLAGS -v"
|
|
|
|
|
fi
|
2019-10-15 16:15:33 +00:00
|
|
|
|
2025-07-18 11:38:27 +00:00
|
|
|
mkdir -p "$TEST_RESULTS"
|
2019-10-15 16:15:33 +00:00
|
|
|
|
2025-07-18 11:38:27 +00:00
|
|
|
# `TEST_FLAGS` cannot be quoted as empty needs to evaluate to 0 arguments.
|
|
|
|
|
# `TEST_FLAGS` cannot be turned into array without backward incompatible change of script input
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
GODEBUG="tarinsecurepath=0,zipinsecurepath=0" \
|
|
|
|
|
gotestsum --rerun-fails-report=rerunreport.txt --junitfile="$TEST_RESULTS/junit.xml" --format=testname \
|
2025-12-08 08:00:38 +00:00
|
|
|
--rerun-fails="$RERUN_FAILS" --packages="${TEST_MODULE:-$PACKAGES}" -- -cover $TEST_FLAGS "$@"
|