Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ mytestnet

# Testing
coverage.txt
coverage*out
coverage*html
profile.out
xion-data

Expand Down
37 changes: 37 additions & 0 deletions scripts/test-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Script to run tests with coverage, excluding generated protobuf files

echo "Running tests with coverage (excluding .pb.go files)..."

# Run tests with coverage
go test ./x/... -coverprofile=coverage.out

# Filter out .pb.go and .pb.gw.go files from coverage report
grep -v "\.pb\.go:" coverage.out | grep -v "\.pb\.gw\.go:" > coverage_filtered.out

# Show coverage report without .pb.go files
echo "Coverage report (excluding generated files):"
go tool cover -func=coverage_filtered.out

# Generate HTML report without .pb.go files
go tool cover -html=coverage_filtered.out -o coverage.html

echo "HTML coverage report generated: coverage.html"
echo "Filtered coverage file: coverage_filtered.out"

# Show summary statistics
echo ""
echo "=== COVERAGE SUMMARY ==="
total_coverage=$(go tool cover -func=coverage_filtered.out | tail -1 | awk '{print $3}')
echo "Overall Coverage: $total_coverage"

# Show modules with 0% coverage
echo ""
echo "=== NO COVERAGE (0%) ==="
go tool cover -func=coverage_filtered.out | grep -E "[^0-9]0.0%"

# Show modules with low coverage (less than 80%)
echo ""
echo "=== LOW COVERAGE (<80%) ==="
go tool cover -func=coverage_filtered.out | grep -v -E "[^0-9]0.0%" | awk '$3 ~ /^[0-7][0-9]\.[0-9]%$/ || $3 ~ /^[0-9]\.[0-9]%$/'
Loading