Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Use gotestsum wrapper for go tests #31163

Merged
merged 5 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=a
GOTEST_OPT_WITH_INTEGRATION=$(GOTEST_INTEGRATION_OPT) -tags=integration,$(GO_BUILD_TAGS) -run=Integration
GOTEST_OPT_WITH_INTEGRATION_COVERAGE=$(GOTEST_OPT_WITH_INTEGRATION) -coverprofile=integration-coverage.txt -covermode=atomic
GOCMD?= go
GOTEST=$(GOCMD) test
GOOS=$(shell $(GOCMD) env GOOS)
GOARCH=$(shell $(GOCMD) env GOARCH)

Expand Down Expand Up @@ -72,6 +71,7 @@ GOJUNIT := $(TOOLS_BIN_DIR)/go-junit-report
BUILDER := $(TOOLS_BIN_DIR)/builder
GOVULNCHECK := $(TOOLS_BIN_DIR)/govulncheck
GCI := $(TOOLS_BIN_DIR)/gci
GOTESTSUM := $(TOOLS_BIN_DIR)/gotestsum

# BUILD_TYPE should be one of (dev, release).
BUILD_TYPE?=release
Expand Down Expand Up @@ -120,39 +120,39 @@ all-pkg-dirs:
common: lint test

.PHONY: test
test:
$(GOTEST) $(GOTEST_OPT) ./...
test: $(GOTESTSUM)
$(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT)

.PHONY: test-with-cover
test-with-cover:
test-with-cover: $(GOTESTSUM)
mkdir -p $(PWD)/coverage/unit
$(GOTEST) $(GOTEST_OPT) -cover ./... -covermode=atomic -args -test.gocoverdir="$(PWD)/coverage/unit"
$(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT) -cover -covermode=atomic -args -test.gocoverdir="$(PWD)/coverage/unit"

.PHONY: do-unit-tests-with-cover
do-unit-tests-with-cover:
do-unit-tests-with-cover: $(GOTESTSUM)
@echo "running $(GOCMD) unit test ./... + coverage in `pwd`"
$(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) ./...
$(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT_WITH_COVERAGE)
$(GOCMD) tool cover -html=coverage.txt -o coverage.html

.PHONY: mod-integration-test
mod-integration-test:
mod-integration-test: $(GOTESTSUM)
@echo "running $(GOCMD) integration test ./... in `pwd`"
$(GOTEST) $(GOTEST_OPT_WITH_INTEGRATION) ./...
$(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION)
@if [ -e integration-coverage.txt ]; then \
$(GOCMD) tool cover -html=integration-coverage.txt -o integration-coverage.html; \
fi

.PHONY: do-integration-tests-with-cover
do-integration-tests-with-cover:
do-integration-tests-with-cover: $(GOTESTSUM)
@echo "running $(GOCMD) integration test ./... + coverage in `pwd`"
$(GOTEST) $(GOTEST_OPT_WITH_INTEGRATION_COVERAGE) ./...
$(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION_COVERAGE)
@if [ -e integration-coverage.txt ]; then \
$(GOCMD) tool cover -html=integration-coverage.txt -o integration-coverage.html; \
fi

.PHONY: benchmark
benchmark:
$(GOTEST) -bench=. -run=notests --tags=$(GO_BUILD_TAGS) $(ALL_PKGS)
benchmark: $(GOTESTSUM)
$(GOTESTSUM) --packages="$(ALL_PKGS)" -- -bench=. -run=notests --tags=$(GO_BUILD_TAGS)

.PHONY: addlicense
addlicense: $(ADDLICENSE)
Expand Down
7 changes: 6 additions & 1 deletion internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
go.uber.org/goleak v1.3.0
golang.org/x/tools v0.17.0
golang.org/x/vuln v1.0.3
gotest.tools/gotestsum v1.11.0
)

require (
Expand Down Expand Up @@ -47,6 +48,7 @@ require (
github.com/ashanbrown/forbidigo v1.6.0 // indirect
github.com/ashanbrown/makezero v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bitfield/gotestdox v0.2.1 // indirect
github.com/bkielbasa/cyclop v1.2.1 // indirect
github.com/blizzy78/varnamelen v0.8.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.0.2 // indirect
Expand All @@ -65,6 +67,7 @@ require (
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/denis-tingaikin/go-header v0.4.3 // indirect
github.com/dnephin/pflag v1.0.7 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/esimonov/ifshort v1.0.4 // indirect
github.com/ettle/strcase v0.1.1 // indirect
Expand Down Expand Up @@ -103,6 +106,7 @@ require (
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
github.com/gostaticanalysis/comment v1.4.2 // indirect
Expand Down Expand Up @@ -143,7 +147,7 @@ require (
github.com/maratori/testpackage v1.1.1 // indirect
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mbilski/exhaustivestruct v1.2.0 // indirect
Expand Down Expand Up @@ -228,6 +232,7 @@ require (
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
Expand Down
32 changes: 31 additions & 1 deletion internal/tools/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ import (
_ "go.opentelemetry.io/collector/cmd/builder"
_ "golang.org/x/tools/cmd/goimports"
_ "golang.org/x/vuln/cmd/govulncheck"
_ "gotest.tools/gotestsum"
)
Loading