Skip to content

Commit f640ad6

Browse files
author
Alessio Treglia
authored
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
1 parent 46a8e94 commit f640ad6

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

Makefile

+23-17
Original file line numberDiff line numberDiff line change
@@ -204,24 +204,30 @@ sync-docs:
204204
test: test-unit
205205
test-all: test-unit test-ledger-mock test-race test-cover
206206

207-
test-ledger-mock:
208-
@go test -mod=readonly `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger test_ledger_mock'
209-
210-
test-ledger: test-ledger-mock
211-
@go test -mod=readonly -v `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger'
212-
213-
test-unit: test-unit-proto
214-
215-
test-unit-proto:
216-
@VERSION=$(VERSION) go test -mod=readonly ./... -tags='ledger test_ledger_mock'
217-
218-
test-unit-amino:
219-
@VERSION=$(VERSION) go test -mod=readonly ./... -tags='ledger test_ledger_mock test_amino'
220-
221-
test-race:
222-
@VERSION=$(VERSION) go test -mod=readonly -race $(PACKAGES_NOSIMULATION)
207+
TEST_PACKAGES=./...
208+
TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-race test-ledger test-race
209+
210+
# Test runs-specific rules. To add a new test target, just add
211+
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
212+
# append the new rule to the TEST_TARGETS list.
213+
214+
test-unit: ARGS=-tags='cgo ledger test_ledger_mock'
215+
test-unit-amino: ARGS=-tags='ledger test_ledger_mock test_amino'
216+
test-ledger: ARGS=-tags='cgo ledger'
217+
test-ledger-mock: ARGS=-tags='ledger test_ledger_mock'
218+
test-race: ARGS=-race -tags='cgo ledger test_ledger_mock'
219+
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
220+
221+
$(TEST_TARGETS): run-tests
222+
223+
run-tests:
224+
ifneq (,$(shell which tparse 2>/dev/null))
225+
go test -mod=readonly -json $(ARGS) $(TEST_PACKAGES) | tparse
226+
else
227+
go test -mod=readonly $(ARGS) $(TEST_PACKAGES)
228+
endif
223229

224-
.PHONY: test test-all test-ledger-mock test-ledger test-unit test-race
230+
.PHONY: run-tests test test-all $(TEST_TARGETS)
225231

226232
test-sim-nondeterminism:
227233
@echo "Running non-determinism test..."

0 commit comments

Comments
 (0)