Class: CemAcpt::RunHandler

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/cem_acpt/runner.rb

Overview

RunHandler orchestrates the acceptance test suites, including creating Runner objects, handling input and output, and exception handling.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

current_log_config, #current_log_config, current_log_format, current_log_level, #current_log_level, included, #logger, new_log_config, #new_log_config, new_log_formatter, new_log_level, #new_log_level

Constructor Details

#initialize(params) ⇒ RunHandler

Returns a new instance of RunHandler.

Parameters:

  • params (Hash)

    the parameters passed from the command line



24
25
26
27
28
29
30
31
# File 'lib/cem_acpt/runner.rb', line 24

def initialize(params)
  @params = params
  @config_file = params[:config_file] || File.expand_path('./cem_acpt_config.yaml')
  @module_pkg_path = Concurrent::IVar.new
  @start_time = nil
  @runners = Concurrent::Array.new
  @results = Concurrent::Map.new
end

Instance Attribute Details

#config_fileObject

Returns the value of attribute config_file.



21
22
23
# File 'lib/cem_acpt/runner.rb', line 21

def config_file
  @config_file
end

#paramsObject

Returns the value of attribute params.



21
22
23
# File 'lib/cem_acpt/runner.rb', line 21

def params
  @params
end

Instance Method Details

#runObject

Runs the acceptance test suites.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cem_acpt/runner.rb', line 34

def run
  @start_time = Time.now
  logger.info("Running acceptance test suite at #{@start_time}")
  logger.debug("Params: #{@params}")
  logger.debug("Config file: #{@config_file}")
  logger.info("Using module directory: #{@params[:module_dir]}")
  context_opts = {
    config_opts: @params,
    config_file: @config_file,
  }
  build_module_package
  begin
    keep_terminal_alive if params[:CI] || ENV['CI'] || ENV['GITHUB_ACTION']
    create_and_start_runners(context_opts)
  rescue StandardError, SignalException, SystemExit => e
    handle_fatal_error(e)
  ensure
    @keep_terminal_alive&.exit
  end
  handle_test_results
  exit_code = @runners.map(&:spec_exit_code).any? { |rc| rc != 0 } ? 1 : 0
  exit exit_code
end