From 56387407c33f8aadc35b93d8c4e7b17b1b90a19e Mon Sep 17 00:00:00 2001 From: Adrian Villin Date: Tue, 11 Jun 2024 10:32:08 +0200 Subject: hs-test: added go style targets - added checkstyle-go and fixstyle-go - comments in stats_fs.go were missing a space Type: make Change-Id: I520acab5ff61eaf9d0ccfd9425bdc41f74559198 Signed-off-by: Adrian Villin --- extras/hs-test/Makefile | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'extras/hs-test') diff --git a/extras/hs-test/Makefile b/extras/hs-test/Makefile index d459d9d916c..118afefa543 100644 --- a/extras/hs-test/Makefile +++ b/extras/hs-test/Makefile @@ -1,5 +1,10 @@ export HS_ROOT=$(CURDIR) +# sets WS_ROOT if called from extras/hs-test +ifeq ($(WS_ROOT),) +export WS_ROOT=$(HS_ROOT)/../.. +endif + ifeq ($(VERBOSE),) VERBOSE=false endif @@ -60,7 +65,8 @@ help: @echo " build-cov - coverage build of VPP and Docker images" @echo " build-debug - build test infra (vpp debug image)" @echo " build-go - just build golang files" - @echo " fixstyle - format .go source files" + @echo " checkstyle-go - check style of .go source files" + @echo " fixstyle-go - format .go source files" @echo " list-tests - list all tests" @echo @echo "make build arguments:" @@ -171,7 +177,26 @@ install-deps: fi @touch .deps.ok -.PHONY: fixstyle -fixstyle: - @gofmt -w . +.PHONY: checkstyle-go +checkstyle-go: + @output=$$(gofmt -d $${WS_ROOT}); \ + if [ -z "$$output" ]; then \ + echo "*******************************************************************"; \ + echo "Checkstyle OK."; \ + echo "*******************************************************************"; \ + else \ + echo "$$output"; \ + echo "*******************************************************************"; \ + echo "Checkstyle failed. Use 'make fixstyle-go' or fix errors manually."; \ + echo "*******************************************************************"; \ + exit 1; \ + fi + +.PHONY: fixstyle-go +fixstyle-go: + @echo "Modified files:" + @gofmt -w -l $(WS_ROOT) @go mod tidy + @echo "*******************************************************************" + @echo "Fixstyle done." + @echo "*******************************************************************" -- cgit 1.2.3-korg