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
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

View File

@ -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 ./... \