Skip to content

Commit

Permalink
Makefile: plug in gotestsum for better test output (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkowalski committed Sep 30, 2020
1 parent 2b6d3d7 commit a01bfde
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
17 changes: 9 additions & 8 deletions Makefile
@@ -1,5 +1,4 @@
COVERAGE_PACKAGES=github.com/kopia/kopia/repo/...,github.com/kopia/kopia/fs/...,github.com/kopia/kopia/snapshot/...
GO_TEST=go test
TEST_FLAGS?=
KOPIA_INTEGRATION_EXE=$(CURDIR)/dist/integration/kopia.exe
FIO_DOCKER_TAG=ljishen/fio
Expand All @@ -16,6 +15,8 @@ endif

include tools/tools.mk

GO_TEST=$(gotestsum) --format=pkgname-and-test-fails --

LINTER_DEADLINE=300s
UNIT_TESTS_TIMEOUT=300s

Expand Down Expand Up @@ -60,7 +61,7 @@ vet-time-inject:
ifneq ($(TRAVIS_OS_NAME),windows)
! find . -name '*.go' \
-exec grep -n -e time.Now -e time.Since -e time.Until {} + \
| grep -v -e allow:no-inject-time
grep -v src/golang.org | grep -v -e allow:no-inject-time
endif

vet: vet-time-inject
Expand Down Expand Up @@ -186,28 +187,28 @@ test-with-coverage:
test-with-coverage-pkgonly:
$(GO_TEST) -count=1 -coverprofile=tmp.cov -timeout 300s github.com/kopia/kopia/...

test:
test: $(gotestsum)
$(GO_TEST) -count=1 -timeout $(UNIT_TESTS_TIMEOUT) ./...

vtest:
vtest: $(gotestsum)
$(GO_TEST) -count=1 -short -v -timeout $(UNIT_TESTS_TIMEOUT) ./...

dist-binary:
go build -o $(KOPIA_INTEGRATION_EXE) -tags testing github.com/kopia/kopia

integration-tests: export KOPIA_EXE ?= $(KOPIA_INTEGRATION_EXE)
integration-tests: dist-binary
integration-tests: dist-binary $(gotestsum)
$(GO_TEST) $(TEST_FLAGS) -count=1 -parallel $(PARALLEL) -timeout 3600s github.com/kopia/kopia/tests/end_to_end_test

endurance-tests: export KOPIA_EXE ?= $(KOPIA_INTEGRATION_EXE)
endurance-tests: dist-binary
endurance-tests: dist-binary $(gotestsum)
$(GO_TEST) $(TEST_FLAGS) -count=1 -parallel $(PARALLEL) -timeout 3600s github.com/kopia/kopia/tests/endurance_test

robustness-tool-tests:
robustness-tool-tests: $(gotestsum)
FIO_DOCKER_IMAGE=$(FIO_DOCKER_TAG) \
$(GO_TEST) $(TEST_FLAGS) -count=1 -timeout 90s github.com/kopia/kopia/tests/tools/...

stress-test:
stress-test: $(gotestsum)
KOPIA_LONG_STRESS_TEST=1 $(GO_TEST) -count=1 -timeout 200s github.com/kopia/kopia/tests/stress_test
$(GO_TEST) -count=1 -timeout 200s github.com/kopia/kopia/tests/repository_stress_test

Expand Down
15 changes: 12 additions & 3 deletions tools/tools.mk
Expand Up @@ -107,13 +107,14 @@ TOOLS_DIR:=$(SELF_DIR)$(slash).tools
GOLANGCI_LINT_VERSION=1.30.0
NODE_VERSION=12.18.3
HUGO_VERSION=0.74.3
GOTESTSUM_VERSION=0.5.3
GORELEASER_VERSION=v0.140.1

# goveralls
GOVERALLS_TOOL=$(TOOLS_DIR)/bin/goveralls

$(GOVERALLS_TOOL):
$(mkdir) $(TOOLS_DIR)
-$(mkdir) $(TOOLS_DIR)
GO111MODULE=off GOPATH=$(TOOLS_DIR) go get github.com/mattn/goveralls

# nodejs / npm
Expand Down Expand Up @@ -187,7 +188,7 @@ hugo=$(hugo_dir)$(slash)hugo$(exe_suffix)

$(hugo):
@echo Downloading Hugo v$(HUGO_VERSION) to $(hugo)
$(mkdir) $(TOOLS_DIR)$(slash)hugo-$(HUGO_VERSION)
-$(mkdir) $(TOOLS_DIR)$(slash)hugo-$(HUGO_VERSION)

ifeq ($(uname),Windows)
curl -LsS -o $(hugo_dir).zip https://github.com/gohugoio/hugo/releases/download/v$(HUGO_VERSION)/hugo_extended_$(HUGO_VERSION)_Windows-64bit.zip
Expand All @@ -202,6 +203,14 @@ endif

endif

gotestsum=$(TOOLS_DIR)/bin/gotestsum

$(gotestsum): export GO111MODULE=off
$(gotestsum): export GOPATH=$(TOOLS_DIR)
$(gotestsum):
-$(mkdir) $(TOOLS_DIR)
go get gotest.tools/gotestsum

# goreleaser
goreleaser_dir=$(TOOLS_DIR)$(slash)goreleaser-$(GORELEASER_VERSION)
goreleaser=$(goreleaser_dir)$(slash)goreleaser$(exe_suffix)
Expand Down Expand Up @@ -264,5 +273,5 @@ else
maybehugo=
endif

all-tools: $(npm) $(goreleaser) $(linter) $(maybehugo) $(go_bindata) windows-signing-tools
all-tools: $(gotestsum) $(npm) $(goreleaser) $(linter) $(maybehugo) $(go_bindata) windows-signing-tools

0 comments on commit a01bfde

Please sign in to comment.