From e85f97dd328db770174ec84a4350ba5d7fe4d7fe Mon Sep 17 00:00:00 2001 From: Pierre Durand Date: Mon, 5 Aug 2024 13:38:39 +0200 Subject: [PATCH] copy common files (Makefile: add options to control test fullpath and coverage) --- Makefile-common.mk | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile-common.mk b/Makefile-common.mk index 98d11a2..c462313 100644 --- a/Makefile-common.mk +++ b/Makefile-common.mk @@ -7,6 +7,8 @@ noop: CI?=false ifeq ($(CI),true) VERBOSE?=true +TEST_FULLPATH?=true +TEST_COVER?=true endif VERBOSE?=false @@ -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::