gitlab-org--gitlab-foss/qa/qa/service/shellout.rb
Dylan Griffith c9078e3d9d Add a QA spec for RBAC cluster and auto devops
This fails now because we have not yet implemented support for this
2018-10-04 09:38:51 +00:00

29 lines
707 B
Ruby

require 'open3'
module QA
module Service
module Shellout
CommandError = Class.new(StandardError)
module_function
##
# TODO, make it possible to use generic QA framework classes
# as a library - gitlab-org/gitlab-qa#94
#
def shell(command, stdin_data: nil)
puts "Executing `#{command}`"
Open3.popen2e(*command) do |stdin, out, wait|
stdin.puts(stdin_data) if stdin_data
stdin.close if stdin_data
out.each { |line| puts line }
if wait.value.exited? && wait.value.exitstatus.nonzero?
raise CommandError, "Command `#{command}` failed!"
end
end
end
end
end
end