brew/Library/Homebrew/formula_assertions.rb
Mike McQuaid ef2e297d3b
Disable RubyGems by default.
This speeds up all Ruby invocations where we don't need RubyGems by
around 10%. Where we do need RubyGems: include it manually.
2019-04-18 17:45:03 +09:00

29 lines
777 B
Ruby

module Homebrew
module Assertions
require "rubygems"
require "test/unit/assertions"
include ::Test::Unit::Assertions
# Returns the output of running cmd, and asserts the exit status
def shell_output(cmd, result = 0)
ohai cmd
output = `#{cmd}`
assert_equal result, $CHILD_STATUS.exitstatus
output
end
# Returns the output of running the cmd with the optional input, and
# optionally asserts the exit status
def pipe_output(cmd, input = nil, result = nil)
ohai cmd
output = IO.popen(cmd, "w+") do |pipe|
pipe.write(input) unless input.nil?
pipe.close_write
pipe.read
end
assert_equal result, $CHILD_STATUS.exitstatus unless result.nil?
output
end
end
end