Skip to content

Commit 253ac90

Browse files
Copilotyurishkuro
andauthored
Use gotestsum for all test execution (#8256)
Replaces the raw `go test | tee` pipeline and `bash -c "... | COLORIZE"` patterns with [`gotestsum`](https://github.com/gotestyourself/gotestsum) across all test targets for consistent formatting, automatic failure reruns, and cleaner output. ## Changes - **`internal/tools/tools.go`** — pins `gotest.tools/gotestsum v1.13.0` as a tracked tool dependency - **`scripts/makefiles/Tools.mk`** — adds `GOTESTSUM` variable; installs it via `install-test-tools` - **`Makefile`**: - Adds `GOTESTSUM_FLAGS=--format pkgname-and-test-fails --format-icons hivis` shared across targets - `test`: replaces `bash -c "... go test -v ... | COLORIZE"` with `gotestsum` - `cover`: replaces `bash -c "... go test ... | tee"` with `gotestsum --rerun-fails --packages ./...` - Removes `GOTEST`, `GOTEST_QUIET`, `COLORIZE` variables - **`scripts/makefiles/IntegrationTests.mk`** — migrates `all-in-one-integration-test`, `jaeger-v2-storage-integration-test`, `storage-integration-test` to `gotestsum` ## Output format ``` ✅ github.com/jaegertracing/jaeger/internal/metrics (2.28s) ➖ github.com/jaegertracing/jaeger/internal/metrics/benchmark (1.02s) ❌ github.com/jaegertracing/jaeger/internal/metrics/foo (0.8s) --- FAIL: TestFoo (0.00s) DONE 37 tests in 6.1s ``` - `pkgname-and-test-fails`: one line per package; failed test output inlined - `hivis`: high-visibility ✅ / ➖ / ❌ icons - `--rerun-fails`: auto-reruns failing packages (up to 2×) in `cover` - `--packages ./...` required alongside `--rerun-fails` per gotestsum's API <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Signed-off-by: Yuri Shkuro <github@ysh.us> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yurishkuro <3523016+yurishkuro@users.noreply.github.com> Co-authored-by: Yuri Shkuro <github@ysh.us>
1 parent bfc46ac commit 253ac90

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

Makefile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,22 @@ else
6767
SED=sed
6868
endif
6969

70-
GOTEST_QUIET=$(GO) test $(RACE)
71-
GOTEST=$(GOTEST_QUIET) -v
7270
COVEROUT=cover.out
7371
GOFMT=gofmt
7472
FMT_LOG=.fmt.log
7573
IMPORT_LOG=.import.log
76-
COLORIZE ?= | $(SED) 's/PASS/✅ PASS/g' | $(SED) 's/FAIL/❌ FAIL/g' | $(SED) 's/SKIP/🔕 SKIP/g'
74+
GOTESTSUM_FLAGS=--format pkgname-and-test-fails --format-icons hivis
7775

78-
# import other Makefiles after the variables are defined
76+
# Import other Makefiles after the variables are defined.
77+
# The order is important as some Makefiles depend on variables
78+
# defined in this file and other includes.
7979

80+
include scripts/makefiles/Tools.mk
8081
include scripts/makefiles/BuildBinaries.mk
8182
include scripts/makefiles/BuildInfo.mk
8283
include scripts/makefiles/Docker.mk
8384
include scripts/makefiles/IntegrationTests.mk
8485
include scripts/makefiles/Protobuf.mk
85-
include scripts/makefiles/Tools.mk
8686
include scripts/makefiles/Windows.mk
8787

8888

@@ -120,12 +120,12 @@ clean:
120120
bash scripts/build/clean-binaries.sh
121121

122122
.PHONY: test
123-
test:
124-
bash -c "set -e; set -o pipefail; $(GOTEST) -tags=memory_storage_integration ./... $(COLORIZE)"
123+
test: $(GOTESTSUM)
124+
$(GOTESTSUM) $(GOTESTSUM_FLAGS) -- $(RACE) -tags=memory_storage_integration ./...
125125

126126
.PHONY: cover
127-
cover: nocover
128-
bash -c "set -e; set -o pipefail; STORAGE=memory $(GOTEST) -timeout 5m -coverprofile $(COVEROUT) ./... | tee test-results.json"
127+
cover: nocover $(GOTESTSUM)
128+
STORAGE=memory $(GOTESTSUM) $(GOTESTSUM_FLAGS) --rerun-fails --packages ./... -- $(RACE) -timeout 5m -coverprofile $(COVEROUT)
129129
go tool cover -html=cover.out -o cover.html
130130

131131
.PHONY: nocover
@@ -231,7 +231,6 @@ prepare-release:
231231
bash ./scripts/release/prepare.sh $(VERSION)
232232

233233
.PHONY: test-ci
234-
test-ci: GOTEST := $(GOTEST_QUIET)
235234
test-ci: build-examples cover
236235

237236
.PHONY: init-submodules

internal/tools/go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/vektra/mockery/v3 v3.7.0
1010
github.com/wadey/gocovmerge v0.0.0-20160331181800-b5bfa59ec0ad
1111
golang.org/x/vuln v1.1.4
12+
gotest.tools/gotestsum v1.13.0
1213
mvdan.cc/gofumpt v0.9.2
1314
)
1415

@@ -43,6 +44,7 @@ require (
4344
github.com/ashanbrown/makezero/v2 v2.1.0 // indirect
4445
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
4546
github.com/beorn7/perks v1.0.1 // indirect
47+
github.com/bitfield/gotestdox v0.2.2 // indirect
4648
github.com/bkielbasa/cyclop v1.2.3 // indirect
4749
github.com/blizzy78/varnamelen v0.8.0 // indirect
4850
github.com/bombsimon/wsl/v4 v4.7.0 // indirect
@@ -69,6 +71,7 @@ require (
6971
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
7072
github.com/denis-tingaikin/go-header v0.5.0 // indirect
7173
github.com/dlclark/regexp2 v1.11.5 // indirect
74+
github.com/dnephin/pflag v1.0.7 // indirect
7275
github.com/ettle/strcase v0.2.0 // indirect
7376
github.com/fatih/color v1.18.0 // indirect
7477
github.com/fatih/structs v1.1.0 // indirect
@@ -102,6 +105,7 @@ require (
102105
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect
103106
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect
104107
github.com/google/go-cmp v0.7.0 // indirect
108+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
105109
github.com/gordonklaus/ineffassign v0.2.0 // indirect
106110
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
107111
github.com/gostaticanalysis/comment v1.5.0 // indirect

internal/tools/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
104104
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
105105
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
106106
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
107+
github.com/bitfield/gotestdox v0.2.2 h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CDsnE=
108+
github.com/bitfield/gotestdox v0.2.2/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY=
107109
github.com/bkielbasa/cyclop v1.2.3 h1:faIVMIGDIANuGPWH031CZJTi2ymOQBULs9H21HSMa5w=
108110
github.com/bkielbasa/cyclop v1.2.3/go.mod h1:kHTwA9Q0uZqOADdupvcFJQtp/ksSnytRMe8ztxG8Fuo=
109111
github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M=
@@ -170,6 +172,8 @@ github.com/denis-tingaikin/go-header v0.5.0 h1:SRdnP5ZKvcO9KKRP1KJrhFR3RrlGuD+42
170172
github.com/denis-tingaikin/go-header v0.5.0/go.mod h1:mMenU5bWrok6Wl2UsZjy+1okegmwQ3UgWl4V1D8gjlY=
171173
github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
172174
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
175+
github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk=
176+
github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
173177
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
174178
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
175179
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
@@ -323,6 +327,8 @@ github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/v
323327
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
324328
github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=
325329
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
330+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
331+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
326332
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
327333
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
328334
github.com/gordonklaus/ineffassign v0.2.0 h1:Uths4KnmwxNJNzq87fwQQDDnbNb7De00VOk9Nu0TySs=
@@ -1032,6 +1038,10 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
10321038
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
10331039
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
10341040
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1041+
gotest.tools/gotestsum v1.13.0 h1:+Lh454O9mu9AMG1APV4o0y7oDYKyik/3kBOiCqiEpRo=
1042+
gotest.tools/gotestsum v1.13.0/go.mod h1:7f0NS5hFb0dWr4NtcsAsF0y1kzjEFfAil0HiBQJE03Q=
1043+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
1044+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
10351045
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
10361046
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
10371047
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

internal/tools/tools.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ package tools
1111
// This ensures that all systems use the same version of tools in addition to regular dependencies.
1212

1313
import (
14+
_ "gotest.tools/gotestsum"
1415
_ "mvdan.cc/gofumpt"
1516

1617
_ "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"

scripts/makefiles/IntegrationTests.mk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ STORAGE_PKGS = ./internal/storage/integration/...
55
JAEGER_V2_STORAGE_PKGS = ./cmd/jaeger/internal/integration
66

77
.PHONY: all-in-one-integration-test
8-
all-in-one-integration-test:
9-
TEST_MODE=integration $(GOTEST) ./cmd/jaeger/internal/all_in_one_test.go
8+
all-in-one-integration-test: $(GOTESTSUM)
9+
TEST_MODE=integration $(GOTESTSUM) $(GOTESTSUM_FLAGS) -- $(RACE) ./cmd/jaeger/internal/all_in_one_test.go
1010

1111
# A general integration tests for jaeger-v2 storage backends,
1212
# these tests placed at `./cmd/jaeger/internal/integration/*_test.go`.
1313
# The integration tests are filtered by STORAGE env.
1414
.PHONY: jaeger-v2-storage-integration-test
15-
jaeger-v2-storage-integration-test:
15+
jaeger-v2-storage-integration-test: $(GOTESTSUM)
1616
(cd cmd/jaeger/ && go build .)
1717
# Expire tests results for jaeger storage integration tests since the environment
1818
# might have changed even though the code remains the same.
1919
go clean -testcache
20-
bash -c "set -e; set -o pipefail; $(GOTEST) -coverpkg=./... -coverprofile $(COVEROUT) $(JAEGER_V2_STORAGE_PKGS) $(COLORIZE)"
20+
$(GOTESTSUM) $(GOTESTSUM_FLAGS) -- $(RACE) -coverpkg=./... -coverprofile $(COVEROUT) $(JAEGER_V2_STORAGE_PKGS)
2121

2222
.PHONY: storage-integration-test
23-
storage-integration-test:
23+
storage-integration-test: $(GOTESTSUM)
2424
# Expire tests results for storage integration tests since the environment might change
2525
# even though the code remains the same.
2626
go clean -testcache
27-
bash -c "set -e; set -o pipefail; $(GOTEST) -coverpkg=./... -coverprofile $(COVEROUT) $(STORAGE_PKGS) $(COLORIZE)"
27+
$(GOTESTSUM) $(GOTESTSUM_FLAGS) -- $(RACE) -coverpkg=./... -coverprofile $(COVEROUT) $(STORAGE_PKGS)
2828

2929
.PHONY: badger-storage-integration-test
3030
badger-storage-integration-test:

scripts/makefiles/Tools.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ TOOLS_PKG_NAMES := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/tools.g
99
TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(shell echo $(TOOLS_PKG_NAMES) | sed 's|/v[0-9]||g')))
1010

1111
GOFUMPT := $(TOOLS_BIN_DIR)/gofumpt
12+
GOTESTSUM := $(TOOLS_BIN_DIR)/gotestsum
1213
GOVERSIONINFO := $(TOOLS_BIN_DIR)/goversioninfo
1314
GOVULNCHECK := $(TOOLS_BIN_DIR)/govulncheck
1415
LINT := $(TOOLS_BIN_DIR)/golangci-lint
@@ -21,7 +22,7 @@ GOCOVMERGE := $(TOOLS_BIN_DIR)/gocovmerge
2122
install-tools: $(TOOLS_BIN_NAMES)
2223

2324
.PHONY: install-test-tools
24-
install-test-tools: $(LINT) $(GOFUMPT)
25+
install-test-tools: $(LINT) $(GOFUMPT) $(GOTESTSUM)
2526

2627
.PHONY: install-coverage-tools
2728
install-coverage-tools: $(GOCOVMERGE)

0 commit comments

Comments
 (0)