Skip to content

fix(codecov): count only lines every driver reports for files no test loaded - #449

Merged
roxblnfk merged 1 commit into
1.xfrom
fix/codecov-executable-lines-444
Nov 24, 2026
Merged

roxblnfk merged 1 commit into
1.xfrom
fix/codecov-executable-lines-444

Conversation

@roxblnfk

Copy link
Copy Markdown
Member

🔍 What was changed

  • The executable-line estimate for files no test loaded counts only lines that Xdebug, PCOV and turbocov all report once the file is loaded, on every PHP version from 8.2. Missing a line is allowed, counting an extra one is not.
  • A line counts where an operation starts: a call, an assignment, a jump, a one-line condition or ternary branch, a literal argument of a call bound at runtime. Lines holding only operands (glued string literals, if ( openers, format strings, variable arguments) no longer count.
  • Left out as unpredictable: opcodes moved by expression layout, compile-time folding (sprintf rope, constant &&/||, version-dependent if, assert()), unreachable code (after return/throw/goto, exhaustive switch, endless loops, Xdebug's reading of ?? throw), property hook bodies, promoted constructor and generator signatures.
  • UncountedLines asks a separate, permissive question (ExecutableLines::bodyEnds()), so the lower estimate never drops a closing brace the driver reported for a loaded file.

Why?

Codecov merges flags line by line. A line the estimate adds for an unloaded file stays uncovered for good once another suite loads the file and its driver does not report that line. On cycle/database that was 213 of 395 misses.

Review notes

  • Checked against real drivers: PHP 8.2 to 8.6 with PCOV and Xdebug, turbocov on 8.4+, over cycle/* and testo sources plus a held-out set (mockery, symfony/console, psalm, phpunit, amphp, brick/math and others). Zero extra lines in all 13 configurations.
  • The price is under-counting: about 1000 lines on the main corpus count only once a suite loads the file.
  • Per-driver additions (e.g. Xdebug's extra argument lines) are left for a follow-up.

Checklist

@roxblnfk
roxblnfk requested a review from a team as a code owner November 24, 2026 07:27
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@roxblnfk
roxblnfk force-pushed the fix/codecov-executable-lines-444 branch from 16287ec to ab4e586 Compare November 24, 2026 07:42
… loaded

Reports of several suites are merged line by line, so a line the estimate adds for an unloaded file stays uncovered once another suite loads the file and its driver does not report that line. The estimate now marks a line only where an operation starts and the line is the same for Xdebug, PCOV and turbocov on every PHP version from 8.2, leaving out lines whose opcode moves with the layout of an expression, with what is loaded at the time, with the PHP version, or with unreachable code. The last-line check for loaded files gets its own answer on bodies that fall through, so it keeps a closing brace the estimate leaves out. Refs #444.

Assisted-By: Claude Opus 5.5 <[email protected]>
@roxblnfk
roxblnfk force-pushed the fix/codecov-executable-lines-444 branch from ab4e586 to cb24fc2 Compare November 24, 2026 10:54
@roxblnfk
roxblnfk merged commit 5b05dab into 1.x Nov 24, 2026
31 of 33 checks passed
@roxblnfk
roxblnfk deleted the fix/codecov-executable-lines-444 branch November 24, 2026 17:34
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.

codecov: executable-line estimate for unloaded files counts lines pcov never reports

1 participant