git » summer » commit 02813d6

test: Use `covermode=count` on coverage tests

author Alberto Bertogli
2024-04-07 10:41:53 UTC
committer Alberto Bertogli
2024-04-07 10:41:53 UTC
parent 1086b07b6a396740cc7021f0ea73c9977c4e7ca6

test: Use `covermode=count` on coverage tests

Coverage tests use `covermode=set` by default, which just checks if a
statement was run at all.

This patch changes them to use `covermode=count`, which keeps track of how
many times each statement was run.

The count mode results in more useful coverage information, with
negligible downsides for our use case.

test/cover.sh +2 -2

diff --git a/test/cover.sh b/test/cover.sh
index 259cf2a..cc521aa 100755
--- a/test/cover.sh
+++ b/test/cover.sh
@@ -7,12 +7,12 @@ export GOCOVERDIR="$PWD/.cover/"
 rm -rf "${GOCOVERDIR?}"
 mkdir -p "${GOCOVERDIR?}"
 
-export BUILDARGS="-cover"
+export BUILDARGS="-cover -covermode=count"
 
 # Coverage tests require Go >= 1.20.
 go version
 
-go test -cover ../... -args -test.gocoverdir="${GOCOVERDIR?}"
+go test -cover ../... -covermode=count -args -test.gocoverdir="${GOCOVERDIR?}"
 
 ./test.sh