make localunit: record coverage

Inspirsed by CRI-O's coverage logic.  Initial coverage is at 15.7
percent.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg 2020-07-21 14:54:57 +02:00
parent 644b5bc8a3
commit a05c15da2f
2 changed files with 9 additions and 0 deletions

2
.gitignore vendored
View File

@ -7,6 +7,8 @@
/conmon/ /conmon/
contrib/spec/podman.spec contrib/spec/podman.spec
*.coverprofile *.coverprofile
coverprofile
/.coverage
/docs/*.[158] /docs/*.[158]
/docs/*.[158].gz /docs/*.[158].gz
/docs/build/ /docs/build/

View File

@ -2,6 +2,7 @@ export GO111MODULE=off
export GOPROXY=https://proxy.golang.org export GOPROXY=https://proxy.golang.org
GO ?= go GO ?= go
COVERAGE_PATH ?= .coverage
DESTDIR ?= DESTDIR ?=
EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-master} HEAD) EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-master} HEAD)
HEAD ?= HEAD HEAD ?= HEAD
@ -308,14 +309,20 @@ testunit: libpodimage ## Run unittest on the built image
.PHONY: localunit .PHONY: localunit
localunit: test/goecho/goecho varlink_generate localunit: test/goecho/goecho varlink_generate
hack/check_root.sh make localunit hack/check_root.sh make localunit
rm -rf ${COVERAGE_PATH} && mkdir -p ${COVERAGE_PATH}
ginkgo \ ginkgo \
-r \ -r \
$(TESTFLAGS) \ $(TESTFLAGS) \
--skipPackage test/e2e,pkg/apparmor,test/endpoint,pkg/bindings,hack \ --skipPackage test/e2e,pkg/apparmor,test/endpoint,pkg/bindings,hack \
--cover \ --cover \
--covermode atomic \ --covermode atomic \
--coverprofile coverprofile \
--outputdir ${COVERAGE_PATH} \
--tags "$(BUILDTAGS)" \ --tags "$(BUILDTAGS)" \
--succinct --succinct
$(GO) tool cover -html=${COVERAGE_PATH}/coverprofile -o ${COVERAGE_PATH}/coverage.html
$(GO) tool cover -func=${COVERAGE_PATH}/coverprofile > ${COVERAGE_PATH}/functions
cat ${COVERAGE_PATH}/functions | sed -n 's/\(total:\).*\([0-9][0-9].[0-9]\)/\1 \2/p'
.PHONY: ginkgo .PHONY: ginkgo
ginkgo: ginkgo: