chore_: attempt UNIT_TEST_COUNT as test count

This commit is contained in:
Igor Sirotin 2024-08-20 00:07:45 +01:00
parent e5c8a48f0c
commit 9fe200465f
No known key found for this signature in database
GPG Key ID: 425E227CAAB81F95
2 changed files with 7 additions and 4 deletions

View File

@ -50,11 +50,11 @@ run_test_for_packages() {
# Run tests # Run tests
PACKAGES=${packages} \ PACKAGES=${packages} \
UNIT_TEST_COUNT=${UNIT_TEST_COUNT} \
gotestsum --packages="${packages}" ${gotestsum_flags} --raw-command -- \ gotestsum --packages="${packages}" ${gotestsum_flags} --raw-command -- \
./_assets/scripts/test-with-coverage.sh \ ./_assets/scripts/test-with-coverage.sh \
-v ${GOTEST_EXTRAFLAGS} \ -v ${GOTEST_EXTRAFLAGS} \
-timeout 45m \ -timeout 45m \
-count 1 \
-tags "${BUILD_TAGS}" | \ -tags "${BUILD_TAGS}" | \
redirect_stdout "${output_file}" redirect_stdout "${output_file}"
@ -84,9 +84,9 @@ echo -e "${GRN}Testing HEAD:${RST} $(git rev-parse HEAD)"
rm -rf ./**/*.coverage.out rm -rf ./**/*.coverage.out
for ((i=1; i<=UNIT_TEST_COUNT; i++)); do #for ((i=1; i<=UNIT_TEST_COUNT; i++)); do
run_test_for_packages "${UNIT_TEST_PACKAGES}" "${i}" run_test_for_packages "${UNIT_TEST_PACKAGES}" "1"
done #done
# Gather test coverage results # Gather test coverage results
rm -f c.out c-full.out rm -f c.out c-full.out

View File

@ -3,16 +3,19 @@ set -eu
packages="" packages=""
coverage_file_path="$(mktemp coverage.out.rerun.XXXXXXXXXX)" coverage_file_path="$(mktemp coverage.out.rerun.XXXXXXXXXX)"
count=1
# This is a hack to workaround gotestsum behaviour. When using a --raw-command, # 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. # 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 # https://github.com/gotestyourself/gotestsum/blob/03568ab6d48faabdb632013632ac42687b5f17d1/cmd/main.go#L331-L336
if [[ "$*" != *"-test.run"* ]]; then if [[ "$*" != *"-test.run"* ]]; then
packages="${PACKAGES}" packages="${PACKAGES}"
count=${UNIT_TEST_COUNT}
fi fi
go test -json \ go test -json \
${packages} \ ${packages} \
-count=${count} \
-covermode=atomic \ -covermode=atomic \
-coverprofile="${coverage_file_path}" \ -coverprofile="${coverage_file_path}" \
-coverpkg ./... \ -coverpkg ./... \