BigW Consortium Gitlab

Commit 9d9ee761 by Lin Jen-Shin

Use Service::Shellout.shell to spawn a command

parent 4e712f76
...@@ -21,12 +21,7 @@ module QA ...@@ -21,12 +21,7 @@ module QA
def ssh_keygen(name, bits, path) def ssh_keygen(name, bits, path)
cmd = %W[ssh-keygen -t #{name} -b #{bits} -f #{path} -N] << '' cmd = %W[ssh-keygen -t #{name} -b #{bits} -f #{path} -N] << ''
IO.popen([*cmd, err: %i[child out]]) do |io| Service::Shellout.shell(cmd)
out = io.read
io.close
raise "ssh-keygen failed with output: #{out}" unless $?.success?
end
end end
def populate_key_data(path) def populate_key_data(path)
......
...@@ -5,6 +5,8 @@ module QA ...@@ -5,6 +5,8 @@ module QA
module Shellout module Shellout
CommandError = Class.new(StandardError) CommandError = Class.new(StandardError)
module_function
## ##
# TODO, make it possible to use generic QA framework classes # TODO, make it possible to use generic QA framework classes
# as a library - gitlab-org/gitlab-qa#94 # as a library - gitlab-org/gitlab-qa#94
...@@ -12,7 +14,7 @@ module QA ...@@ -12,7 +14,7 @@ module QA
def shell(command) def shell(command)
puts "Executing `#{command}`" puts "Executing `#{command}`"
Open3.popen2e(command) do |_in, out, wait| Open3.popen2e(*command) do |_in, out, wait|
out.each { |line| puts line } out.each { |line| puts line }
if wait.value.exited? && wait.value.exitstatus.nonzero? 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