diff --git a/README.md b/README.md index 75a48ed..989a156 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ test: go::test go::docs-check bats::test | `unit` | Run unit tests | | `unit-int` | Run integration tests (requires running service) | | `unit-cov` | Run tests with coverage | +| `unit-cov-gaps` | Coverage gaps only with HTML heatmap | | `unit-cov-map` | Coverage with HTML heatmap | | `test` | Run all checks (mod, fmt, vet, coverage) | | `fmt` | Auto-format with gofumpt + golines | diff --git a/go.just b/go.just index 547722a..d7761c1 100644 --- a/go.just +++ b/go.just @@ -101,6 +101,16 @@ unit-cov: _cov-deps go tool github.com/boumenot/gocover-cobertura < {{ coverage_dir }}/cover.out > {{ coverage_dir }}/cobertura.xml go tool cover -func={{ coverage_dir }}/cover.out +# Show files without 100% coverage and open heatmap of only those files +[group('test')] +unit-cov-gaps: unit-cov + #!/usr/bin/env bash + set -euo pipefail + gap_files=$(go tool cover -func={{ coverage_dir }}/cover.out | grep -v '100.0%' | grep -v '^total:' | awk -F: '{print $1}' | sort -u) + if [ -z "$gap_files" ]; then echo "No coverage gaps found."; exit 0; fi + { head -1 {{ coverage_dir }}/cover.out; grep -F -f <(echo "$gap_files") {{ coverage_dir }}/cover.out; } > {{ coverage_dir }}/gaps.out + go tool cover -html={{ coverage_dir }}/gaps.out + # Generate coverage and show heatmap [group('test')] unit-cov-map: unit-cov