rspec-conductor Support - #1259
Merged
Merged
Conversation
rspec-conductor marks each forked worker with the parallel_tests environment convention, TEST_ENV_NUMBER per worker plus PARALLEL_TEST_GROUPS for the worker count (since rspec-conductor 1.0.7). SimpleCov's generic parallel adapter already recognizes that convention, so coverage from a conductor run merges into one report with unique suite names per worker and no configuration. Lock that support in with a dedicated test project and cucumber feature covering the default numbering (first worker ""), the --first-is-1 numbering, branch coverage, and threshold checks deferred to the merged report. Name rspec-conductor in the adapter docs so users can find it. Resolves #1156.
…ctor features The rspec_conductor test project was a byte-for-byte copy of the parallel_tests one, differing only in which parallel runner its Gemfile pulls in, and its feature repeated the expected coverage tables inline three times. Any change to the fixture sources would have required updating five copies of the tables and ten duplicated files. Slim test_projects/rspec_conductor down to its Gemfile and Gemfile.lock. A new setup step overlays those onto another project's sources, so the conductor feature now runs against the parallel_tests fixture itself. Rename the shared assertion steps to "the parallel fixture project" (and their file to parallel_fixture_steps.rb) since they no longer belong to a single feature, and reuse them in place of the inline tables.
rspec-conductor closes each worker's output pipes as soon as the worker has sent its run summary to the server, before the worker's at_exit hooks run. SimpleCov's exit tasks then died half way: the HTML and JSON report files were already written, but emitting the status line probes Color.enabled?, whose IO#tty? call raises IOError on a closed stream. That exception aborted the rest of the at_exit work, so the minimum and maximum coverage checks silently never ran under rspec-conductor, and .last_run.json and the .report_stamp deferral marker were never written. Treat a closed stream as not a tty in Color.enabled?, and drop the status line in Formatter::Base#emit_status and the violation report in ExitCodes.print_error when stderr is closed, instead of letting the IOError cancel the threshold checks that follow. The conductor feature's threshold scenario previously asserted that no violation appears in the output, which the closed pipes made vacuous: the text could never appear, and the swallowed worker exit status meant the run always succeeded. It now asserts that .last_run.json carries the merged 81.48. SimpleCov writes that file only when the threshold check passes, and every single worker's partial slice is below the threshold, so the file proves the check ran against the merged result.
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.
rspec-conductoralready works with SimpleCov out of the box, so this PR locks that in with end-to-end tests and documentation rather than new runtime code.No runtime change was needed because of two things that happened after #1156 was filed: three days later,
rspec-conductor1.0.7 started exportingPARALLEL_TEST_GROUPSalongside theTEST_ENV_NUMBERit always set per worker. Then the pluggable parallel adapter interface landed withGenericAdapter, which activates on that env-var convention. As a result, a conductor run records each worker under a unique suite name (RSpec (1/2),RSpec (2/2)) and the first worker waits for its siblings and builds the merged report, with zero configuration.This PR adds a
rspec_conductortest project (mirroring theparallel_testsone, withrspec-conductorin its Gemfile) and a cucumber feature with four scenarios: a default 2-worker run matching a plainrspecrun, the--first-is-1numbering mode, branch coverage, and threshold checks deferred until the merged report. The scenarios are tagged@process_forkbecause conductor forks its workers, which JRuby cannot do. They assert on the generated report files instead of the usual "Coverage report generated" output line, because the reporting worker prints that line from itsat_exithook after it has already sent its run summary, and the conductor server does not forward worker output arriving that late. The docs inParallelism.mdand the adapter source comments now namerspec-conductor(1.0.7 or later) among the runners the generic adapter covers, so users searching for it can find the answer. Users on earlier versions still need the manualcommand_nameworkaround, because those versions do not export the worker count.