Module: Homebrew::Assertions Private
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Helper functions available in formula test
blocks.
Instance Attribute Summary collapse
- #assertions ⇒ Integer private
Instance Method Summary collapse
-
#pipe_output(cmd, input = nil, result = nil) ⇒ String
Returns the output of running the cmd with the optional input and optionally asserts the exit status.
-
#shell_output(cmd, result = 0) ⇒ String
Returns the output of running cmd and asserts the exit status.
Methods included from Context
current, current=, #debug?, #quiet?, #verbose?, #with_context
Instance Attribute Details
#assertions ⇒ Integer
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
20 21 22 |
# File 'formula_assertions.rb', line 20 def assertions @assertions ||= T.let(0, T.nilable(Integer)) end |
Instance Method Details
#pipe_output(cmd, input = nil, result = nil) ⇒ String
Returns the output of running the cmd with the optional input and optionally asserts the exit status.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'formula_assertions.rb', line 43 def pipe_output(cmd, input = nil, result = nil) ohai cmd output = IO.popen(cmd, "w+") do |pipe| pipe.write(input) unless input.nil? pipe.close_write pipe.read end assert_equal result, $CHILD_STATUS.exitstatus unless result.nil? output rescue Minitest::Assertion puts output if verbose? raise end |
#shell_output(cmd, result = 0) ⇒ String
Returns the output of running cmd and asserts the exit status.
28 29 30 31 32 33 34 35 36 |
# File 'formula_assertions.rb', line 28 def shell_output(cmd, result = 0) ohai cmd output = `#{cmd}` assert_equal result, $CHILD_STATUS.exitstatus output rescue Minitest::Assertion puts output if verbose? raise end |