pipe_output optional result assertion added

Closes Homebrew/homebrew#36024.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Baptiste Fontaine 2015-01-19 10:20:49 +01:00 committed by Mike McQuaid
parent 3a3f56e9a3
commit 8b793c6ab3

View File

@ -31,14 +31,17 @@ module Homebrew
output
end
# Returns the output of running the cmd, with the optional input
def pipe_output(cmd, input=nil)
# 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
IO.popen(cmd, "w+") do |pipe|
output = IO.popen(cmd, "w+") do |pipe|
pipe.write(input) unless input.nil?
pipe.close_write
pipe.read
end
assert_equal result, $?.exitstatus unless result.nil?
output
end
end
end