Add post-suite hooks for SimpleCov integration#28
Open
cb341 wants to merge 2 commits intomarkiz:masterfrom
Open
Add post-suite hooks for SimpleCov integration#28cb341 wants to merge 2 commits intomarkiz:masterfrom
cb341 wants to merge 2 commits intomarkiz:masterfrom
Conversation
Introduces a class-level hook registry that enables callbacks to run in the parent process after all workers complete but before printing summary and exiting. This allows libraries like SimpleCov to aggregate results from forked workers without requiring manual invocation outside of spec_helper configuration. New API: - RSpec::Conductor.register_post_suite_hook(&block) Hooks are called after suite_run.suite_complete, enabling access to merged worker results before final exit code determination. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
If SimpleCov is loaded, automatically register the result merging hook in the parent process. No configuration needed in applications. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was authored by Claude Haiku and Opus (Anthropic).
Problem
SimpleCov doesn't support rspec-conductor. When tests run across forked workers, each process writes its own coverage data, but there's no mechanism to merge results in the parent process after workers exit.
SimpleCov handles this for
parallel_teststhrough explicit integration:CommandGuesser.from_envdetectsPARALLEL_TEST_GROUPS/TEST_ENV_NUMBERto assign unique command names per workerfinal_result_process?gates reporting to run only in the lastParallelTestsprocesswait_for_other_processescallsParallelTests.wait_for_other_processes_to_finishbefore mergingNone of this works for rspec-conductor. Users are forced to manually invoke
ResultMerger.merged_resultandprocess_resultafter rspec-conductor exits, e.g. in CI:Related SimpleCov issues:
minimum_coveragevalidates too early, before all processes finishcommand_name/merge_timeoutsetupSolution
Add a post-suite hook mechanism: callbacks that run in the parent process after all workers complete, before printing the summary.
When
SimpleCovis defined, rspec-conductor automatically registers a hook that callsmerged_resultandprocess_result. No application-side code needed. This mirrors what SimpleCov does internally forparallel_testsviafinal_result_process?+wait_for_other_processes, but driven from the runner side.Changes
Server.post_suite_hooks/Server.register_post_suite_hook: class-level hook registryServer#run: call hooks aftersuite_run.suite_complete, beforeprint_summaryRSpec::Conductor.register_post_suite_hook: public API (delegates toServer)SimpleCovconstant is defined (parent process only)