Merge pull request #4500 from reitermarkus/load-path
Refactor `$LOAD_PATH`.
This commit is contained in:
commit
f16bff5b95
@ -12,20 +12,7 @@ if RUBY_X < 2 || (RUBY_X == 2 && RUBY_Y < 3)
|
|||||||
raise "Homebrew must be run under Ruby 2.3! You're running #{RUBY_VERSION}."
|
raise "Homebrew must be run under Ruby 2.3! You're running #{RUBY_VERSION}."
|
||||||
end
|
end
|
||||||
|
|
||||||
require "pathname"
|
require_relative "global"
|
||||||
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
|
|
||||||
|
|
||||||
require "English"
|
|
||||||
|
|
||||||
unless $LOAD_PATH.include?("#{HOMEBREW_LIBRARY_PATH}/cask/lib")
|
|
||||||
$LOAD_PATH.unshift("#{HOMEBREW_LIBRARY_PATH}/cask/lib")
|
|
||||||
end
|
|
||||||
|
|
||||||
unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
|
|
||||||
$LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
require "global"
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
trap("INT", std_trap) # restore default CTRL-C handler
|
trap("INT", std_trap) # restore default CTRL-C handler
|
||||||
|
@ -46,14 +46,3 @@ HOMEBREW_TEMP = begin
|
|||||||
tmp.mkpath unless tmp.exist?
|
tmp.mkpath unless tmp.exist?
|
||||||
tmp.realpath
|
tmp.realpath
|
||||||
end
|
end
|
||||||
|
|
||||||
unless defined? HOMEBREW_LIBRARY_PATH
|
|
||||||
# Root of the Homebrew code base
|
|
||||||
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
|
|
||||||
end
|
|
||||||
|
|
||||||
# Load path used by standalone scripts to access the Homebrew code base
|
|
||||||
HOMEBREW_LOAD_PATH = [
|
|
||||||
HOMEBREW_LIBRARY_PATH,
|
|
||||||
HOMEBREW_LIBRARY_PATH/"cask/lib",
|
|
||||||
].join(File::PATH_SEPARATOR)
|
|
||||||
|
@ -8,6 +8,6 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def ruby
|
def ruby
|
||||||
exec ENV["HOMEBREW_RUBY_PATH"], "-I", HOMEBREW_LOAD_PATH, "-rglobal", "-rdev-cmd/irb", *ARGV
|
exec ENV["HOMEBREW_RUBY_PATH"], "-I", $LOAD_PATH.join(File::PATH_SEPARATOR), "-rglobal", "-rdev-cmd/irb", *ARGV
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,7 +65,7 @@ module Homebrew
|
|||||||
args = %W[
|
args = %W[
|
||||||
#{RUBY_PATH}
|
#{RUBY_PATH}
|
||||||
-W0
|
-W0
|
||||||
-I #{HOMEBREW_LOAD_PATH}
|
-I #{$LOAD_PATH.join(File::PATH_SEPARATOR)}
|
||||||
--
|
--
|
||||||
#{HOMEBREW_LIBRARY_PATH}/test.rb
|
#{HOMEBREW_LIBRARY_PATH}/test.rb
|
||||||
#{f.path}
|
#{f.path}
|
||||||
|
@ -729,7 +729,7 @@ class FormulaInstaller
|
|||||||
args = %W[
|
args = %W[
|
||||||
nice #{RUBY_PATH}
|
nice #{RUBY_PATH}
|
||||||
-W0
|
-W0
|
||||||
-I #{HOMEBREW_LOAD_PATH}
|
-I #{$LOAD_PATH.join(File::PATH_SEPARATOR)}
|
||||||
--
|
--
|
||||||
#{HOMEBREW_LIBRARY_PATH}/build.rb
|
#{HOMEBREW_LIBRARY_PATH}/build.rb
|
||||||
#{formula.specified_path}
|
#{formula.specified_path}
|
||||||
@ -886,7 +886,7 @@ class FormulaInstaller
|
|||||||
args = %W[
|
args = %W[
|
||||||
nice #{RUBY_PATH}
|
nice #{RUBY_PATH}
|
||||||
-W0
|
-W0
|
||||||
-I #{HOMEBREW_LOAD_PATH}
|
-I #{$LOAD_PATH.join(File::PATH_SEPARATOR)}
|
||||||
--
|
--
|
||||||
#{HOMEBREW_LIBRARY_PATH}/postinstall.rb
|
#{HOMEBREW_LIBRARY_PATH}/postinstall.rb
|
||||||
#{formula.path}
|
#{formula.path}
|
||||||
|
@ -1,4 +1,18 @@
|
|||||||
require "pathname"
|
require "pathname"
|
||||||
|
require "English"
|
||||||
|
|
||||||
|
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
|
||||||
|
|
||||||
|
unless $LOAD_PATH.include?("#{HOMEBREW_LIBRARY_PATH}/cask/lib")
|
||||||
|
$LOAD_PATH.push("#{HOMEBREW_LIBRARY_PATH}/cask/lib")
|
||||||
|
end
|
||||||
|
|
||||||
|
unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
|
||||||
|
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
|
require "config"
|
||||||
|
|
||||||
require "English"
|
require "English"
|
||||||
require "ostruct"
|
require "ostruct"
|
||||||
require "messages"
|
require "messages"
|
||||||
@ -12,7 +26,6 @@ HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"]
|
|||||||
HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"]
|
HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"]
|
||||||
HOMEBREW_WWW = "https://brew.sh".freeze
|
HOMEBREW_WWW = "https://brew.sh".freeze
|
||||||
|
|
||||||
require "config"
|
|
||||||
require "extend/git_repository"
|
require "extend/git_repository"
|
||||||
|
|
||||||
HOMEBREW_REPOSITORY.extend(GitRepositoryExtension)
|
HOMEBREW_REPOSITORY.extend(GitRepositoryExtension)
|
||||||
|
@ -14,11 +14,9 @@ require "rubocop"
|
|||||||
require "rubocop/rspec/support"
|
require "rubocop/rspec/support"
|
||||||
require "find"
|
require "find"
|
||||||
|
|
||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/cask/lib"))
|
$LOAD_PATH.push(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib"))
|
||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew"))
|
|
||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib"))
|
|
||||||
|
|
||||||
require "global"
|
require_relative "../global"
|
||||||
|
|
||||||
require "test/support/no_seed_progress_formatter"
|
require "test/support/no_seed_progress_formatter"
|
||||||
require "test/support/helper/fixtures"
|
require "test/support/helper/fixtures"
|
||||||
|
@ -83,8 +83,7 @@ RSpec.shared_context "integration test" do
|
|||||||
@ruby_args ||= begin
|
@ruby_args ||= begin
|
||||||
ruby_args = [
|
ruby_args = [
|
||||||
"-W0",
|
"-W0",
|
||||||
"-I", HOMEBREW_LOAD_PATH,
|
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR)
|
||||||
"-rconfig"
|
|
||||||
]
|
]
|
||||||
if ENV["HOMEBREW_TESTS_COVERAGE"]
|
if ENV["HOMEBREW_TESTS_COVERAGE"]
|
||||||
simplecov_spec = Gem.loaded_specs["simplecov"]
|
simplecov_spec = Gem.loaded_specs["simplecov"]
|
||||||
|
@ -13,13 +13,7 @@ TEST_TMPDIR = ENV.fetch("HOMEBREW_TEST_TMPDIR") do |k|
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Paths pointing into the Homebrew code base that persist across test runs
|
# Paths pointing into the Homebrew code base that persist across test runs
|
||||||
HOMEBREW_LIBRARY_PATH = Pathname.new(File.expand_path("../../..", __dir__))
|
|
||||||
HOMEBREW_SHIMS_PATH = HOMEBREW_LIBRARY_PATH.parent/"Homebrew/shims"
|
HOMEBREW_SHIMS_PATH = HOMEBREW_LIBRARY_PATH.parent/"Homebrew/shims"
|
||||||
HOMEBREW_LOAD_PATH = [
|
|
||||||
File.expand_path(__dir__),
|
|
||||||
HOMEBREW_LIBRARY_PATH,
|
|
||||||
HOMEBREW_LIBRARY_PATH/"cask/lib",
|
|
||||||
].join(File::PATH_SEPARATOR)
|
|
||||||
|
|
||||||
# Paths redirected to a temporary directory and wiped at the end of the test run
|
# Paths redirected to a temporary directory and wiped at the end of the test run
|
||||||
HOMEBREW_PREFIX = Pathname(TEST_TMPDIR)/"prefix"
|
HOMEBREW_PREFIX = Pathname(TEST_TMPDIR)/"prefix"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user