Allow HOMEBREW_RUBY3 in tests

This commit is contained in:
Bo Anderson 2023-10-26 23:07:33 +01:00 committed by Mike McQuaid
parent 4ec450823c
commit 14c1dce38b
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
3 changed files with 16 additions and 8 deletions

View File

@ -208,6 +208,7 @@ module Homebrew
HOMEBREW_CACHE HOMEBREW_CACHE
HOMEBREW_LOGS HOMEBREW_LOGS
HOMEBREW_TEMP HOMEBREW_TEMP
HOMEBREW_RUBY3
] ]
allowed_test_env << "HOMEBREW_USE_RUBY_FROM_PATH" if Homebrew::EnvConfig.developer? allowed_test_env << "HOMEBREW_USE_RUBY_FROM_PATH" if Homebrew::EnvConfig.developer?
Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env| Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env|

View File

@ -9,6 +9,7 @@ describe "RuboCop" do
allowlist = %w[ allowlist = %w[
HOMEBREW_TESTS HOMEBREW_TESTS
HOMEBREW_USE_RUBY_FROM_PATH HOMEBREW_USE_RUBY_FROM_PATH
HOMEBREW_RUBY3
] ]
ENV.delete(key) if key.start_with?("HOMEBREW_") && allowlist.exclude?(key) ENV.delete(key) if key.start_with?("HOMEBREW_") && allowlist.exclude?(key)
end end

View File

@ -78,13 +78,15 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
].compact.join(File::PATH_SEPARATOR) ].compact.join(File::PATH_SEPARATOR)
env.merge!( env.merge!(
"PATH" => path, "PATH" => path,
"HOMEBREW_PATH" => path, "HOMEBREW_PATH" => path,
"HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew", "HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew",
"HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args), "HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args),
"HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR, "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
"HOMEBREW_DEV_CMD_RUN" => "true", "HOMEBREW_DEV_CMD_RUN" => "true",
"GEM_HOME" => nil, "HOMEBREW_USE_RUBY_FROM_PATH" => ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", nil),
"HOMEBREW_RUBY3" => ENV.fetch("HOMEBREW_RUBY3", nil),
"GEM_HOME" => nil,
) )
@ruby_args ||= begin @ruby_args ||= begin
@ -129,8 +131,12 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
end end
def brew_sh(*args) def brew_sh(*args)
env = {
"HOMEBREW_USE_RUBY_FROM_PATH" => ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", nil),
"HOMEBREW_RUBY3" => ENV.fetch("HOMEBREW_RUBY3", nil),
}
Bundler.with_unbundled_env do Bundler.with_unbundled_env do
stdout, stderr, status = Open3.capture3("#{ENV.fetch("HOMEBREW_PREFIX")}/bin/brew", *args) stdout, stderr, status = Open3.capture3(env, "#{ENV.fetch("HOMEBREW_PREFIX")}/bin/brew", *args)
$stdout.print stdout $stdout.print stdout
$stderr.print stderr $stderr.print stderr
status status