From 15071b164b7ec34c0edb53e7d3108e79820459fc Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Thu, 18 Mar 2021 17:33:09 +0900 Subject: [PATCH] Fix `make cover` task --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 75327d4..fd49bb1 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,20 @@ +PKG := github.com/goccy/go-json + BIN_DIR := $(CURDIR)/bin +PKGS := $(shell go list ./... | grep -v internal/cmd) +COVER_PKGS := $(foreach pkg,$(PKGS),$(subst $(PKG),.,$(pkg))) + +COMMA := , +EMPTY := +SPACE := $(EMPTY) $(EMPTY) +COVERPKG_OPT := $(subst $(SPACE),$(COMMA),$(COVER_PKGS)) $(BIN_DIR): @mkdir -p $(BIN_DIR) .PHONY: cover cover: - @ go test -coverprofile=cover.tmp.out . ; \ - cat cover.tmp.out | grep -v "encode_optype.go" > cover.out; \ - rm cover.tmp.out + go test -coverpkg=$(COVERPKG_OPT) -coverprofile=cover.out . .PHONY: cover-html cover-html: cover