Skip to content

Commit 024ed5d

Browse files
VanillaSpoonanishasthana
authored andcommitted
add: coverage report generation to test target
1 parent 785d047 commit 024ed5d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ IMG ?= controller:latest
2020
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
2121
ENVTEST_K8S_VERSION = 1.23
2222

23+
GO ?= go
24+
2325
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
2426
ifeq (,$(shell go env GOBIN))
2527
GOBIN=$(shell go env GOPATH)/bin
@@ -74,6 +76,15 @@ vet: ## Run go vet against code.
7476
.PHONY: test
7577
test: manifests generate fmt vet envtest ## Run tests.
7678
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
79+
grep -v -e "_moq.go" cover.out > coverage.out
80+
81+
test/output/coverage/report:
82+
@if [ -f coverage.out ]; then $(GO) tool cover -func=coverage.out; else echo "coverage.out file not found"; fi;
83+
.PHONY: test/output/coverage/report
84+
85+
test/html/coverage/report:
86+
@if [ -f coverage.out ]; then $(GO) tool cover -html=coverage.out; else echo "coverage.out file not found"; fi;
87+
.PHONY: test/html/coverage/report
7788

7889
##@ Build
7990

0 commit comments

Comments
 (0)