Skip to content

Commit

Permalink
tests: use -coverpkg to further improve coverage accuracy (#25)
Browse files Browse the repository at this point in the history
-coverpkgleads to worse reporting while the tests are being executed but
may make overall reporting more accurate - include all cross-package
calls but ignore generated code.
  • Loading branch information
murfffi authored Jan 10, 2025
1 parent af1a6eb commit dc40b67
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ usql:
test-cli: usql
./usql -c "\drivers" | grep impala

PKGS=$(shell exec go list ./... | grep -v "./internal/generated")
PKGS_LST=$(shell echo ${PKGS} | tr ' ' ',')
test:
mkdir -p coverage/covdata
# Use the new binary format to ensure integration tests and cross-package calls are counted towards coverage
# https://go.dev/blog/integration-test-coverage
go test -race -cover -v -vet=all `exec go list ./... | grep -v "./internal/generated"` -args -test.gocoverdir="${PWD}/coverage/covdata"
# -coverpkg can't be ./... because that will include generated code in the stats
go test -race -cover -coverpkg "${PKGS_LST}" -v -vet=all ${PKGS} -args -test.gocoverdir="${PWD}/coverage/covdata"
go tool covdata percent -i=./coverage/covdata
# Convert to old text format for coveralls upload
go tool covdata textfmt -i=./coverage/covdata -o ./coverage/covprofile
Expand Down

0 comments on commit dc40b67

Please sign in to comment.