pipe_output optional result assertion added
Closes Homebrew/homebrew#36024. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
3a3f56e9a3
commit
8b793c6ab3
@ -31,14 +31,17 @@ module Homebrew
|
|||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the output of running the cmd, with the optional input
|
# Returns the output of running the cmd with the optional input, and
|
||||||
def pipe_output(cmd, input=nil)
|
# optionally asserts the exit status
|
||||||
|
def pipe_output(cmd, input=nil, result=nil)
|
||||||
ohai cmd
|
ohai cmd
|
||||||
IO.popen(cmd, "w+") do |pipe|
|
output = IO.popen(cmd, "w+") do |pipe|
|
||||||
pipe.write(input) unless input.nil?
|
pipe.write(input) unless input.nil?
|
||||||
pipe.close_write
|
pipe.close_write
|
||||||
pipe.read
|
pipe.read
|
||||||
end
|
end
|
||||||
|
assert_equal result, $?.exitstatus unless result.nil?
|
||||||
|
output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user