Skip to content

Commit 5446423

Browse files
committed
test: fix coverage coverage accounting
Commit "github-ci: add Coveralls support" (31ebde8) introduced code coverage support. However there is wrong value for option -covermode was specified - "count". According to documentation [1] "count" calculates how many times did each statement run and "atomic" mode is like "count", but counts precisely in parallel programs. We don't use parallel mode in tests at all (-p 1) and for code coverage measurement particularly, but it is better using "atomic" mode instead "count". Option "-coverpkg" was missed. "coverpkg" applies coverage analysis in each test to packages matching the patterns. The default is for each test to analyze only the package being tested. Total statement coverage without -coverpkg is 66.8% and with -coverpkg is 69.3% according to "go tool cover". 1. https://go.dev/blog/cover
1 parent a9e491f commit 5446423

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test-main:
6262
coverage:
6363
go clean -testcache
6464
go get golang.org/x/tools/cmd/cover
65-
go test ./... -v -p 1 -covermode=count -coverprofile=$(COVERAGE_FILE)
65+
go test ./... -v -p 1 -covermode=atomic -coverprofile=$(COVERAGE_FILE) -coverpkg=./...
6666

6767
.PHONY: coveralls
6868
coveralls: coverage

0 commit comments

Comments
 (0)