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
This commit is contained in:
Alessio Treglia 2020-09-14 13:00:33 +01:00 committed by GitHub
parent 46a8e94740
commit f640ad6cea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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..."