diff options
| author | Baptiste Fontaine | 2015-01-19 10:20:49 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2015-01-19 18:35:33 +0100 |
| commit | 9a4a938c9f77b1f563b004f6b08acc3b4cd80ae3 (patch) | |
| tree | 4ea9791d56219af68c89ffe9f3b49f338c0dd462 | |
| parent | 259b115ae0928673a12f01960b4d299e0daa85da (diff) | |
| download | homebrew-9a4a938c9f77b1f563b004f6b08acc3b4cd80ae3.tar.bz2 | |
pipe_output optional result assertion added
Closes #36024.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
| -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 |
