Show the rspec command output when the dry-run fails#27
Merged
Conversation
RunSpecs#example_ids ran the `rspec --dry-run` and, on failure, printed the contents of rspec's `--out` JSON file (the example list) instead of the actual error. The real error goes to the process's stderr, which `execute` streamed but never captured, so the rescue only had the JSON to show — and when the failure happens at exit (after the JSON is already written) that file contains no trace of the error at all. `execute` now optionally captures the command's combined stdout+stderr and attaches it to the raised `Error`; `RunSpecs` runs the dry-run with `capture: true` and fails with that output.
KirIgor
approved these changes
Jul 6, 2026
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.
Problem
RunSpecs#example_idsrunsrspec --dry-run --format=json --out <file>to enumerate examples for splitting. On failure it printed the contents of that--outJSON file — i.e. the example list — as the error:That's never the error. The real failure (a load error, or an exception raised at
at_exit) goes to the process's stderr.executestreamed it viapopen2ebut never captured it, so the rescue had only the JSON file to fall back on. Worse, when the crash happens atat_exit— after rspec has already written a complete JSON file — that file contains no trace of the error at all, so the log is just a giant, useless JSON blob.Fix
executetakes an opt-incapture:flag. When set, it accumulates the command's combined stdout+stderr and attaches it to the raisedError(newError#output). Default isfalse, so the streaming behaviour of every other call is unchanged (and large test runs aren't buffered into memory).RunSpecsruns the dry-run withcapture: trueand, on failure, fails with the captured output instead of the JSON file.A failed dry-run now surfaces the actual error:
Specs updated for the new behaviour; full suite is green with 100% line and branch coverage.