Commit 9d9ee761 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Use Service::Shellout.shell to spawn a command

parent 4e712f76
......@@ -21,12 +21,7 @@ module QA
def ssh_keygen(name, bits, path)
cmd = %W[ssh-keygen -t #{name} -b #{bits} -f #{path} -N] << ''
IO.popen([*cmd, err: %i[child out]]) do |io|
out = io.read
io.close
raise "ssh-keygen failed with output: #{out}" unless $?.success?
end
Service::Shellout.shell(cmd)
end
def populate_key_data(path)
......
......@@ -5,6 +5,8 @@ module QA
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
......@@ -12,7 +14,7 @@ module QA
def shell(command)
puts "Executing `#{command}`"
Open3.popen2e(command) do |_in, out, wait|
Open3.popen2e(*command) do |_in, out, wait|
out.each { |line| puts line }
if wait.value.exited? && wait.value.exitstatus.nonzero?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment