Add -cover flag to go test

Make go test (make check) report the coverage percentage of the unit
tests that run. Add checkcoverage target to generate a coverage.out file
for a given package.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
This commit is contained in:
Matthew Johnson
2018-02-08 11:58:24 -08:00
parent 5e94f151a0
commit 15938366ae
+10 -1
View File
@@ -45,7 +45,16 @@ install: gopath
install -D -m 00644 yum.conf.in $(DESTDIR)/usr/share/defaults/mixer/yum.conf.in
check: gopath
go test ${GO_PACKAGE_PREFIX}/...
go test -cover ${GO_PACKAGE_PREFIX}/...
# TODO: when Go 1.10 comes out we will have support for passing multiple packages
# to coverprofile, so there will be no need to pass an individual package.
# At that time we can merge this target into check and run it against all
# packages every time.
checkcoverage: gopath
test ${PKG}
go test -cover ${GO_PACKAGE_PREFIX}/${PKG} -coverprofile=coverage.out
go tool cover -html=coverage.out
.PHONY: lint
lint: gopath