Skip to content

Commit d1a1c37

Browse files
committed
Enable strict typing in Homebrew::TestBot
1 parent 9187b1a commit d1a1c37

18 files changed

+825
-553
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

3-
require "test_bot"
4-
require "ostruct"
3+
require "dev-cmd/test-bot"
54

65
RSpec.describe Homebrew::TestBot::Setup do
76
subject(:setup) { described_class.new }
@@ -12,7 +11,7 @@
1211
.exactly(3).times
1312
.and_return(instance_double(Homebrew::TestBot::Step, passed?: true))
1413

15-
expect(setup.run!(args: instance_double(Homebrew::CLI::Args)).passed?).to be(true)
14+
expect(setup.run!(args: instance_double(Homebrew::Cmd::TestBotCmd::Args)).passed?).to be(true)
1615
end
1716
end
1817
end

Library/Homebrew/test_bot.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# typed: true # rubocop:todo Sorbet/StrictSigil
1+
# typed: strict
22
# frozen_string_literal: true
33

44
require "test_bot/step"
@@ -23,14 +23,17 @@ module TestBot
2323

2424
HOMEBREW_TAP_REGEX = %r{^([\w-]+)/homebrew-([\w-]+)$}
2525

26+
sig { params(args: Homebrew::Cmd::TestBotCmd::Args).returns(T::Boolean) }
2627
def cleanup?(args)
2728
args.cleanup? || GitHub::Actions.env_set?
2829
end
2930

31+
sig { params(args: Homebrew::Cmd::TestBotCmd::Args).returns(T::Boolean) }
3032
def local?(args)
3133
args.local? || GitHub::Actions.env_set?
3234
end
3335

36+
sig { params(tap: T.nilable(String)).returns(T.nilable(Tap)) }
3437
def resolve_test_tap(tap = nil)
3538
return Tap.fetch(tap) if tap
3639

@@ -52,6 +55,7 @@ def resolve_test_tap(tap = nil)
5255
end
5356
end
5457

58+
sig { params(args: Homebrew::Cmd::TestBotCmd::Args).void }
5559
def run!(args)
5660
$stdout.sync = true
5761
$stderr.sync = true

Library/Homebrew/test_bot/bottles_fetch.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
module Homebrew
55
module TestBot
66
class BottlesFetch < TestFormulae
7+
sig { returns(T::Array[String]) }
78
attr_accessor :testing_formulae
89

10+
sig { params(args: Homebrew::Cmd::TestBotCmd::Args).void }
911
def run!(args:)
1012
info_header "Testing formulae:"
1113
puts testing_formulae
@@ -19,6 +21,7 @@ def run!(args:)
1921

2022
private
2123

24+
sig { returns(T::Hash[Symbol, T::Set[String]]) }
2225
def formulae_by_tag
2326
tags = Hash.new { |hash, key| hash[key] = Set.new }
2427

@@ -38,6 +41,7 @@ def formulae_by_tag
3841
tags
3942
end
4043

44+
sig { params(tag: Symbol, formulae: T::Set[String], args: Homebrew::Cmd::TestBotCmd::Args).void }
4145
def fetch_bottles!(tag, formulae, args:)
4246
test_header(:BottlesFetch, method: "fetch_bottles!(#{tag})")
4347

Library/Homebrew/test_bot/cleanup_after.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# typed: true # rubocop:todo Sorbet/StrictSigil
1+
# typed: strict
22
# frozen_string_literal: true
33

44
module Homebrew
55
module TestBot
66
class CleanupAfter < TestCleanup
7+
sig { params(args: Homebrew::Cmd::TestBotCmd::Args).void }
78
def run!(args:)
89
if ENV["HOMEBREW_GITHUB_ACTIONS"].present? && ENV["GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED"].blank? &&
910
# don't need to do post-build cleanup unless testing test-bot itself.
@@ -27,6 +28,7 @@ def run!(args:)
2728

2829
private
2930

31+
sig { void }
3032
def pkill_if_needed
3133
pgrep = ["pgrep", "-f", HOMEBREW_CELLAR.to_s]
3234

Library/Homebrew/test_bot/cleanup_before.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# typed: true # rubocop:todo Sorbet/StrictSigil
1+
# typed: strict
22
# frozen_string_literal: true
33

44
module Homebrew
55
module TestBot
66
class CleanupBefore < TestCleanup
7+
sig { params(args: Homebrew::Cmd::TestBotCmd::Args).void }
78
def run!(args:)
89
test_header(:CleanupBefore)
910

0 commit comments

Comments
 (0)