dev-cmd/tests: fetch JSON API files if needed.

If HOMEBREW_NO_INSTALL_FROM_API was set, we hadn't fetched JSON API
files so will need to fetch them for a valid test environment.
This commit is contained in:
Mike McQuaid 2025-08-19 19:18:31 +01:00
parent 5decda29b8
commit 88d2b74ee5
No known key found for this signature in database

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.