Skip to content
Snippets Groups Projects
Commit 5841b992 authored by Markus Reiter's avatar Markus Reiter
Browse files

Refactor `$LOAD_PATH`.

parent e4f46872
No related branches found
No related tags found
No related merge requests found
......@@ -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}."
end
require "pathname"
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"
require_relative "global"
begin
trap("INT", std_trap) # restore default CTRL-C handler
......
......@@ -46,14 +46,3 @@ HOMEBREW_TEMP = begin
tmp.mkpath unless tmp.exist?
tmp.realpath
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
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
......@@ -65,7 +65,7 @@ module Homebrew
args = %W[
#{RUBY_PATH}
-W0
-I #{HOMEBREW_LOAD_PATH}
-I #{$LOAD_PATH.join(File::PATH_SEPARATOR)}
--
#{HOMEBREW_LIBRARY_PATH}/test.rb
#{f.path}
......
......@@ -729,7 +729,7 @@ class FormulaInstaller
args = %W[
nice #{RUBY_PATH}
-W0
-I #{HOMEBREW_LOAD_PATH}
-I #{$LOAD_PATH.join(File::PATH_SEPARATOR)}
--
#{HOMEBREW_LIBRARY_PATH}/build.rb
#{formula.specified_path}
......@@ -886,7 +886,7 @@ class FormulaInstaller
args = %W[
nice #{RUBY_PATH}
-W0
-I #{HOMEBREW_LOAD_PATH}
-I #{$LOAD_PATH.join(File::PATH_SEPARATOR)}
--
#{HOMEBREW_LIBRARY_PATH}/postinstall.rb
#{formula.path}
......
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 "ostruct"
require "messages"
......@@ -12,7 +26,6 @@ HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"]
HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"]
HOMEBREW_WWW = "https://brew.sh".freeze
require "config"
require "extend/git_repository"
HOMEBREW_REPOSITORY.extend(GitRepositoryExtension)
......
......@@ -14,11 +14,9 @@ require "rubocop"
require "rubocop/rspec/support"
require "find"
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/cask/lib"))
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew"))
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib"))
$LOAD_PATH.push(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/helper/fixtures"
......
......@@ -83,8 +83,7 @@ RSpec.shared_context "integration test" do
@ruby_args ||= begin
ruby_args = [
"-W0",
"-I", HOMEBREW_LOAD_PATH,
"-rconfig"
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR)
]
if ENV["HOMEBREW_TESTS_COVERAGE"]
simplecov_spec = Gem.loaded_specs["simplecov"]
......
......@@ -13,13 +13,7 @@ TEST_TMPDIR = ENV.fetch("HOMEBREW_TEST_TMPDIR") do |k|
end
# 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_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
HOMEBREW_PREFIX = Pathname(TEST_TMPDIR)/"prefix"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment