Merge pull request #20520 from Homebrew/brew_tests_fetch_json_api_files_if_needed

dev-cmd/tests: fetch JSON API files if needed.
This commit is contained in:
Mike McQuaid 2025-08-19 18:34:32 +00:00 committed by GitHub
commit 033138638f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -230,6 +230,25 @@ module Homebrew
ENV.delete(env)
end
# Fetch JSON API files if needed.
download_queue = if Homebrew::EnvConfig.download_concurrency > 1
require "download_queue"
Homebrew::DownloadQueue.new
end
require "api"
require "api/formula"
require "api/cask"
stale_seconds = 86400 # 1 day
Homebrew::API.fetch_api_files!(download_queue:, stale_seconds:)
begin
download_queue&.fetch
ensure
download_queue&.shutdown
end
# Codespaces HOMEBREW_PREFIX and /tmp are mounted 755 which makes Ruby warn constantly.
if (ENV["HOMEBREW_CODESPACES"] == "true") && (HOMEBREW_TEMP.to_s == "/tmp")
# Need to keep this fairly short to avoid socket paths being too long in tests.