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

Fixed rspec --bisect to sort ids_to_run as the original order #3093

Merged
merged 3 commits into from
Jul 9, 2024
Merged
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
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
### Development
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.13.0...main)

Bug fixes:

* Sort ids to run as the original order to fix `--bisect`. (Maki Kawahara, #3093)

### 3.13.0 / 2024-02-04
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.3...v3.13.0)

Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/bisect/example_minimizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def non_failing_example_ids
end

def get_expected_failures_for?(ids)
ids_to_run = ids + failed_example_ids
ids_to_run = all_example_ids & (ids + failed_example_ids)
JonRowe marked this conversation as resolved.
Show resolved Hide resolved
notify(
:bisect_individual_run_start,
:command => shell_command.repro_command_from(ids_to_run),
Expand Down
13 changes: 13 additions & 0 deletions spec/integration/bisect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ def bisect(cli_args, expected_status=nil)
end
end

context "when the spec ordering is consistent" do
it 'returns the minimal reproduction command' do
output = bisect(%w[
--order defined
spec/rspec/core/resources/bisect/consistently_ordered_1_specs.rb
spec/rspec/core/resources/bisect/consistently_ordered_2_specs.rb
spec/rspec/core/resources/bisect/consistently_ordered_3_specs.rb
spec/rspec/core/resources/bisect/consistently_ordered_4_specs.rb
])
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]")
end
end

context "when the bisect command saturates the pipe" do
# On OSX and Linux a file descriptor limit meant that the bisect process got stuck at a certain limit.
# This test demonstrates that we can run large bisects above this limit (found to be at time of commit).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Deliberately named _specs.rb to avoid being loaded except when specified

RSpec.describe "Order1" do
it("passes") { expect(1).to eq 1 }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Deliberately named _specs.rb to avoid being loaded except when specified

require "rspec/core/resources/bisect/frieren_quote"

RSpec.describe "Order2" do
before { FrierenQuote.change }

it("passes") { expect(1).to eq 1 }
end
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

require "rspec/core/resources/bisect/frieren_quote"

RSpec.describe "Order3" do
it("fails order-dependency") { expect(FrierenQuote.one).to eq "That is what hero Himmel would have done." }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Deliberately named _specs.rb to avoid being loaded except when specified

RSpec.describe "Order4" do
it("passes") { expect(1).to eq 1 }
end
12 changes: 12 additions & 0 deletions spec/rspec/core/resources/bisect/frieren_quote.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class FrierenQuote
class << self
def one
@@one ||= "That is what hero Himmel would have done."
end

def change
@@one = "The greatest enjoyment comes only during the pursuit of magic, you know."
end
end
end

2 changes: 1 addition & 1 deletion spec/support/fake_bisect_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def run(ids)
failures << failing_example if dependency_satisfied?(depends_upon, ids)
end

RSpec::Core::Bisect::ExampleSetDescriptor.new(ids.sort, failures.sort)
RSpec::Core::Bisect::ExampleSetDescriptor.new(ids, failures.sort)
end

private
Expand Down
Loading