From f640ad6ceabc3551de92459474095003c658aacc Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Mon, 14 Sep 2020 13:00:33 +0100 Subject: [PATCH] Makefile: reorganise test rules (#7290) Adding a new test suite is now as easy as write a oneliner. Format test output with tparse if available: go get github.com/mfridman/tparse Ref #7287 --- Makefile | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 9df0b7647a..cdd8efb19a 100644 --- a/Makefile +++ b/Makefile @@ -204,24 +204,30 @@ sync-docs: test: test-unit test-all: test-unit test-ledger-mock test-race test-cover -test-ledger-mock: - @go test -mod=readonly `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger test_ledger_mock' +TEST_PACKAGES=./... +TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-race test-ledger test-race -test-ledger: test-ledger-mock - @go test -mod=readonly -v `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger' +# Test runs-specific rules. To add a new test target, just add +# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and +# append the new rule to the TEST_TARGETS list. -test-unit: test-unit-proto +test-unit: ARGS=-tags='cgo ledger test_ledger_mock' +test-unit-amino: ARGS=-tags='ledger test_ledger_mock test_amino' +test-ledger: ARGS=-tags='cgo ledger' +test-ledger-mock: ARGS=-tags='ledger test_ledger_mock' +test-race: ARGS=-race -tags='cgo ledger test_ledger_mock' +test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION) -test-unit-proto: - @VERSION=$(VERSION) go test -mod=readonly ./... -tags='ledger test_ledger_mock' +$(TEST_TARGETS): run-tests -test-unit-amino: - @VERSION=$(VERSION) go test -mod=readonly ./... -tags='ledger test_ledger_mock test_amino' +run-tests: +ifneq (,$(shell which tparse 2>/dev/null)) + go test -mod=readonly -json $(ARGS) $(TEST_PACKAGES) | tparse +else + go test -mod=readonly $(ARGS) $(TEST_PACKAGES) +endif -test-race: - @VERSION=$(VERSION) go test -mod=readonly -race $(PACKAGES_NOSIMULATION) - -.PHONY: test test-all test-ledger-mock test-ledger test-unit test-race +.PHONY: run-tests test test-all $(TEST_TARGETS) test-sim-nondeterminism: @echo "Running non-determinism test..."