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

Commit b836d71

Browse files
authored
Merge pull request #2502 from rspec/myron/simplify-bisect-formatter
Simplify BisectFormatter using `example_finished` notification.
2 parents b48d851 + a35be9f commit b836d71

File tree

1 file changed

+11
-29
lines changed

1 file changed

+11
-29
lines changed

lib/rspec/core/formatters/bisect_formatter.rb

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,30 @@ module Formatters
1212
# after each example.
1313
# @private
1414
class BisectFormatter
15-
Formatters.register self, :start, :start_dump, :example_started,
16-
:example_failed, :example_passed, :example_pending
15+
Formatters.register self, :start_dump, :example_failed, :example_finished
1716

1817
def initialize(_output)
19-
port = RSpec.configuration.drb_port
20-
drb_uri = "druby://localhost:#{port}"
21-
@all_example_ids = []
22-
@failed_example_ids = []
18+
drb_uri = "druby://localhost:#{RSpec.configuration.drb_port}"
2319
@bisect_server = DRbObject.new_with_uri(drb_uri)
24-
@remaining_failures = []
2520
RSpec.configuration.files_or_directories_to_run = @bisect_server.files_or_directories_to_run
26-
end
2721

28-
def start(_notification)
22+
@all_example_ids = []
23+
@failed_example_ids = []
2924
@remaining_failures = Set.new(@bisect_server.expected_failures)
3025
end
3126

32-
def example_started(notification)
33-
@all_example_ids << notification.example.id
34-
end
35-
3627
def example_failed(notification)
3728
@failed_example_ids << notification.example.id
38-
example_finished(notification, :failed)
3929
end
4030

41-
def example_passed(notification)
42-
example_finished(notification, :passed)
43-
end
31+
def example_finished(notification)
32+
@all_example_ids << notification.example.id
33+
return unless @remaining_failures.include?(notification.example.id)
34+
@remaining_failures.delete(notification.example.id)
4435

45-
def example_pending(notification)
46-
example_finished(notification, :pending)
36+
status = notification.example.execution_result.status
37+
return if status == :failed && !@remaining_failures.empty?
38+
RSpec.world.wants_to_quit = true
4739
end
4840

4941
def start_dump(_notification)
@@ -53,16 +45,6 @@ def start_dump(_notification)
5345
end
5446

5547
RunResults = Struct.new(:all_example_ids, :failed_example_ids)
56-
57-
private
58-
59-
def example_finished(notification, status)
60-
return unless @remaining_failures.include?(notification.example.id)
61-
@remaining_failures.delete(notification.example.id)
62-
63-
return if status == :failed && !@remaining_failures.empty?
64-
RSpec.world.wants_to_quit = true
65-
end
6648
end
6749
end
6850
end

0 commit comments

Comments
 (0)