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

Commit 362d7d0

Browse files
Introduce #bisect_over_recursive to handle independent failures
Recursive strategy implicitly assumes that at least one candidate is culpable; therefore introduce an initial step (#bisect_over) and a recursive helper method (#bisect_over_recursive) to check that the expected failures do not occur without any of the passing examples.
1 parent 6e81a08 commit 362d7d0

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/rspec/core/bisect/example_minimizer.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def find_minimal_repro
1717
prep
1818

1919
self.remaining_ids, duration = track_duration do
20-
bisect_over(non_failing_example_ids, [])
20+
bisect_over(non_failing_example_ids)
2121
end
2222

2323
notify(:bisect_complete, :round => 10, :duration => duration,
@@ -27,7 +27,13 @@ def find_minimal_repro
2727
remaining_ids + failed_example_ids
2828
end
2929

30-
def bisect_over(candidate_ids, fixed)
30+
def bisect_over(candidate_ids)
31+
return [] if get_expected_failures_for?([])
32+
33+
bisect_over_recursive(candidate_ids, [])
34+
end
35+
36+
def bisect_over_recursive(candidate_ids, fixed)
3137
return candidate_ids if candidate_ids.length == 1
3238
slice_size = (candidate_ids.length / 2.0).ceil
3339
slices = candidate_ids.each_slice(slice_size).to_a
@@ -50,10 +56,10 @@ def bisect_over(candidate_ids, fixed)
5056
:ids_to_ignore => ids_to_ignore,
5157
:remaining_ids => remaining_ids
5258
)
53-
bisect_over(remaining_ids, fixed)
59+
bisect_over_recursive(remaining_ids, fixed)
5460
else
5561
slices.permutation(2).map do |slice, other_slice|
56-
bisect_over(slice, fixed + other_slice)
62+
bisect_over_recursive(slice, fixed + other_slice)
5763
end.flatten(1)
5864
end
5965
end

spec/rspec/core/bisect/example_minimizer_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def bisect_individual_run_start
8585
it 'detects an unminimisable run in the minimum number of rounds' do
8686
minimizer.find_minimal_repro
8787

88-
expect(counting_reporter.round_count).to eq(14)
88+
expect(counting_reporter.round_count).to eq(15)
8989
end
9090
end
9191

0 commit comments

Comments
 (0)