Add coverage make target

These changes add a coverage target to align with other projects.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2023-05-24 17:02:31 +02:00
parent 649703f6b3
commit 50d9615b6c
2 changed files with 11 additions and 5 deletions

View File

@ -81,4 +81,4 @@ unit-tests:
- .requires-build-image
stage: test
script:
- make docker-test
- make docker-coverage

View File

@ -25,8 +25,8 @@ endif
IMAGE_TAG ?= $(GOLANG_VERSION)
BUILDIMAGE ?= $(IMAGE):$(IMAGE_TAG)-devel
TARGETS := binary build all check fmt assert-fmt generate lint vet test
DOCKER_TARGETS := $(patsubst %, docker-%, $(TARGETS))
TARGETS := binary build all check fmt assert-fmt generate lint vet test coverage
DOCKER_TARGETS := $(patsubst %,docker-%, $(TARGETS))
.PHONY: $(TARGETS) $(DOCKER_TARGETS)
GOOS := linux
@ -64,8 +64,14 @@ lint:
vet:
go vet $(MODULE)/...
test:
go test $(MODULE)/...
COVERAGE_FILE := coverage.out
test: build
go test -v -coverprofile=$(COVERAGE_FILE) $(MODULE)/...
coverage: test
cat $(COVERAGE_FILE) | grep -v "_mock.go" > $(COVERAGE_FILE).no-mocks
go tool cover -func=$(COVERAGE_FILE).no-mocks
# Generate an image for containerized builds
# Note: This image is local only