Class: Beaker::TestmodeSwitcher::RunnerBase

Inherits:
Object
  • Object
show all
Defined in:
lib/beaker/testmode_switcher/runner_base.rb

Overview

Contains functions used in both local runner and beaker runners

Direct Known Subclasses

BeakerRunnerBase, LocalRunner

Instance Method Summary collapse

Instance Method Details

#get_acceptable_puppet_run_exit_codes(opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/beaker/testmode_switcher/runner_base.rb', line 9

def get_acceptable_puppet_run_exit_codes(opts = {})
  # Ensure only one option given
  if [opts[:catch_changes], opts[:catch_failures], opts[:expect_failures], opts[:expect_changes]].compact.length > 1
    raise(ArgumentError,
          'Cannot specify more than one of `catch_failures`, \
           `catch_changes`, `expect_failures`, or `expect_changes` \
            for a single manifest')
  end

  # Return appropriate exit code
  return [0]        if opts[:catch_changes]
  return [0, 2]     if opts[:catch_failures]
  return [1, 4, 6]  if opts[:expect_failures]
  return [2]        if opts[:expect_changes]

  # If no option supplied, return all exit codes, as an array,
  # as acceptable so beaker returns a detailed output
  (0...256)
end

#handle_puppet_run_returned_exit_code(acceptable_exit_codes, returned_exit_code) ⇒ Object



29
30
31
32
# File 'lib/beaker/testmode_switcher/runner_base.rb', line 29

def handle_puppet_run_returned_exit_code(acceptable_exit_codes, returned_exit_code)
  return if acceptable_exit_codes.include?(returned_exit_code)
  raise UnacceptableExitCodeError, "Unacceptable exit code returned: #{returned_exit_code}. Acceptable code(s): #{acceptable_exit_codes.join(', ')}"
end