Class: RSpec::Core::Bisect::Coordinator

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/core/bisect/coordinator.rb

Overview

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

- Bisect::ShellCommand: Generates shell commands to run spec subsets
- Bisect::ShellRunner: Runs a set of examples and returns the results.
- Bisect::ExampleMinimizer: Contains the core bisect logic.
- Formatters::BisectProgressFormatter: provides progress updates
  to the user.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_cli_args, formatter) ⇒ Coordinator



22
23
24
25
# File 'lib/rspec/core/bisect/coordinator.rb', line 22

def initialize(original_cli_args, formatter)
  @shell_command = ShellCommand.new(original_cli_args)
  @notifier      = Bisect::Notifier.new(formatter)
end

Class Method Details

.bisect_with(original_cli_args, formatter) ⇒ Object



18
19
20
# File 'lib/rspec/core/bisect/coordinator.rb', line 18

def self.bisect_with(original_cli_args, formatter)
  new(original_cli_args, formatter).bisect
end

Instance Method Details

#bisectObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rspec/core/bisect/coordinator.rb', line 27

def bisect
  repro = ShellRunner.start(@shell_command) do |runner|
    minimizer = ExampleMinimizer.new(@shell_command, runner, @notifier)

    gracefully_abort_on_sigint(minimizer)
    minimizer.find_minimal_repro
    minimizer.repro_command_for_currently_needed_ids
  end

  @notifier.publish(:bisect_repro_command, :repro => repro)

  true
rescue BisectFailedError => e
  @notifier.publish(:bisect_failed, :failure_explanation => e.message)
  false
ensure
  @notifier.publish(:close)
end