From 7cde4ba86741d4df124b5708cebab7fa4e78728f Mon Sep 17 00:00:00 2001 From: pallam Date: Thu, 16 Jul 2026 16:01:49 +0300 Subject: [PATCH] Add gotestsum dependency to Makefile and testing scripts Signed-off-by: pallam --- Makefile | 13 ++++++++++--- hack/run_tests.sh | 5 ++++- hack/utils.sh | 14 +++++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c5ba602..0fec983 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ GOLANGCI_VERSION = 2.7.2 GOFUMPT_VERSION=0.9.2 JQ_VERSION=1.8.1 KIND_VERSION=0.31.0 +GOTESTSUM_VERSION=1.13.0 export TESTS_OPENSSH_IMAGE = lscr.io/linuxserver/openssh-server:10.0_p1-r9-ls209 export TESTS_PYTHON_IMAGE = registry.deckhouse.ru/base_images@sha256:b15f9150f3b51f2e11cd73db39c89eef8a075953659caf802363d4f544335fb5 @@ -58,7 +59,7 @@ else ifeq ($(PLATFORM_NAME), arm64) KIND_ARCH = arm64 endif -.PHONY: bin/jq bin/gofumpt bin/golangci-lint clean validation/license/download curl-installed docker-installed go-installed clean/test clean/ssh clean/docker +.PHONY: bin/jq bin/gofumpt bin/golangci-lint bin/gotestsum clean validation/license/download curl-installed docker-installed go-installed clean/test clean/ssh clean/docker bin: @mkdir -p bin @@ -101,7 +102,13 @@ bin/kind: curl-installed bin chmod +x "./bin/kind"; \ fi -deps: bin bin/jq bin/golangci-lint bin/gofumpt bin/kind +bin/gotestsum: go-installed bin + @if ! ./hack/check_binary.sh "gotestsum" "--version" "$(GOTESTSUM_VERSION)"; then \ + echo "Install gotestsum"; \ + GOBIN=$(abspath bin/) go install gotest.tools/gotestsum@v$(GOTESTSUM_VERSION); \ + fi + +deps: bin bin/jq bin/golangci-lint bin/gofumpt bin/kind bin/gotestsum go-deps/update: go-installed @if [ -z "$(DEP)" ] ; then \ @@ -136,7 +143,7 @@ test/pull-ssh-image: docker-installed test/pull-python-image: docker-installed @docker pull $(TESTS_PYTHON_IMAGE) -test: go-installed docker-installed bin/kind test/pull-ssh-image test/pull-python-image +test: go-installed docker-installed bin/kind bin/gotestsum test/pull-ssh-image test/pull-python-image ./hack/run_tests.sh $(MAKE) clean/test diff --git a/hack/run_tests.sh b/hack/run_tests.sh index 781b5f3..8c78a8c 100755 --- a/hack/run_tests.sh +++ b/hack/run_tests.sh @@ -20,6 +20,9 @@ check_all_deps check_go pull_image +# Absolute path: run_tests_in_dir cd's into module dirs (repo root and ./tests). +gotestsum_bin="$(gotestsum_bin_path)" + run_tests="" if [ -n "$RUN_TEST" ]; then @@ -80,7 +83,7 @@ function run_tests_in_dir() { echo "Found packages: ${packages[@]} in ${run_dir} with module ${prefix}" echo "Run tests in ${run_dir} (-p ${package_parallelism} -parallel ${test_parallelism})" - if ! go test -timeout 35m -v -p "$package_parallelism" -parallel "$test_parallelism" $run_tests $packages; then + if ! "$gotestsum_bin" -- -timeout 35m -v -p "$package_parallelism" -parallel "$test_parallelism" $run_tests $packages; then all_failed_tests="$(echo -e "${all_failed_tests}\nTests in ${prefix} failed")" fi } diff --git a/hack/utils.sh b/hack/utils.sh index 6f495b1..d2dd733 100644 --- a/hack/utils.sh +++ b/hack/utils.sh @@ -96,8 +96,20 @@ function check_kind() { fi } +function gotestsum_bin_path() { + echo -n "$(pwd)/bin/gotestsum" +} + +function check_gotestsum() { + local bin_path="$(gotestsum_bin_path)" + if ! [ -x "$bin_path" ]; then + echo "gotestsum not installed! You should run 'make bin/gotestsum' before" + exit 1 + fi +} + function check_all_deps() { - check_docker && check_kind + check_docker && check_kind && check_gotestsum } function pull_image() {