formula_assertions: Convert to Sorbet typed: strict

This commit is contained in:
Issy Long 2024-07-04 23:59:32 +01:00
parent bd9c7777e8
commit fdd7fdd2f6
No known key found for this signature in database

View File

@ -1,4 +1,4 @@
# typed: true # typed: strict
# frozen_string_literal: true # frozen_string_literal: true
module Homebrew module Homebrew
@ -10,15 +10,18 @@ module Homebrew
require "minitest/assertions" require "minitest/assertions"
include ::Minitest::Assertions include ::Minitest::Assertions
sig { params(assertions: Integer).returns(Integer) }
attr_writer :assertions attr_writer :assertions
sig { returns(Integer) }
def assertions def assertions
@assertions ||= 0 @assertions ||= T.let(0, T.nilable(Integer))
end end
# Returns the output of running cmd and asserts the exit status. # Returns the output of running cmd and asserts the exit status.
# #
# @api public # @api public
sig { params(cmd: String, result: Integer).returns(String) }
def shell_output(cmd, result = 0) def shell_output(cmd, result = 0)
ohai cmd ohai cmd
output = `#{cmd}` output = `#{cmd}`
@ -33,6 +36,7 @@ module Homebrew
# optionally asserts the exit status. # optionally asserts the exit status.
# #
# @api public # @api public
sig { params(cmd: String, input: T.nilable(String), result: T.nilable(Integer)).returns(String) }
def pipe_output(cmd, input = nil, result = nil) def pipe_output(cmd, input = nil, result = nil)
ohai cmd ohai cmd
output = IO.popen(cmd, "w+") do |pipe| output = IO.popen(cmd, "w+") do |pipe|