Don't touch PATH, GEM_HOME and GEM_PATH when testing formula
This commit is contained in:
parent
4524714a7b
commit
769a6cd1f5
@ -35,7 +35,7 @@ module Homebrew
|
|||||||
def test
|
def test
|
||||||
args = test_args.parse
|
args = test_args.parse
|
||||||
|
|
||||||
Homebrew.install_bundler_gems!
|
Homebrew.install_bundler_gems!(setup_path: false)
|
||||||
|
|
||||||
require "formula_assertions"
|
require "formula_assertions"
|
||||||
require "formula_free_port"
|
require "formula_free_port"
|
||||||
|
@ -125,7 +125,11 @@ module Homebrew
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_bundler_gems!(only_warn_on_failure: false)
|
def install_bundler_gems!(only_warn_on_failure: false, setup_path: true)
|
||||||
|
old_path = ENV["PATH"]
|
||||||
|
old_gem_path = ENV["GEM_PATH"]
|
||||||
|
old_gem_home = ENV["GEM_HOME"]
|
||||||
|
|
||||||
install_bundler!
|
install_bundler!
|
||||||
|
|
||||||
ENV["BUNDLE_GEMFILE"] = File.join(ENV.fetch("HOMEBREW_LIBRARY"), "Homebrew", "Gemfile")
|
ENV["BUNDLE_GEMFILE"] = File.join(ENV.fetch("HOMEBREW_LIBRARY"), "Homebrew", "Gemfile")
|
||||||
@ -152,5 +156,12 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
setup_gem_environment!
|
setup_gem_environment!
|
||||||
|
ensure
|
||||||
|
unless setup_path
|
||||||
|
# Reset the paths. We need to have at least temporarily changed them while invoking `bundle`.
|
||||||
|
ENV["PATH"] = old_path
|
||||||
|
ENV["GEM_PATH"] = old_gem_path
|
||||||
|
ENV["GEM_HOME"] = old_gem_home
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,6 +22,6 @@ module Homebrew
|
|||||||
sig { void }
|
sig { void }
|
||||||
def install_bundler!; end
|
def install_bundler!; end
|
||||||
|
|
||||||
sig { params(only_warn_on_failure: T::Boolean).void }
|
sig { params(only_warn_on_failure: T::Boolean, setup_path: T::Boolean).void }
|
||||||
def install_bundler_gems!(only_warn_on_failure: false); end
|
def install_bundler_gems!(only_warn_on_failure: false, setup_path: false); end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user