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

Commit 589e4b8

Browse files
committed
Merge pull request #3093 from makicamel/fix-non_failing_example_ids
Fixed rspec --bisect to sort ids_to_run as the original order
1 parent 71b9b03 commit 589e4b8

9 files changed

+57
-2
lines changed

Changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
### Development
22
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.3...main)
33

4+
Bug fixes:
5+
6+
* Sort ids to run as the original order to fix `--bisect`. (Maki Kawahara, #3093)
7+
48
### 3.13.0 / 2024-02-04
59
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.3...v3.13.0)
610

lib/rspec/core/bisect/example_minimizer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def non_failing_example_ids
136136
end
137137

138138
def get_expected_failures_for?(ids)
139-
ids_to_run = ids + failed_example_ids
139+
ids_to_run = all_example_ids & (ids + failed_example_ids)
140140
notify(
141141
:bisect_individual_run_start,
142142
:command => shell_command.repro_command_from(ids_to_run),

spec/integration/bisect_spec.rb

+13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ def bisect(cli_args, expected_status=nil)
3535
end
3636
end
3737

38+
context "when the spec ordering is consistent" do
39+
it 'returns the minimal reproduction command' do
40+
output = bisect(%w[
41+
--order defined
42+
spec/rspec/core/resources/bisect/consistently_ordered_1_specs.rb
43+
spec/rspec/core/resources/bisect/consistently_ordered_2_specs.rb
44+
spec/rspec/core/resources/bisect/consistently_ordered_3_specs.rb
45+
spec/rspec/core/resources/bisect/consistently_ordered_4_specs.rb
46+
])
47+
expect(output).to include("Bisect complete!", "rspec ./spec/rspec/core/resources/bisect/consistently_ordered_2_specs.rb[1:1] ./spec/rspec/core/resources/bisect/consistently_ordered_3_specs.rb[1:1]")
48+
end
49+
end
50+
3851
context "when the bisect command saturates the pipe" do
3952
# On OSX and Linux a file descriptor limit meant that the bisect process got stuck at a certain limit.
4053
# This test demonstrates that we can run large bisects above this limit (found to be at time of commit).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Deliberately named _specs.rb to avoid being loaded except when specified
2+
3+
RSpec.describe "Order1" do
4+
it("passes") { expect(1).to eq 1 }
5+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Deliberately named _specs.rb to avoid being loaded except when specified
2+
3+
require "rspec/core/resources/bisect/frieren_quote"
4+
5+
RSpec.describe "Order2" do
6+
before { FrierenQuote.change }
7+
8+
it("passes") { expect(1).to eq 1 }
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Deliberately named _specs.rb to avoid being loaded except when specified
2+
3+
require "rspec/core/resources/bisect/frieren_quote"
4+
5+
RSpec.describe "Order3" do
6+
it("fails order-dependency") { expect(FrierenQuote.one).to eq "That is what hero Himmel would have done." }
7+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Deliberately named _specs.rb to avoid being loaded except when specified
2+
3+
RSpec.describe "Order4" do
4+
it("passes") { expect(1).to eq 1 }
5+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class FrierenQuote
2+
class << self
3+
def one
4+
@@one ||= "That is what hero Himmel would have done."
5+
end
6+
7+
def change
8+
@@one = "The greatest enjoyment comes only during the pursuit of magic, you know."
9+
end
10+
end
11+
end
12+

spec/support/fake_bisect_runner.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def run(ids)
1616
failures << failing_example if dependency_satisfied?(depends_upon, ids)
1717
end
1818

19-
RSpec::Core::Bisect::ExampleSetDescriptor.new(ids.sort, failures.sort)
19+
RSpec::Core::Bisect::ExampleSetDescriptor.new(ids, failures.sort)
2020
end
2121

2222
private

0 commit comments

Comments
 (0)