Skip to content

Commit

Permalink
Exclude mock files from test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Lai-YT committed Mar 29, 2024
1 parent 5cb7091 commit a38f776
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ PACKAGES ?= $(shell $(GO) list ./...)
GOFILES := $(shell find . -name "*.go")
TESTTAGS ?= "-test.shuffle=on"
COVERPROFILE ?= coverage.out
COVEREXCLUDE ?= "mock"

.PHONY: test
test:
$(GO) test $(TESTTAGS) -v $(PACKAGES)

# TODO: Exclude mock files from coverage.
.PHONY: test-coverage
test-coverage:
$(GO) test $(TESTTAGS) -v $(PACKAGES) -coverprofile=$(COVERPROFILE)
$(GO) test $(TESTTAGS) -v $(PACKAGES) -coverprofile=/tmp/$(COVERPROFILE)
cat /tmp/$(COVERPROFILE) | grep -v -E $(COVEREXCLUDE) > $(COVERPROFILE)
$(GO) tool cover -func=$(COVERPROFILE)

.PHONY: fmt
Expand Down

0 comments on commit a38f776

Please sign in to comment.