From 9fe200465f2496b578635e71bdc9667ad94c0fce Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Tue, 20 Aug 2024 00:07:45 +0100 Subject: [PATCH] chore_: attempt UNIT_TEST_COUNT as test count --- _assets/scripts/run_unit_tests.sh | 8 ++++---- _assets/scripts/test-with-coverage.sh | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/_assets/scripts/run_unit_tests.sh b/_assets/scripts/run_unit_tests.sh index 28388b37e..3cc52ec4f 100755 --- a/_assets/scripts/run_unit_tests.sh +++ b/_assets/scripts/run_unit_tests.sh @@ -50,11 +50,11 @@ run_test_for_packages() { # Run tests PACKAGES=${packages} \ + UNIT_TEST_COUNT=${UNIT_TEST_COUNT} \ gotestsum --packages="${packages}" ${gotestsum_flags} --raw-command -- \ ./_assets/scripts/test-with-coverage.sh \ -v ${GOTEST_EXTRAFLAGS} \ -timeout 45m \ - -count 1 \ -tags "${BUILD_TAGS}" | \ redirect_stdout "${output_file}" @@ -84,9 +84,9 @@ echo -e "${GRN}Testing HEAD:${RST} $(git rev-parse HEAD)" rm -rf ./**/*.coverage.out -for ((i=1; i<=UNIT_TEST_COUNT; i++)); do - run_test_for_packages "${UNIT_TEST_PACKAGES}" "${i}" -done +#for ((i=1; i<=UNIT_TEST_COUNT; i++)); do +run_test_for_packages "${UNIT_TEST_PACKAGES}" "1" +#done # Gather test coverage results rm -f c.out c-full.out diff --git a/_assets/scripts/test-with-coverage.sh b/_assets/scripts/test-with-coverage.sh index f6c6f8a36..96040f283 100755 --- a/_assets/scripts/test-with-coverage.sh +++ b/_assets/scripts/test-with-coverage.sh @@ -3,16 +3,19 @@ set -eu packages="" coverage_file_path="$(mktemp coverage.out.rerun.XXXXXXXXXX)" +count=1 # This is a hack to workaround gotestsum behaviour. When using a --raw-command, # gotestsum will only pass the package when rerunning a test. Otherwise we should pass the package ourselves. # https://github.com/gotestyourself/gotestsum/blob/03568ab6d48faabdb632013632ac42687b5f17d1/cmd/main.go#L331-L336 if [[ "$*" != *"-test.run"* ]]; then packages="${PACKAGES}" + count=${UNIT_TEST_COUNT} fi go test -json \ ${packages} \ + -count=${count} \ -covermode=atomic \ -coverprofile="${coverage_file_path}" \ -coverpkg ./... \