Skip to content

tests: refactoring #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
**/**.go
go.mod
go.sum
evmd/go.mod
evmd/go.sum
evmd/**/**.go
*.toml
- name: Test and Create Coverage Report
run: |
Expand Down
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ linters:
- staticcheck
path: migrations
text: 'SA1019:'
- linters:
- staticcheck
path: ^tests/integration/
- linters:
- stylecheck
text: 'ST1001:'
paths:
- x/vm/core
- third_party$
Expand Down
47 changes: 30 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,39 +101,52 @@ vulncheck:
### Tests & Simulation ###
###############################################################################

test: test-unit
test-all: test-unit test-race
PACKAGES_UNIT := $(shell go list ./... | grep -v '/tests/e2e$$' | grep -v '/simulation')
PACKAGES_EVMD := $(shell cd evmd && go list ./... | grep -v '/simulation')
COVERPKG_EVM := $(shell go list ./... | grep -v '/tests/e2e$$' | grep -v '/simulation' | paste -sd, -)
COVERPKG_ALL := $(COVERPKG_EVM)
COMMON_COVER_ARGS := -timeout=15m -covermode=atomic

# For unit tests we don't want to execute the upgrade tests in tests/e2e but
# we want to include all unit tests in the subfolders (tests/e2e/*)
PACKAGES_UNIT=$(shell go list ./... | grep -v '/tests/e2e$$')
TEST_PACKAGES=./...
TEST_TARGETS := test-unit test-unit-cover test-race
TEST_PACKAGES := ./...
TEST_TARGETS := test-unit test-evmd test-unit-cover test-race

# 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=-timeout=15m
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)
test-unit: run-tests

test-race: ARGS=-race
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
$(TEST_TARGETS): run-tests
test-race: TEST_PACKAGES=$(PACKAGES_UNIT)
test-race: run-tests

test-evmd: ARGS=-timeout=15m
test-evmd:
@cd evmd && go test -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(PACKAGES_EVMD)

test-unit-cover: ARGS=-timeout=15m -coverprofile=coverage.txt -covermode=atomic
test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)
test-unit-cover:
@echo "Filtering ignored files from coverage.txt..."
@grep -v -E '/cmd/|/client/|/proto/|/testutil/|/mocks/|/test_.*\.go:|\.pb\.go:|\.pb\.gw\.go:|/x/[^/]+/module\.go:|/scripts/|/ibc/testing/|/version/|\.md:|\.pulsar\.go:' coverage.txt > tmp_coverage.txt && mv tmp_coverage.txt coverage.txt
@echo "Function-level coverage summary:"
test-unit-cover: run-tests
@echo "🔍 Running evm (root) coverage..."
@go test -tags=test $(COMMON_COVER_ARGS) -coverpkg=$(COVERPKG_ALL) -coverprofile=coverage.txt ./...
@echo "🔍 Running evmd coverage..."
@cd evmd && go test -tags=test $(COMMON_COVER_ARGS) -coverpkg=$(COVERPKG_ALL) -coverprofile=coverage_evmd.txt ./...
@echo "🔀 Merging evmd coverage into root coverage..."
@tail -n +2 evmd/coverage_evmd.txt >> coverage.txt && rm evmd/coverage_evmd.txt
@echo "📊 Coverage summary:"
@go tool cover -func=coverage.txt

test: test-unit

test-all:
@echo "🔍 Running evm module tests..."
@go test -tags=test -mod=readonly -timeout=15m $(PACKAGES_NOSIMULATION)
@echo "🔍 Running evmd module tests..."
@cd evmd && go test -tags=test -mod=readonly -timeout=15m $(PACKAGES_EVMD)

run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
go test -tags=test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
else
go test -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
go test -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
endif

# Use the old Apple linker to workaround broken xcode - https://github.com/golang/go/issues/65169
Expand Down
Loading
Loading