Class: Selective::Ruby::Core::Controller

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/selective/ruby/core/controller.rb

Constant Summary collapse

REQUIRED_CONFIGURATION =
{
  "host" => "SELECTIVE_HOST",
  "api_key" => "SELECTIVE_API_KEY",
  "platform" => "SELECTIVE_PLATFORM",
  "run_id" => "SELECTIVE_RUN_ID",
  "run_attempt" => "SELECTIVE_RUN_ATTEMPT",
  "branch" => "SELECTIVE_BRANCH"
}.freeze
@@selective_suppress_reporting =
false
@@report_at_finish =
{}

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper

#banner, banner, #print_notice, #print_warning, #puts_indented, #safe_filename, #with_error_handling

Constructor Details

#initialize(runner_class, runner_args, debug: false, log: false) ⇒ Controller

Returns a new instance of Controller.



22
23
24
25
26
27
28
# File 'lib/selective/ruby/core/controller.rb', line 22

def initialize(runner_class, runner_args, debug: false, log: false)
  @debug = debug
  @runner = runner_class.new(runner_args, method(:test_case_callback))
  @retries = 0
  @runner_id = safe_filename(get_runner_id)
  @logger = init_logger(log)
end

Class Method Details

.report_at_finishObject



61
62
63
# File 'lib/selective/ruby/core/controller.rb', line 61

def self.report_at_finish
  @@report_at_finish
end

.restore_reporting!Object



53
54
55
# File 'lib/selective/ruby/core/controller.rb', line 53

def self.restore_reporting!
  @@selective_suppress_reporting = false
end

.suppress_reporting!Object



49
50
51
# File 'lib/selective/ruby/core/controller.rb', line 49

def self.suppress_reporting!
  @@selective_suppress_reporting = true
end

.suppress_reporting?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/selective/ruby/core/controller.rb', line 57

def self.suppress_reporting?
  @@selective_suppress_reporting
end

Instance Method Details

#execObject



43
44
45
46
47
# File 'lib/selective/ruby/core/controller.rb', line 43

def exec
  runner.exec
rescue => e
  with_error_handling(include_header: false) { raise e }
end

#start(reconnect: false) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/selective/ruby/core/controller.rb', line 30

def start(reconnect: false)
  @pipe = NamedPipe.new("/tmp/#{runner_id}_2", "/tmp/#{runner_id}_1")
  @transport_pid = spawn_transport_process(reconnect: reconnect)

  handle_termination_signals(transport_pid)
  wait_for_connectivity
  run_main_loop
rescue ConnectionLostError
  retry!
rescue => e
  with_error_handling { raise e }
end