Skip to content

Commit

Permalink
test: make coverage (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency authored Mar 26, 2024
1 parent 93c13fe commit d85c7ba
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .coverageignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.pb.go
*.pb.gw.go
*.pulsar.go
*_simulation.go
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,21 @@ test-integration:
@echo "--> Running integration tests"
cd integration; go test -v ./...

.PHONY: test test-integration
coverage: ## Run coverage report
@echo "--> Running coverage"
@go test -race -cpu=$$(nproc) -covermode=atomic -coverprofile=coverage.out $$(go list ./...) ./interchaintest/... -coverpkg=github.com/strangelove-ventures/tokenfactory/... > /dev/null 2>&1
@echo "--> Running coverage filter"
@./scripts/filter-coverage.sh
@echo "--> Running coverage report"
@go tool cover -func=coverage-filtered.out
@echo "--> Running coverage html"
@go tool cover -html=coverage-filtered.out -o coverage.html
@echo "--> Coverage report available at coverage.html"
@echo "--> Cleaning up coverage files"
@rm coverage.out
@echo "--> Running coverage complete"

.PHONY: test test-integration coverage

##################
### Protobuf ###
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module github.com/strangelove-ventures/tokenfactory

go 1.21

toolchain go1.21.0

replace (
// core v0.12 was tagged wrong (SDK v51).
cosmossdk.io/core => cosmossdk.io/core v0.11.0
Expand Down
6 changes: 6 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go 1.21

use (
.
./interchaintest
)
290 changes: 290 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion interchaintest/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/strangelove-ventures/tokenfactory/interchaintest

go 1.21.1
go 1.21

replace (
cosmossdk.io/core v0.12.0 => cosmossdk.io/core v0.11.0 // proper SDK v50 version
Expand Down
15 changes: 15 additions & 0 deletions scripts/filter-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

coverage_profile="coverage.out"
filtered_coverage_profile="coverage-filtered.out"
exclusion_file=".coverageignore"

cp "$coverage_profile" "$filtered_coverage_profile"

while read -r pattern; do
files_to_exclude=$(find . -type f -regex ".*$pattern")
for file in $files_to_exclude; do
relative_path=$(realpath --relative-to="." "$file")
grep -v "$relative_path" "$filtered_coverage_profile" > temp_coverage.out && mv temp_coverage.out "$filtered_coverage_profile"
done
done < "$exclusion_file"

0 comments on commit d85c7ba

Please sign in to comment.