Skip to content

Commit

Permalink
test: run tests of all go.mods
Browse files Browse the repository at this point in the history
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
  • Loading branch information
DimitrisJim and Carlos Rodriguez committed Sep 21, 2023
1 parent bef00ef commit 347c671
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 3 deletions.
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-
# 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: ARGS=-tags='cgo ledger test_ledger_mock'
test-unit: ARGS=-tags='cgo ledger test_ledger_mock test_e2e'
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'
Expand All @@ -192,11 +192,32 @@ check-test-unit-amino: ARGS=-tags='ledger test_ledger_mock test_amino'
$(CHECK_TEST_TARGETS): EXTRA_ARGS=-run=none
$(CHECK_TEST_TARGETS): run-tests

ARGS += -tags "$(test_tags)"
SUB_MODULES = $(shell find . -type f -name 'go.mod' -print0 | xargs -0 -n1 dirname | sort)
CURRENT_DIR = $(shell pwd)
run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
go test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
@echo "Starting unit tests"; \
finalec=0; \
for module in $(SUB_MODULES); do \
cd ${CURRENT_DIR}/$$module; \
echo "Running unit tests for $$(grep '^module' go.mod)"; \
go test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) ./... | tparse; \
ec=$$?; \
if [ "$$ec" -ne '0' ]; then finalec=$$ec; fi; \
done; \
exit $$finalec
else
go test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
@echo "Starting unit tests"; \
finalec=0; \
for module in $(SUB_MODULES); do \
cd ${CURRENT_DIR}/$$module; \
echo "Running unit tests for $$(grep '^module' go.mod)"; \
go test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) ./... ; \
ec=$$?; \
if [ "$$ec" -ne '0' ]; then finalec=$$ec; fi; \
done; \
exit $$finalec
endif

.PHONY: run-tests test test-all $(TEST_TARGETS)
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/core/02-client/client_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package client

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/core/03-connection/connection_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package connection

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/interchain_accounts/base_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package interchainaccounts

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/interchain_accounts/gov_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package interchainaccounts

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/interchain_accounts/groups_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package interchainaccounts

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/interchain_accounts/incentivized_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package interchainaccounts

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/interchain_accounts/localhost_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package interchainaccounts

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/interchain_accounts/params_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package interchainaccounts

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/transfer/authz_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package transfer

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/transfer/base_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package transfer

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/transfer/incentivized_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package transfer

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/transfer/localhost_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package transfer

import (
Expand Down
3 changes: 3 additions & 0 deletions e2e/tests/upgrades/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !test_e2e
// +build !test_e2e

package upgrades

import (
Expand Down

0 comments on commit 347c671

Please sign in to comment.