Skip to content

Commit a05c15d

Browse files
committed
make localunit: record coverage
Inspirsed by CRI-O's coverage logic. Initial coverage is at 15.7 percent. Signed-off-by: Valentin Rothberg <[email protected]>
1 parent 644b5bc commit a05c15d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
/conmon/
88
contrib/spec/podman.spec
99
*.coverprofile
10+
coverprofile
11+
/.coverage
1012
/docs/*.[158]
1113
/docs/*.[158].gz
1214
/docs/build/

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export GO111MODULE=off
22
export GOPROXY=https://proxy.golang.org
33

44
GO ?= go
5+
COVERAGE_PATH ?= .coverage
56
DESTDIR ?=
67
EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-master} HEAD)
78
HEAD ?= HEAD
@@ -308,14 +309,20 @@ testunit: libpodimage ## Run unittest on the built image
308309
.PHONY: localunit
309310
localunit: test/goecho/goecho varlink_generate
310311
hack/check_root.sh make localunit
312+
rm -rf ${COVERAGE_PATH} && mkdir -p ${COVERAGE_PATH}
311313
ginkgo \
312314
-r \
313315
$(TESTFLAGS) \
314316
--skipPackage test/e2e,pkg/apparmor,test/endpoint,pkg/bindings,hack \
315317
--cover \
316318
--covermode atomic \
319+
--coverprofile coverprofile \
320+
--outputdir ${COVERAGE_PATH} \
317321
--tags "$(BUILDTAGS)" \
318322
--succinct
323+
$(GO) tool cover -html=${COVERAGE_PATH}/coverprofile -o ${COVERAGE_PATH}/coverage.html
324+
$(GO) tool cover -func=${COVERAGE_PATH}/coverprofile > ${COVERAGE_PATH}/functions
325+
cat ${COVERAGE_PATH}/functions | sed -n 's/\(total:\).*\([0-9][0-9].[0-9]\)/\1 \2/p'
319326

320327
.PHONY: ginkgo
321328
ginkgo:

0 commit comments

Comments
 (0)