Skip to content

Exclude test and benchmark files from patch coverage - #9992

Merged
glen-84 merged 3 commits into
mainfrom
gai/patch-coverage-exclude-tests
Jun 26, 2026
Merged

glen-84 merged 3 commits into
mainfrom
gai/patch-coverage-exclude-tests

Conversation

@glen-84

@glen-84 glen-84 commented Jun 26, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Patch coverage now excludes test and benchmark sources (any path with a /test/, /tests/, /benchmark/, or /benchmarks/ segment), so both the patch percentage and the project coverage total reflect production code only.
  • Test projects instrument their own code, so changed test files were being counted (often at 0%), skewing the patch percentage, and test assemblies inflated the project-total denominator. Both are now dropped from the table, the JSON, the headline patch %, and the project coverage line, via a single IsProductionPath helper.

Test plan

  • Verified a changed, instrumented test file is excluded from the report output.
  • Confirmed on a real PR: production paths remain; the patch headline is unaffected where test files were already non-instrumented; the project total rises once test assemblies leave the denominator (49.3% → 52.3%).

Copilot AI review requested due to automatic review settings June 26, 2026 15:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the patch coverage GitHub script to exclude test and benchmark sources from patch coverage calculations so the reported percentage reflects production code changes only.

Changes:

  • Skip changed paths that contain /test/, /tests/, /benchmark/, or /benchmarks/ segments when building patch coverage rows.
  • Ensure excluded paths are omitted from the markdown table, JSON payload, and headline totals by filtering them out at row-construction time.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/scripts/patch-coverage.cs Outdated
Comment thread .github/scripts/patch-coverage.cs Outdated
@glen-84
glen-84 merged commit 246bc03 into main Jun 26, 2026
146 checks passed
@glen-84
glen-84 deleted the gai/patch-coverage-exclude-tests branch June 26, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants