aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/formula_assertions.rb
diff options
context:
space:
mode:
authorAdam Vandenberg2014-07-27 10:34:22 -0700
committerAdam Vandenberg2014-08-01 07:58:09 -0700
commitc003e805bea98f6d0be62c0938ccad4f4a7e4ce0 (patch)
tree2346dd224ad2c6d5ce3c78a1a1d36ffc53ce2dbe /Library/Homebrew/formula_assertions.rb
parentf4ae1c9e1b603af9ada89de833a31c4ae50c3fb5 (diff)
downloadbrew-c003e805bea98f6d0be62c0938ccad4f4a7e4ce0.tar.bz2
add helpers for formula tests
Diffstat (limited to 'Library/Homebrew/formula_assertions.rb')
-rw-r--r--Library/Homebrew/formula_assertions.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/Library/Homebrew/formula_assertions.rb b/Library/Homebrew/formula_assertions.rb
new file mode 100644
index 000000000..845c5480d
--- /dev/null
+++ b/Library/Homebrew/formula_assertions.rb
@@ -0,0 +1,23 @@
+require 'test/unit/assertions'
+
+module Homebrew
+ module Assertions
+ include Test::Unit::Assertions
+
+ # Returns the output of running cmd, and asserts the exit status
+ def shell_output(cmd, result=0)
+ output = `#{cmd}`
+ assert_equal result, $?.exitstatus
+ output
+ end
+
+ # Returns the output of running the cmd, with the optional input
+ def pipe_output(cmd, input=nil)
+ IO.popen(cmd, "w+") do |pipe|
+ pipe.write(input) unless input.nil?
+ pipe.close_write
+ pipe.read
+ end
+ end
+ end
+end