Skip to content

Commit

Permalink
copy common files (Makefile: add options to control test fullpath and…
Browse files Browse the repository at this point in the history
… coverage)
  • Loading branch information
pierrre committed Aug 5, 2024
1 parent 53d8254 commit e85f97d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Makefile-common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ noop:
CI?=false
ifeq ($(CI),true)
VERBOSE?=true
TEST_FULLPATH?=true
TEST_COVER?=true
endif

VERBOSE?=false
Expand All @@ -31,14 +33,28 @@ ifneq ($(wildcard ./cmd/*),)
go build $(VERBOSE_FLAG) -ldflags="-s -w -X main.version=$(VERSION)" -o $(GO_BUILD_DIR) ./cmd/...
endif

TEST_FULLPATH?=false
ifeq ($(TEST_FULLPATH),true)
TEST_FULLPATH_FLAG=-fullpath
else
TEST_FULLPATH_FLAG=
endif
TEST_COVER?=false
ifeq ($(TEST_COVER),true)
TEST_COVER_FLAGS=-cover -coverprofile=coverage.out
else
TEST_COVER_FLAGS=
endif
.PHONY: test
test:
go test $(VERBOSE_FLAG) -fullpath -cover -coverprofile=coverage.out ./...
go test $(VERBOSE_FLAG) $(TEST_FULLPATH_FLAG) $(TEST_COVER_FLAGS) ./...
ifeq ($(TEST_COVER),true)
go tool cover -func=coverage.out -o=coverage.txt
ifeq ($(VERBOSE),true)
cat coverage.txt
endif
go tool cover -html=coverage.out -o=coverage.html
endif

.PHONY: generate
generate::
Expand Down

0 comments on commit e85f97d

Please sign in to comment.