Skip to content

feat(covgate): add --exclude flag to skip packages from coverage measurement#29

Merged
ben-miru merged 6 commits into
mainfrom
feat/covgate-exclude-flag
May 15, 2026
Merged

feat(covgate): add --exclude flag to skip packages from coverage measurement#29
ben-miru merged 6 commits into
mainfrom
feat/covgate-exclude-flag

Conversation

@ben-miru

Copy link
Copy Markdown
Contributor

Summary

  • Add --exclude flag to miru covgate that takes a comma-separated list of Go list patterns (e.g. ./pkg/b, ./internal/foo/...) and removes the resolved import paths from the coverage measurement set before tests run. Patterns are resolved via go list so they share the same dialect as --packages, wildcards expand correctly, and whitespace around comma-separated entries is tolerated.
  • When exclusion actually removes packages, covgate prints Excluded N package(s) from coverage measurement between the intro line and the results table. No-op patterns (matching zero packages) and unset/empty --exclude produce byte-identical output to today, so existing CI invocations are unaffected.
  • Motivated by the downstream backend/ repo: some packages exercise cloud services (AWS, Cloudflare) in their tests and cannot run locally without cloud credentials. --exclude lets developers skip those packages locally while CI continues to measure everything by omitting the flag.

Test plan

  • TestRun_Exclude_NoExclude — empty Exclude preserves existing output exactly; no "Excluded" notice.
  • TestRun_Exclude_Subset — single pattern removes one package; "Excluded 1 package(s)" notice appears.
  • TestRun_Exclude_NoOpPattern — pattern that resolves to zero packages leaves the list untouched and suppresses the notice.
  • TestRun_Exclude_MultiplePatternsWithWhitespace"./pkg/a, ./pkg/c" (with whitespace) is trimmed correctly and removes both.
  • TestRun_Exclude_AllPackages — excluding everything produces a clean run with no per-package rows and the standard "All packages meet minimum coverage requirement" tail.
  • TestRun_Exclude_GoListErrorgo list failure on an exclude pattern is wrapped with resolve exclude %q: %w and propagated.
  • TestNewCovgateCommand_Flags / TestNewCovgateCommand_FlagDefaults — CLI flag wiring asserts --exclude exists as a string flag with default "".
  • ./scripts/preflight.sh (lint + covgate + surface lint) passes locally.

Plan: plans/completed/20260515-covgate-exclude-flag.md.

Generated with Claude Code

@ben-miru ben-miru merged commit 93c04cd into main May 15, 2026
3 checks passed
@ben-miru ben-miru deleted the feat/covgate-exclude-flag branch May 15, 2026 17:08
ben-miru added a commit that referenced this pull request May 15, 2026
…table (#30)

## Summary

- Render each `--exclude`d package as a `SKIPPED` row in the per-package
coverage table with `---` placeholders for COVERAGE/REQUIRED/TIME,
grouped at the end after measured rows.
- Widen the `STATUS` column from 6 to 7 chars so `SKIPPED` fits without
breaking alignment of existing `PASS`/`FAIL`/`LOOSE` rows.
- Follow-up to #29: the existing `Excluded N package(s)` summary line
told users *how many* packages were excluded but not *which ones*. This
change surfaces them by name. The summary line is preserved and the
pass/fail tally is unaffected — `SKIPPED` rows never flip a successful
run to failure.

## Sample output

```
Checking per-package coverage (default minimum: 80.0%)...

Excluded 1 package(s) from coverage measurement
STATUS    COVERAGE  REQUIRED      TIME  PACKAGE
-------   --------  --------  --------  -------
PASS         90.0%     80.0%      0.5s  pkg/a
PASS         85.2%     80.0%      0.4s  pkg/c
SKIPPED        ---       ---       ---  pkg/b

Total time: 0.9s
All packages meet minimum coverage requirement
```

## Test plan

- [ ] `SKIPPED` row renders for each `--exclude`d package
- [ ] `SKIPPED` rows appear after all measured rows in the table
- [ ] `SKIPPED` packages do not count toward the failure tally (run
succeeds when all measured packages pass)
- [ ] All-excluded case: run succeeds with every package as a `SKIPPED`
row
- [ ] Existing `TestRun_Exclude` subtests pass with updated assertions
- [ ] `./scripts/preflight.sh` reports `=== All checks passed ===`

Full design and rationale:
`plans/completed/20260515-covgate-skipped-rows.md`.

[Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant