From 7623a844ba470ac63f1b5dce48bb160f35f5e2e1 Mon Sep 17 00:00:00 2001 From: Aaron Godin Date: Mon, 26 Aug 2024 08:32:42 -0500 Subject: [PATCH] Add test-go-unit-pretty (#91645) Add make task for executing go test over a set of files and piping to tparse --- Makefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Makefile b/Makefile index 27834bf0db8..1f45d7385aa 100644 --- a/Makefile +++ b/Makefile @@ -239,6 +239,14 @@ test-go-unit: ## Run unit tests for backend with flags. printf '$(GO_TEST_FILES)' | xargs \ $(GO) test $(GO_RACE_FLAG) -short -covermode=atomic -timeout=30m +.PHONY: test-go-unit-pretty +test-go-unit-pretty: check-tparse + @if [ -z "$(FILES)" ]; then \ + echo "Notice: FILES variable is not set. Try \"make test-go-unit-pretty FILES=./pkg/services/mysvc\""; \ + exit 1; \ + fi + $(GO) test $(GO_RACE_FLAG) -timeout=10s $(FILES) -json | tparse -all + .PHONY: test-go-integration test-go-integration: ## Run integration tests for backend with flags. @echo "test backend integration tests" @@ -431,6 +439,12 @@ go-race-is-enabled: enable-go-race: @touch .go-race-enabled-locally +check-tparse: + @command -v tparse >/dev/null 2>&1 || { \ + echo >&2 "Error: tparse is not installed. Refer to https://github.com/mfridman/tparse"; \ + exit 1; \ + } + .PHONY: help help: ## Display this help. @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)