brew/Library/Homebrew/formula_assertions.rb

26 lines
582 B
Ruby
Raw Normal View History

2014-07-27 10:34:22 -07:00
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)
2014-07-29 21:59:49 -07:00
ohai cmd
2014-07-27 10:34:22 -07:00
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)
2014-07-29 21:59:49 -07:00
ohai cmd
2014-07-27 10:34:22 -07:00
IO.popen(cmd, "w+") do |pipe|
pipe.write(input) unless input.nil?
pipe.close_write
pipe.read
end
end
end
end