diff --git a/Library/Homebrew/github_runner_matrix.rb b/Library/Homebrew/github_runner_matrix.rb index 3c013423b5..1a86aa7942 100644 --- a/Library/Homebrew/github_runner_matrix.rb +++ b/Library/Homebrew/github_runner_matrix.rb @@ -255,17 +255,10 @@ class GitHubRunnerMatrix @testing_formulae.select do |formula| next false if macos_version && !formula.compatible_with?(macos_version) - simulate_arch = case arch - when :x86_64 - :intel - when :arm64 - :arm - else - :dunno - end - Homebrew::SimulateSystem.with(os: platform, arch: simulate_arch) do - formula.public_send(:"#{platform}_compatible?") && - formula.public_send(:"#{arch}_compatible?") + Homebrew::SimulateSystem.with(os: platform, arch: Homebrew::SimulateSystem.arch_symbols.fetch(arch)) do + simulated_formula = TestRunnerFormula.new(Formulary.factory(formula.name)) + simulated_formula.public_send(:"#{platform}_compatible?") && + simulated_formula.public_send(:"#{arch}_compatible?") end end end @@ -283,8 +276,11 @@ class GitHubRunnerMatrix .select do |dependent_f| next false if macos_version && !dependent_f.compatible_with?(macos_version) - dependent_f.public_send(:"#{platform}_compatible?") && - dependent_f.public_send(:"#{arch}_compatible?") + Homebrew::SimulateSystem.with(os: platform, arch: Homebrew::SimulateSystem.arch_symbols.fetch(arch)) do + simulated_dependent_f = TestRunnerFormula.new(Formulary.factory(dependent_f.name)) + simulated_dependent_f.public_send(:"#{platform}_compatible?") && + simulated_dependent_f.public_send(:"#{arch}_compatible?") + end end # These arrays will generally have been generated by different Formulary caches, diff --git a/Library/Homebrew/simulate_system.rb b/Library/Homebrew/simulate_system.rb index e40d891581..840d4ea963 100644 --- a/Library/Homebrew/simulate_system.rb +++ b/Library/Homebrew/simulate_system.rb @@ -10,6 +10,11 @@ module Homebrew class << self attr_reader :arch, :os + sig { returns(T::Hash[Symbol, Symbol]) } + def arch_symbols + { arm64: :arm, x86_64: :intel }.freeze + end + sig { type_parameters(:U).params( os: Symbol, diff --git a/Library/Homebrew/test/github_runner_matrix_spec.rb b/Library/Homebrew/test/github_runner_matrix_spec.rb index 7379e0d7d9..8e062d9aa2 100644 --- a/Library/Homebrew/test/github_runner_matrix_spec.rb +++ b/Library/Homebrew/test/github_runner_matrix_spec.rb @@ -20,7 +20,7 @@ RSpec.describe GitHubRunnerMatrix, :no_api do MacOSVersion::SYMBOLS.find { |k, _| k == described_class::NEWEST_HOMEBREW_CORE_MACOS_RUNNER } end - let(:testball) { TestRunnerFormula.new(Testball.new) } + let(:testball) { setup_test_runner_formula("testball") } let(:testball_depender) { setup_test_runner_formula("testball-depender", ["testball"]) } let(:testball_depender_linux) { setup_test_runner_formula("testball-depender-linux", ["testball", :linux]) } let(:testball_depender_macos) { setup_test_runner_formula("testball-depender-macos", ["testball", :macos]) } @@ -315,6 +315,7 @@ RSpec.describe GitHubRunnerMatrix, :no_api do end end + stub_formula_loader f TestRunnerFormula.new(f) end end diff --git a/Library/Homebrew/test_runner_formula.rb b/Library/Homebrew/test_runner_formula.rb index e3c3c987d6..34c617d77f 100644 --- a/Library/Homebrew/test_runner_formula.rb +++ b/Library/Homebrew/test_runner_formula.rb @@ -77,8 +77,6 @@ class TestRunnerFormula macos_version.public_send(requirement.comparator, requirement.version) end - SIMULATE_SYSTEM_SYMBOLS = T.let({ arm64: :arm, x86_64: :intel }.freeze, T::Hash[Symbol, Symbol]) - sig { params( platform: Symbol, @@ -98,7 +96,7 @@ class TestRunnerFormula with_env(HOMEBREW_EVAL_ALL: eval_all_env) do os = macos_version || platform - arch = SIMULATE_SYSTEM_SYMBOLS.fetch(arch) + arch = Homebrew::SimulateSystem.arch_symbols.fetch(arch) Homebrew::SimulateSystem.with(os:, arch:) do Formula.public_send(formula_selector)