class RSpec::Core::Bisect::Coordinator

@private The main entry point into the bisect logic. Coordinates among:

- Bisect::Server: Receives suite results.
- Bisect::Runner: Runs a set of examples and directs the results
  to the server.
- Bisect::ExampleMinimizer: Contains the core bisect logic.
- Formatters::BisectProgressFormatter: provides progress updates
  to the user.

Public Class Methods

bisect_with(original_cli_args, configuration, formatter) click to toggle source
# File lib/rspec/core/bisect/coordinator.rb, line 18
def self.bisect_with(original_cli_args, configuration, formatter)
  new(original_cli_args, configuration, formatter).bisect
end
new(original_cli_args, configuration, formatter) click to toggle source
# File lib/rspec/core/bisect/coordinator.rb, line 22
def initialize(original_cli_args, configuration, formatter)
  @original_cli_args = original_cli_args
  @configuration     = configuration
  @formatter         = formatter
end

Public Instance Methods

bisect() click to toggle source
# File lib/rspec/core/bisect/coordinator.rb, line 28
def bisect
  @configuration.add_formatter @formatter

  reporter.close_after do
    repro = Server.run do |server|
      runner    = Runner.new(server, @original_cli_args)
      minimizer = ExampleMinimizer.new(runner, reporter)

      gracefully_abort_on_sigint(minimizer)
      minimizer.find_minimal_repro
      minimizer.repro_command_for_currently_needed_ids
    end

    reporter.publish(:bisect_repro_command, :repro => repro)
  end

  true
rescue BisectFailedError => e
  reporter.publish(:bisect_failed, :failure_explanation => e.message)
  false
end

Private Instance Methods

gracefully_abort_on_sigint(minimizer) click to toggle source
# File lib/rspec/core/bisect/coordinator.rb, line 56
def gracefully_abort_on_sigint(minimizer)
  trap('INT') do
    repro = minimizer.repro_command_for_currently_needed_ids
    reporter.publish(:bisect_aborted, :repro => repro)
    exit(1)
  end
end
reporter() click to toggle source
# File lib/rspec/core/bisect/coordinator.rb, line 52
def reporter
  @configuration.reporter
end