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

Commit 0e9dcc9

Browse files
committed
Suggest bisect_runner = :shell when there was a problem.
1 parent 1484daa commit 0e9dcc9

File tree

3 files changed

+53
-14
lines changed

3 files changed

+53
-14
lines changed

lib/rspec/core/formatters/bisect_progress_formatter.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ module Formatters
66
# @private
77
# Produces progress output while bisecting.
88
class BisectProgressFormatter < BaseTextFormatter
9+
def initialize(output, bisect_runner)
10+
super(output)
11+
@bisect_runner = bisect_runner
12+
end
13+
914
def bisect_starting(notification)
1015
@round_count = 0
1116
output.puts bisect_started_message(notification)
@@ -30,6 +35,16 @@ def bisect_dependency_check_passed(_notification)
3035

3136
def bisect_dependency_check_failed(_notification)
3237
output.puts " failure(s) do not require any non-failures to run first"
38+
39+
if @bisect_runner == :fork
40+
output.puts
41+
output.puts "=" * 80
42+
output.puts "NOTE: this bisect run used `config.bisect_runner = :fork`, which generally"
43+
output.puts "provides significantly faster bisection runs than the old shell-based runner,"
44+
output.puts "but may inaccurately report that no non-failures are required. If this result"
45+
output.puts "is unexpected, consider setting `config.bisect_runner = :shell` and trying again."
46+
output.puts "=" * 80
47+
end
3348
end
3449

3550
def bisect_round_started(notification, include_trailing_space=true)

lib/rspec/core/invocations.rb

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,23 @@ def call(options, err, out)
2828
class Bisect
2929
def call(options, err, out)
3030
RSpec::Support.require_rspec_core "bisect/coordinator"
31+
runner = Runner.new(options).tap { |r| r.configure(err, out) }
32+
formatter = bisect_formatter_klass_for(options.options[:bisect]).new(
33+
out, runner.configuration.bisect_runner
34+
)
3135

3236
success = RSpec::Core::Bisect::Coordinator.bisect_with(
33-
Runner.new(options).tap { |r| r.configure(err, out) },
34-
options.args,
35-
bisect_formatter_for(options.options[:bisect], out)
37+
runner, options.args, formatter
3638
)
3739

3840
success ? 0 : 1
3941
end
4042

4143
private
4244

43-
def bisect_formatter_for(argument, output)
44-
klass = if argument == "verbose"
45-
Formatters::BisectDebugFormatter
46-
else
47-
Formatters::BisectProgressFormatter
48-
end
49-
50-
klass.new(output)
45+
def bisect_formatter_klass_for(argument)
46+
return Formatters::BisectDebugFormatter if argument == "verbose"
47+
Formatters::BisectProgressFormatter
5148
end
5249
end
5350

spec/rspec/core/bisect/coordinator_spec.rb

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ module RSpec::Core
1616
)
1717
end
1818

19-
def find_minimal_repro(output, formatter=Formatters::BisectProgressFormatter)
20-
Bisect::Coordinator.bisect_with(spec_runner, [], formatter.new(output))
19+
def find_minimal_repro(output, formatter=Formatters::BisectProgressFormatter, bisect_runner = :fork)
20+
Bisect::Coordinator.bisect_with(spec_runner, [], formatter.new(output, bisect_runner))
2121
end
2222

2323
it 'notifies the bisect progress formatter of progress and closes the output' do
@@ -99,7 +99,7 @@ def find_minimal_repro(output, formatter=Formatters::BisectProgressFormatter)
9999
it "detects the independent case and prints the minimal reproduction" do
100100
fake_bisect_runner.dependent_failures = {}
101101
output = StringIO.new
102-
find_minimal_repro(output)
102+
find_minimal_repro(output, Formatters::BisectProgressFormatter, :shell)
103103
output = normalize_durations(output.string)
104104

105105
expect(output).to eq(<<-EOS.gsub(/^\s+\|/, ''))
@@ -116,6 +116,33 @@ def find_minimal_repro(output, formatter=Formatters::BisectProgressFormatter)
116116
EOS
117117
end
118118

119+
it "also indicates that the :fork runner may be at fault when that was used" do
120+
fake_bisect_runner.dependent_failures = {}
121+
output = StringIO.new
122+
find_minimal_repro(output, Formatters::BisectProgressFormatter, :fork)
123+
output = normalize_durations(output.string)
124+
125+
expect(output).to eq(<<-EOS.gsub(/^\s+\|/, ''))
126+
|Bisect started using options: ""
127+
|Running suite to find failures... (n.nnnn seconds)
128+
|Starting bisect with 1 failing example and 7 non-failing examples.
129+
|Checking that failure(s) are order-dependent... failure(s) do not require any non-failures to run first
130+
|
131+
|================================================================================
132+
|NOTE: this bisect run used `config.bisect_runner = :fork`, which generally
133+
|provides significantly faster bisection runs than the old shell-based runner,
134+
|but may inaccurately report that no non-failures are required. If this result
135+
|is unexpected, consider setting `config.bisect_runner = :shell` and trying again.
136+
|================================================================================
137+
|
138+
|Bisect complete! Reduced necessary non-failing examples from 7 to 0 in n.nnnn seconds.
139+
|
140+
|The minimal reproduction command is:
141+
| rspec 2.rb[1:1]
142+
143+
EOS
144+
end
145+
119146
it "can use the debug formatter for detailed output" do
120147
fake_bisect_runner.dependent_failures = {}
121148
output = StringIO.new

0 commit comments

Comments
 (0)