Skip to content

Commit 3d11ca2

Browse files
committed
Incorporate feedback
1 parent cc7ef4e commit 3d11ca2

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

Library/Homebrew/test_bot/formulae_dependents.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class FormulaeDependents < TestFormulae
2121
}
2222
def initialize(tap:, git:, dry_run:, fail_fast:, verbose:)
2323
super
24-
@testing_formulae_with_tested_dependents = T.let(nil, T.nilable(T::Array[String]))
24+
@testing_formulae_with_tested_dependents = T.let([], T::Array[String])
2525
@tested_dependents_list = T.let(nil, T.nilable(Pathname))
26-
@dependent_testing_formulae = T.let(nil, T.nilable(T::Array[String]))
26+
@dependent_testing_formulae = T.let([], T::Array[String])
2727
end
2828

2929
sig { params(args: Homebrew::Cmd::TestBotCmd::Args).void }
@@ -37,7 +37,7 @@ def run!(args:)
3737
info_header "Skipped or failed formulae:"
3838
puts skipped_or_failed_formulae
3939

40-
@testing_formulae_with_tested_dependents = T.let([], T.nilable(T::Array[String]))
40+
@testing_formulae_with_tested_dependents = []
4141
@tested_dependents_list = Pathname("tested-dependents-#{Utils::Bottles.tag}.txt")
4242

4343
@dependent_testing_formulae = sorted_formulae - skipped_or_failed_formulae
@@ -92,10 +92,10 @@ def install_formulae_if_needed_from_bottles!(installable_bottles, args:)
9292

9393
sig { params(formula_name: String, args: Homebrew::Cmd::TestBotCmd::Args).void }
9494
def dependent_formulae!(formula_name, args:)
95-
cleanup_during!(T.must(@dependent_testing_formulae), args:)
95+
cleanup_during!(@dependent_testing_formulae, args:)
9696

9797
test_header(:FormulaeDependents, method: "dependent_formulae!(#{formula_name})")
98-
T.must(@testing_formulae_with_tested_dependents) << formula_name
98+
@testing_formulae_with_tested_dependents << formula_name
9999

100100
formula = Formulary.factory(formula_name)
101101

@@ -208,7 +208,7 @@ def dependents_for_formula(formula, formula_name, args:)
208208
# Defer formulae which could be tested later
209209
# i.e. formulae that also depend on something else yet to be built in this test run.
210210
dependents.reject! do |_, deps|
211-
still_to_test = T.must(@dependent_testing_formulae) - T.must(@testing_formulae_with_tested_dependents)
211+
still_to_test = @dependent_testing_formulae - @testing_formulae_with_tested_dependents
212212
deps.map { |d| d.to_formula.full_name }.intersect?(still_to_test)
213213
end
214214

@@ -223,7 +223,7 @@ def dependents_for_formula(formula, formula_name, args:)
223223
# rubocop:enable Homebrew/MoveToExtendOS
224224

