summaryrefslogtreecommitdiff
path: root/qa/qa/service/shellout.rb
blob: 898febde63c17e45039d91d978d4faa266b7759f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'open3'

module QA
  module Service
    module Shellout
      ##
      # TODO, make it possible to use generic QA framework classes
      # as a library - gitlab-org/gitlab-qa#94
      #
      def shell(command)
        puts "Executing `#{command}`"

        Open3.popen2e(command) do |_in, out, wait|
          out.each { |line| puts line }

          if wait.value.exited? && wait.value.exitstatus.nonzero?
            raise "Command `#{command}` failed!"
          end
        end
      end
    end
  end
end