class RSpec::Core::Formatters::BisectFormatter

Used by `–bisect`. When it shells out and runs a portion of the suite, it uses this formatter as a means to have the status reported back to it, via DRb.

Note that since DRb calls carry considerable overhead compared to normal method calls, we try to minimize the number of DRb calls for perf reasons, opting to communicate only at the start and the end of the run, rather than after each example. @private

Constants

RunResults

Public Class Methods

new(_output) click to toggle source
# File lib/rspec/core/formatters/bisect_formatter.rb, line 18
def initialize(_output)
  port = RSpec.configuration.drb_port
  drb_uri = "druby://localhost:#{port}"
  @all_example_ids = []
  @failed_example_ids = []
  @bisect_server = DRbObject.new_with_uri(drb_uri)
  @remaining_failures = []
  RSpec.configuration.files_or_directories_to_run = @bisect_server.files_or_directories_to_run
end

Public Instance Methods

example_failed(notification) click to toggle source
# File lib/rspec/core/formatters/bisect_formatter.rb, line 36
def example_failed(notification)
  @failed_example_ids << notification.example.id
  example_finished(notification, :failed)
end
example_passed(notification) click to toggle source
# File lib/rspec/core/formatters/bisect_formatter.rb, line 41
def example_passed(notification)
  example_finished(notification, :passed)
end
example_pending(notification) click to toggle source
# File lib/rspec/core/formatters/bisect_formatter.rb, line 45
def example_pending(notification)
  example_finished(notification, :pending)
end
example_started(notification) click to toggle source
# File lib/rspec/core/formatters/bisect_formatter.rb, line 32
def example_started(notification)
  @all_example_ids << notification.example.id
end
start(_notification) click to toggle source
# File lib/rspec/core/formatters/bisect_formatter.rb, line 28
def start(_notification)
  @remaining_failures = Set.new(@bisect_server.expected_failures)
end
start_dump(_notification) click to toggle source
# File lib/rspec/core/formatters/bisect_formatter.rb, line 49
def start_dump(_notification)
  @bisect_server.latest_run_results = RunResults.new(
    @all_example_ids, @failed_example_ids
  )
end

Private Instance Methods

example_finished(notification, status) click to toggle source
# File lib/rspec/core/formatters/bisect_formatter.rb, line 59
def example_finished(notification, status)
  return unless @remaining_failures.include?(notification.example.id)
  @remaining_failures.delete(notification.example.id)

  return if status == :failed && !@remaining_failures.empty?
  RSpec.world.wants_to_quit = true
end