Class: Crosstest::Shell::BuffShellOutExecutor

Inherits:
Object
  • Object
show all
Includes:
Core::Logger
Defined in:
lib/crosstest/shell/buff_shellout_executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#shellObject (readonly)

Returns the value of attribute shell


7
8
9
# File 'lib/crosstest/shell/buff_shellout_executor.rb', line 7

def shell
  @shell
end

Instance Method Details

#execute(command, opts) ⇒ Object

rubocop:disable Metrics/AbcSize


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/crosstest/shell/buff_shellout_executor.rb', line 9

def execute(command, opts) # rubocop:disable Metrics/AbcSize
  @logger = opts.delete(:logger) || logger
  cwd = opts[:cwd] || Dir.pwd
  env = opts[:env] || {}
  # @shell.live_stream = IOToLog.new(@logger)
  shell_result = Dir.chdir(cwd) do
    Bundler.with_clean_env do
      Buff::ShellOut.shell_out(command, env)
    end
  end
  fail Errno::ENOENT, shell_result.stderr if shell_result.exitstatus == 127
  execution_result(command, shell_result)
rescue SystemCallError => e
  execution_error = ExecutionError.new(e)
  execution_error.execution_result = execution_result(command, shell_result)
  raise execution_error
end