From b442e92e90981a048d60b50d0accb0a7d003f7c1 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw)" <3293172751nss@gmail.com> Date: Tue, 16 May 2023 13:17:29 +0800 Subject: [PATCH] fix: golang mk Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --- script/make-rules/golang.mk | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/script/make-rules/golang.mk b/script/make-rules/golang.mk index 517c60b23..5e3845451 100644 --- a/script/make-rules/golang.mk +++ b/script/make-rules/golang.mk @@ -127,31 +127,28 @@ go.lint: tools.verify.golangci-lint @echo "===========> Run golangci to lint source codes" @$(TOOLS_DIR)/golangci-lint run -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/... -# # @$(GO) test $(GO_BUILD_FLAGS) ./... -# ## go.test: Run unit test -# .PHONY: go.test -# go.test: tools.verify.go-junit-report -# @echo "===========> Run unit test" -# @set -o pipefail;$(GO) test -race -cover -coverprofile=$(OUTPUT_DIR)/coverage.out \ -# -timeout=10m -shuffle=on -short -v `go list ./...|\ -# egrep -v $(subst $(SPACE),'|',$(sort $(EXCLUDE_TESTS)))` 2>&1 | \ -# tee >(go-junit-report --set-exit-code >$(OUTPUT_DIR)/report.xml) -# @sed -i '/mock_.*.go/d' $(OUTPUT_DIR)/coverage.out # remove mock_.*.go files from test coverage -# @$(GO) tool cover -html=$(OUTPUT_DIR)/coverage.out -o $(OUTPUT_DIR)/coverage.html - ## go.test: Run unit test .PHONY: go.test go.test: @$(GO) test ./... +# ## go.test.junit-report: Run unit test +# .PHONY: go.test.junit-report +# go.test.junit-report: tools.verify.go-junit-report +# @echo "===========> Run unit test > $(TMP_DIR)/report.xml" +# @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 $(GO_BUILD_FLAGS) ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml +# @sed -i '/mock_.*.go/d' $(TMP_DIR)/coverage.out +# @echo "===========> Test coverage of Go code is reported to $(TMP_DIR)/coverage.html by generating HTML" +# @$(GO) tool cover -html=$(TMP_DIR)/coverage.out -o $(TMP_DIR)/coverage.html + ## go.test.junit-report: Run unit test .PHONY: go.test.junit-report go.test.junit-report: tools.verify.go-junit-report - @echo "===========> Run unit test > $(TMP_DIR)/report.xml" - @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 $(GO_BUILD_FLAGS) ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml - @sed -i '/mock_.*.go/d' $(TMP_DIR)/coverage.out - @echo "===========> Test coverage of Go code is reported to $(TMP_DIR)/coverage.html by generating HTML" - @$(GO) tool cover -html=$(TMP_DIR)/coverage.out -o $(TMP_DIR)/coverage.html + @echo "===========> Run unit test > $(OUTPUT_DIR)/report.xml" + @$(GO) test -v -coverprofile=$(OUTPUT_DIR)/coverage.out 2>&1 ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(OUTPUT_DIR)/report.xml + @sed -i '/mock_.*.go/d' $(OUTPUT_DIR)/coverage.out + @echo "===========> Test coverage of Go code is reported to $(OUTPUT_DIR)/coverage.html by generating HTML" + @$(GO) tool cover -html=$(OUTPUT_DIR)/coverage.out -o $(OUTPUT_DIR)/coverage.html ## go.test.cover: Run unit test with coverage .PHONY: go.test.cover