mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
24 lines
552 B
Ruby
24 lines
552 B
Ruby
![]() |
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
|