Merge pull request #1757 from dnephin/fix-coverage

Fix coverage report
This commit is contained in:
Phil Estes 2017-11-14 13:33:11 -05:00 committed by GitHub
commit f435ec0733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -169,24 +169,30 @@ uninstall:
coverage: ## generate coverprofiles from the unit tests, except tests that require root coverage: ## generate coverprofiles from the unit tests, except tests that require root
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
@rm -f coverage.txt @rm -f coverage.txt
go test -i ${TESTFLAGS} $(filter-out ${INTEGRATION_PACKAGE},${PACKAGES})
( for pkg in $(filter-out ${INTEGRATION_PACKAGE},${PACKAGES}); do \ ( for pkg in $(filter-out ${INTEGRATION_PACKAGE},${PACKAGES}); do \
go test -i ${TESTFLAGS} -test.short -coverprofile=coverage.out -covermode=atomic $$pkg || exit; \ go test ${TESTFLAGS} \
if [ -f profile.out ]; then \ -cover \
cat profile.out >> coverage.txt; \ -coverprofile=profile.out \
rm profile.out; \ -covermode=atomic $$pkg || exit; \
fi; \
go test ${TESTFLAGS} -test.short -coverprofile=coverage.out -covermode=atomic $$pkg || exit; \
if [ -f profile.out ]; then \ if [ -f profile.out ]; then \
cat profile.out >> coverage.txt; \ cat profile.out >> coverage.txt; \
rm profile.out; \ rm profile.out; \
fi; \ fi; \
done ) done )
root-coverage: ## generae coverage profiles for the unit tests root-coverage: ## generate coverage profiles for unit tests that require root
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
@( for pkg in $(filter-out ${INTEGRATION_PACKAGE},${TEST_REQUIRES_ROOT_PACKAGES}); do \ go test -i ${TESTFLAGS} $(filter-out ${INTEGRATION_PACKAGE},${TEST_REQUIRES_ROOT_PACKAGES})
go test -i ${TESTFLAGS} -test.short -coverprofile="../../../$$pkg/coverage.txt" -covermode=atomic $$pkg -test.root || exit; \ ( for pkg in $(filter-out ${INTEGRATION_PACKAGE},${TEST_REQUIRES_ROOT_PACKAGES}); do \
go test ${TESTFLAGS} -test.short -coverprofile="../../../$$pkg/coverage.txt" -covermode=atomic $$pkg -test.root || exit; \ 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 ) done )
coverage-integration: ## generate coverprofiles from the integration tests coverage-integration: ## generate coverprofiles from the integration tests