From b28e1eee4282716d4a12030a5a97e2f940d79a5f Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 14 Nov 2017 12:47:48 -0500 Subject: [PATCH] Fix coverage report Previously the coverage.txt file was never populated Signed-off-by: Daniel Nephin --- Makefile | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 1244501b0..5a123b2dd 100644 --- a/Makefile +++ b/Makefile @@ -169,24 +169,30 @@ uninstall: coverage: ## generate coverprofiles from the unit tests, except tests that require root @echo "$(WHALE) $@" @rm -f coverage.txt + go test -i ${TESTFLAGS} $(filter-out ${INTEGRATION_PACKAGE},${PACKAGES}) ( for pkg in $(filter-out ${INTEGRATION_PACKAGE},${PACKAGES}); do \ - go test -i ${TESTFLAGS} -test.short -coverprofile=coverage.out -covermode=atomic $$pkg || exit; \ - if [ -f profile.out ]; then \ - cat profile.out >> coverage.txt; \ - rm profile.out; \ - fi; \ - go test ${TESTFLAGS} -test.short -coverprofile=coverage.out -covermode=atomic $$pkg || exit; \ + go test ${TESTFLAGS} \ + -cover \ + -coverprofile=profile.out \ + -covermode=atomic $$pkg || exit; \ if [ -f profile.out ]; then \ cat profile.out >> coverage.txt; \ rm profile.out; \ fi; \ done ) -root-coverage: ## generae coverage profiles for the unit tests +root-coverage: ## generate coverage profiles for unit tests that require root @echo "$(WHALE) $@" - @( for pkg in $(filter-out ${INTEGRATION_PACKAGE},${TEST_REQUIRES_ROOT_PACKAGES}); do \ - go test -i ${TESTFLAGS} -test.short -coverprofile="../../../$$pkg/coverage.txt" -covermode=atomic $$pkg -test.root || exit; \ - go test ${TESTFLAGS} -test.short -coverprofile="../../../$$pkg/coverage.txt" -covermode=atomic $$pkg -test.root || exit; \ + go test -i ${TESTFLAGS} $(filter-out ${INTEGRATION_PACKAGE},${TEST_REQUIRES_ROOT_PACKAGES}) + ( for pkg in $(filter-out ${INTEGRATION_PACKAGE},${TEST_REQUIRES_ROOT_PACKAGES}); do \ + go test ${TESTFLAGS} \ + -cover \ + -coverprofile=profile.out \ + -covermode=atomic $$pkg -test.root || exit; \ + if [ -f profile.out ]; then \ + cat profile.out >> coverage.txt; \ + rm profile.out; \ + fi; \ done ) coverage-integration: ## generate coverprofiles from the integration tests