diff options
| -rw-r--r-- | Library/Homebrew/formula_assertions.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Library/Homebrew/formula_assertions.rb b/Library/Homebrew/formula_assertions.rb index ea12ce001..bdcf0aef2 100644 --- a/Library/Homebrew/formula_assertions.rb +++ b/Library/Homebrew/formula_assertions.rb @@ -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 |
