Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Fix the bisect runner breaking the output expectation #3113

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/rspec/core/bisect/fork_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def initialize(runner, channel)
@runner = runner
@channel = channel

@spec_output = StringIO.new
require "tempfile"
@spec_output = Tempfile.new

runner.configuration.tap do |c|
c.reset_reporter
Expand Down Expand Up @@ -122,7 +123,7 @@ def run_specs(run_descriptor)
latest_run_results = formatter.results

if latest_run_results.nil? || latest_run_results.all_example_ids.empty?
@channel.send(@spec_output.string)
@channel.send(@spec_output.tap(&:rewind).read)
else
@channel.send(latest_run_results)
end
Expand Down
7 changes: 7 additions & 0 deletions spec/integration/bisect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ def bisect(cli_args, expected_status=nil)
end
end

context "when specs use the `output` expectation" do
it 'does not break the capture helper' do
output = bisect(%w[spec/rspec/core/resources/bisect/output_capture_specs.rb])
expect(output).to include("No failures found")
end
end

class RSpecChildProcess
Ps = Struct.new(:pid, :ppid, :state, :command)

Expand Down
7 changes: 7 additions & 0 deletions spec/rspec/core/resources/bisect/output_capture_specs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Deliberately named _specs.rb to avoid being loaded except when specified

RSpec.describe "output capture" do
it "can still capture output when running under --bisect" do
expect { puts "hi" }.to output("hi\n").to_stdout_from_any_process
end
end
Loading