Skip to content

Apply SimpleCov line_stub merge patch on affected CRuby 3.4.x versions too - #1349

Merged
ellisandrews-toast merged 1 commit into
mainfrom
fix-simplecov-line-attribution
Aug 14, 2026
Merged

Apply SimpleCov line_stub merge patch on affected CRuby 3.4.x versions too#1349
ellisandrews-toast merged 1 commit into
mainfrom
fix-simplecov-line-attribution

Conversation

@ellisandrews-toast

Copy link
Copy Markdown
Collaborator

Why

script/quick_build deterministically fails on CRuby 3.4.4 with ~72 phantom "uncovered" lines (all continuation lines of multi-line hash literals), while CI stays green. This is the same Coverage.line_stub bug that #1334 patched, but that patch's version gate ("4.0.0"..."4.0.4") excludes the 3.4 series.

The bisect fixture in #1334 missed the 3.4 variant because it lacked a # frozen_string_literal: true magic comment. With the magic comment (present in every file in this repo), CRuby folds all-static multi-line hash literals at compile time, so their continuation lines fire no runtime line events (nil) — yet Coverage.line_stub (used by SimpleCov 1.x to backfill tracked-but-unloaded files, e.g. from the flatware main process, which runs no tests) still marks them relevant (0). SimpleCov 1.x's merge lets the phantom 0 beat the real nil.

The raw .resultset.json from a failing run shows the mechanism directly: the one worker that actually ran meta_schema_validator_spec.rb recorded line 17 as nil (not relevant), while the flatware main process and the other three workers all stubbed it as 0 (relevant-but-uncovered). Merged: 0 — reported as a miss for a line that cannot be executed.

Re-probing with a Coverage.line_stub-vs-runtime script against docker ruby-slim images, using a fixture with the magic comment: 3.4.1 through 4.0.3 are all affected. 3.4.0 and 4.0.4 are clean, and no 3.4.x release has the fix backported as of 3.4.7. (On 4.0.0–4.0.3 the folding happens even without the magic comment, which is why #1334 caught that range.)

What

Widens the existing patch's version gate in enable_simplecov.rb to Gem::Version.new("3.4.1")...Gem::Version.new("4.0.4"), and updates the comment to document the affected range, the probe method, and the magic-comment variant.

Using Gem::Version also fixes a latent issue with the previous gate's lexicographic string comparison (e.g. "4.0.10" < "4.0.4" as strings).

The merge patch itself is unchanged, and remains harmless anywhere it applies unnecessarily: it only converts nil-vs-0 merges to nil, which never hides a genuinely uncovered line — a real uncovered line is 0 on every side, and 0-vs-0 still merges to 0.

Verification

COVERAGE=1 script/run_specs (what script/quick_build runs) on this branch: 5223 examples, 0 failures, 100.00% line and branch coverage (45057/45057 lines, 3152/3152 branches in 760 files). The same run on unpatched main reports 72 phantom uncovered lines and exits non-zero.

@ellisandrews-toast
ellisandrews-toast enabled auto-merge (squash) August 14, 2026 14:54
@ellisandrews-toast
ellisandrews-toast merged commit 3f1a97c into main Aug 14, 2026
22 checks passed
@ellisandrews-toast
ellisandrews-toast deleted the fix-simplecov-line-attribution branch August 14, 2026 15:04
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.

2 participants