diff --git a/Makefile b/Makefile index 28a9a62c8d8..2afd99c0734 100644 --- a/Makefile +++ b/Makefile @@ -144,7 +144,7 @@ install-tools: #### Static checks #### -check: install-tools static tidy check-plugin errdoc check-testing-t +check: install-tools static tidy generate-errdoc check-plugin check-test static: install-tools @ echo "gofmt ..." @@ -160,21 +160,22 @@ tidy: @ go mod tidy git diff go.mod go.sum | cat git diff --quiet go.mod go.sum - + @ for mod in $(SUBMODULES); do cd $$mod && $(MAKE) tidy && cd - > /dev/null; done +generate-errdoc: install-tools + @echo "generating errors.toml..." + ./scripts/generate-errdoc.sh + check-plugin: - @echo "checking plugin" + @echo "checking plugin..." cd ./plugin/scheduler_example && $(MAKE) evictLeaderPlugin.so && rm evictLeaderPlugin.so -errdoc: install-tools - @echo "generator errors.toml" - ./scripts/check-errdoc.sh - -check-testing-t: - ./scripts/check-testing-t.sh +check-test: + @echo "checking test..." + ./scripts/check-test.sh -.PHONY: check static tidy check-plugin errdoc docker-build-test check-testing-t +.PHONY: check static tidy generate-errdoc check-plugin check-test #### Test utils #### diff --git a/scripts/check-testing-t.sh b/scripts/check-test.sh similarity index 55% rename from scripts/check-testing-t.sh rename to scripts/check-test.sh index 6d107b5a0d1..c8c5b72c0fe 100755 --- a/scripts/check-testing-t.sh +++ b/scripts/check-test.sh @@ -23,4 +23,22 @@ if [ "$res" ]; then exit 1 fi +# Check if there is any inefficient assert function usage in package. + +res=$(grep -rn --include=\*_test.go -E "(re|suite|require)\.(True|False)\((t, )?reflect\.DeepEqual\(" . | sort -u) \ + +if [ "$res" ]; then + echo "following packages use the inefficient assert function: please replace reflect.DeepEqual with require.Equal" + echo "$res" + exit 1 +fi + +res=$(grep -rn --include=\*_test.go -E "(re|suite|require)\.(True|False)\((t, )?strings\.Contains\(" . | sort -u) + +if [ "$res" ]; then + echo "following packages use the inefficient assert function: please replace strings.Contains with require.Contains" + echo "$res" + exit 1 +fi + exit 0 diff --git a/scripts/check-errdoc.sh b/scripts/generate-errdoc.sh similarity index 100% rename from scripts/check-errdoc.sh rename to scripts/generate-errdoc.sh