225225
all_deps_bottled_or_built = deps.all? do |d|
226-
bottled_or_built?(d.to_formula, T.must(@dependent_testing_formulae))
226+
bottled_or_built?(d.to_formula, @dependent_testing_formulae)
227227
end
228228
args.build_dependents_from_source? && all_deps_bottled_or_built
229229
end
@@ -282,7 +282,7 @@ def install_dependent(dependent, testable_dependents, args:, build_from_source:
282282
return
283283
end
284284

285-
cleanup_during!(T.must(@dependent_testing_formulae), args:)
285+
cleanup_during!(@dependent_testing_formulae, args:)
286286

287287
required_dependent_deps = dependent.deps.reject(&:optional?)
288288
bottled_on_current_version = bottled?(dependent, no_older_versions: true)

Library/Homebrew/test_bot/formulae_detect.rb

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class FormulaeDetect < Test
1010
sig {
1111
params(
1212
argument: String,
13-
tap: T.nilable(Tap),
13+
tap: Tap,
1414
git: String,
1515
dry_run: T::Boolean,
1616
fail_fast: T::Boolean,
@@ -25,6 +25,7 @@ def initialize(argument, tap:, git:, dry_run:, fail_fast:, verbose:)
2525
@deleted_formulae = T.let([], T::Array[String])
2626
@formulae_to_fetch = T.let([], T::Array[String])
2727
@testing_formulae = T.let([], T::Array[String])
28+
@tap = T.let(tap, Tap)
2829
end
2930

3031
sig { params(args: Homebrew::Cmd::TestBotCmd::Args).void }
@@ -83,10 +84,10 @@ def detect_formulae!(args:)
8384
No known CI provider detected! If you are using GitHub Actions then we cannot find the expected environment variables! Check you have e.g. exported them to a Docker container.
8485
EOS
8586
end
86-
elsif tap.present? && T.must(tap).full_name.casecmp(github_repository)&.zero?
87+
elsif @tap.full_name.casecmp(github_repository)&.zero?
8788
# Use GitHub Actions variables for pull request jobs.
8889
if (base_ref = ENV.fetch("GITHUB_BASE_REF", nil)).present?
89-
unless T.must(tap).official?
90+
unless @tap.official?
9091
test git.to_s, "-C", repository.to_s, "fetch",
9192
"origin", "+refs/heads/#{base_ref}"
9293
end
@@ -100,7 +101,7 @@ def detect_formulae!(args:)
100101
diff_end_sha1 = github_sha
101102
# Use GitHub Actions variables for branch jobs.
102103
else
103-
test git.to_s, "-C", repository.to_s, "fetch", "origin", "+#{github_ref}" unless T.must(tap).official?
104+
test git.to_s, "-C", repository.to_s, "fetch", "origin", "+#{github_ref}" unless @tap.official?
104105
origin_ref = "origin/#{github_ref.gsub(%r{^refs/heads/}, "")}"
105106
diff_end_sha1 = diff_start_sha1 = github_sha
106107
end
@@ -120,15 +121,15 @@ def detect_formulae!(args:)
120121

121122
if tap
122123
tap_origin_ref_revision_args =
123-
[git, "-C", T.must(tap).path.to_s, "log", "-1", "--format=%h (%s)", origin_ref]
124+
[git, "-C", @tap.path.to_s, "log", "-1", "--format=%h (%s)", origin_ref]
124125
tap_origin_ref_revision = if args.dry_run?
125126
# May fail on dry run as we've not fetched.
126127
Utils.popen_read(*tap_origin_ref_revision_args).strip
127128
else
128129
Utils.safe_popen_read(*tap_origin_ref_revision_args)
129130
end.strip
130131
tap_revision = Utils.safe_popen_read(
131-
git, "-C", T.must(tap).path.to_s,
132+
git, "-C", @tap.path.to_s,
132133
"log", "-1", "--format=%h (%s)"
133134
).strip
134135
end
@@ -143,8 +144,8 @@ def detect_formulae!(args:)
143144

144145
modified_formulae = []
145146

146-
if tap && diff_start_sha1 != diff_end_sha1
147-
formula_path = T.must(tap).formula_dir.to_s
147+
if diff_start_sha1 != diff_end_sha1
148+
formula_path = @tap.formula_dir.to_s
148149
@added_formulae +=
149150
diff_formulae(diff_start_sha1, diff_end_sha1, formula_path, "A")
150151
modified_formulae +=
@@ -255,17 +256,15 @@ def current_sha1
255256
).returns(T::Array[String])
256257
}
257258
def diff_formulae(start_revision, end_revision, path, filter)
258-
raise "A tap is required to call diff_formulae" unless tap
259-
260259
Utils.safe_popen_read(
261260
git, "-C", repository,
262261
"diff-tree", "-r", "--name-only", "--diff-filter=#{filter}",
263262
start_revision, end_revision, "--", path
264263
).lines(chomp: true).filter_map do |file|
265-
next unless T.must(tap).formula_file?(file)
264+
next unless @tap.formula_file?(file)
266265

267266
file = Pathname.new(file)
268-
T.must(tap).formula_file_to_name(file)
267+
@tap.formula_file_to_name(file)
269268
end
270269
end
271270
end

Library/Homebrew/test_bot/test_runner.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ def build_tests(argument, tap:, git:, output_paths:, skip_setup:,
174174
args.added_formulae.nil? &&
175175
args.deleted_formulae.nil?
176176
if no_formulae_flags && (no_only_args || args.only_formulae? || args.only_formulae_detect?)
177+
raise "A tap is required to build formulae" unless tap
178+
177179
formulae_detect = FormulaeDetect.new(argument, tap:,
178180
git:,
179181
dry_run: args.dry_run?,

0 commit comments

Comments
 (0)