aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/formula_assertions.rb
diff options
context:
space:
mode:
authorBaptiste Fontaine2015-01-19 10:20:49 +0100
committerMike McQuaid2015-01-19 18:35:33 +0100
commit8b793c6ab388ed606ac0ff550ca98920c22226f2 (patch)
treefa6b20ff434ff9458a17a1b98231f9588a3f1d8a /Library/Homebrew/formula_assertions.rb
parent3a3f56e9a3a6257db071f85ca189a27ad18bd85e (diff)
downloadbrew-8b793c6ab388ed606ac0ff550ca98920c22226f2.tar.bz2
pipe_output optional result assertion added
Closes Homebrew/homebrew#36024. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew/formula_assertions.rb')
-rw-r--r--Library/Homebrew/formula_assertions.rb9
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