Record branch coverage from the minitest runs too - #417
Conversation
The six spawned minitest runs were contributing line coverage and no branch coverage at all: 0 of the 27 library files they load carried branch data. SimpleCov.at_fork's lambda calls SimpleCov.start itself, and once Coverage is running its mode is fixed, so the `enable_coverage :branch` in the start block below it arrived too late. The rspec runs were unaffected because they go through scripts/rspec_with_simplecov, which starts SimpleCov with branches on before .simplecov_spawn is loaded. Configuring before at_fork fixes it: 23 of 27 files now carry branch data, the rest having no branches at all. That makes 10 more branches visible. Most were already covered, and it also surfaced two in minitest_hooks that nothing exercised, so a minitest run now covers them: it resolves `path` from a proc, and it appends a record the schema builder cannot handle so the after_run reporter has something to report. The rspec side already had the equivalent. branches measured 446 -> 456 branches covered 426 -> 437 partials 20 -> 19
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe change moves SimpleCov branch coverage configuration before fork initialization. It adds Rails/Minitest coverage for recorder hook errors caused by an unbuildable response body. ChangesCoverage and hook error validation
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #417 +/- ##
==========================================
+ Coverage 98.23% 98.32% +0.09%
==========================================
Files 27 27
Lines 1076 1076
Branches 209 214 +5
==========================================
+ Hits 1057 1058 +1
+ Partials 19 18 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Tick the box to add this pull request to the merge queue (same as
|
Answering "are we even running minitest?" — yes, six spawned runs (three Rails, three Roda). But they were contributing line coverage and no branch coverage at all: 0 of the 27 library files they load carried branch data.
Cause
.simplecov_spawn.rbasked for branch coverage inside theSimpleCov.startblock, which sits belowSimpleCov.at_fork.call. That lambda callsSimpleCov.startitself, and onceCoverageis running its mode is fixed, so the request arrived too late.The rspec runs were unaffected: they go through
scripts/rspec_with_simplecov, which starts SimpleCov with branches on before.simplecov_spawnis loaded. Only the runs spawned as plainruby -r./.simplecov_spawn— the minitest ones — hit it.Configuring before
at_forkfixes it. 23 of 27 files now carry branch data; the other 4 have no branches at all.Effect
Ten branches became visible. Most were already exercised — including the
require 'rspec/openapi/minitest_hooks'that was being reported as never taken while minitest was plainly running through it, which is what makes this worth fixing beyond the number.It also surfaced two branches in
minitest_hooks.rbthat nothing exercised, so a minitest run now covers them: it resolvespathfrom a proc, and it appends a record the schema builder cannot handle so theafter_runreporter has something to report. The rspec side already had the equivalent inrspec_hook_error_spec.Note the headline percentage barely moves, because the denominator grew along with the numerator. The point is that the measurement is now honest about a sixth of the suite.
Verified
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests