Skip to content

Update README to address Simplecov intermittently dropping coverage#123

Open
darronschall wants to merge 1 commit into
briandunn:masterfrom
darronschall:update-readme-for-simplecov
Open

Update README to address Simplecov intermittently dropping coverage#123
darronschall wants to merge 1 commit into
briandunn:masterfrom
darronschall:update-readme-for-simplecov

Conversation

@darronschall

@darronschall darronschall commented May 12, 2026

Copy link
Copy Markdown

After first integrating flatware, I've seen 2% drops in coverage in every 1-in-3 full suite runs, with a different worker missing from the final Coverage report generated for ... listing each time.

From what I can tell, flatware rspec returns to its top-level exit the moment the DRb sink has seen every worker report its final result — but a worker's at_exit (where SimpleCov stores its resultset slice to disk) runs after the last DRb report goes over the wire. So the parent's own SimpleCov at_exit (which merges all workers' slices into the final report) can fire before the slowest worker finishes writing.

The solution appears to be adding a Process.waitall barrier inside an at_exit registered from before_fork (after require 'rails_helper' has loaded SimpleCov). LIFO at_exit ordering means the barrier fires before SimpleCov's at_exit, so the merge sees the full set of workers' resultsets. The handler is gated to Process.pid == parent_pid; it no-ops in worker forks.

I'm running this setup in production now and have not seen any coverage drops.

Also, while I had the SimpleCov section open, I added a note for the SimpleCov.minimum_coverage_by_file 0 companion call in the after_fork example, since SimpleCov's default at_fork lambda clears the aggregate minimum_coverage gate but not the per-file one (so workers using the per-file gate kill themselves before their slice can merge).

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