Skip to content

Commit

Permalink
Merge pull request #18391 from Homebrew/shorten_brew_tests_temp_path
Browse files Browse the repository at this point in the history
Shorten `brew tests` temporary paths.
  • Loading branch information
MikeMcQuaid authored Sep 24, 2024
2 parents a553e6b + 27fb07c commit 410fe21
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Library/Homebrew/test/support/lib/startup/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

HOMEBREW_BREW_FILE = Pathname.new(ENV.fetch("HOMEBREW_BREW_FILE")).freeze

homebrew_temp = ENV.fetch("HOMEBREW_TEMP")
TEST_TMPDIR = ENV.fetch("HOMEBREW_TEST_TMPDIR") do |k|
dir = Dir.mktmpdir("homebrew-tests-", ENV.fetch("HOMEBREW_TEMP"))
dir = Dir.mktmpdir("homebrew-tests-", homebrew_temp)
at_exit do
# Child processes inherit this at_exit handler, but we don't want them
# to clean TEST_TMPDIR up prematurely (i.e. when they exit early for a test).
Expand All @@ -15,6 +16,13 @@
ENV[k] = dir
end.freeze

# Use a shorter HOMEBREW_TEMP path so Sequoia doesn't error out as often on long paths (> 104 bytes).
# Use the minimal amount of randomness to avoid collisions while allowing parallel tests.
require "securerandom"
random_hex = SecureRandom.hex(1)
HOMEBREW_TEMP = Pathname("#{homebrew_temp}/brewtests#{random_hex}".squeeze("/")).freeze
HOMEBREW_TEMP.mkpath

# Paths pointing into the Homebrew code base that persist across test runs
HOMEBREW_SHIMS_PATH = (HOMEBREW_LIBRARY_PATH/"shims").freeze

Expand All @@ -32,7 +40,6 @@
HOMEBREW_LOCKS = (HOMEBREW_PREFIX.parent/"locks").freeze
HOMEBREW_CELLAR = (HOMEBREW_PREFIX.parent/"cellar").freeze
HOMEBREW_LOGS = (HOMEBREW_PREFIX.parent/"logs").freeze
HOMEBREW_TEMP = (HOMEBREW_PREFIX.parent/"temp").freeze
HOMEBREW_TAP_DIRECTORY = (HOMEBREW_LIBRARY/"Taps").freeze
HOMEBREW_RUBY_EXEC_ARGS = [
RUBY_PATH,
Expand Down

0 comments on commit 410fe21

Please sign in to comment.