Fix usage of HOMEBREW_LOAD_PATH.

This commit is contained in:
Markus Reiter 2018-06-13 07:35:04 +02:00
parent 1d629c6978
commit 18e46b3ec2
6 changed files with 16 additions and 10 deletions

View File

@ -16,14 +16,15 @@ require "pathname"
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
require "English"
unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
$LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s)
end
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

View File

@ -47,4 +47,7 @@ unless defined? HOMEBREW_LIBRARY_PATH
end
# Load path used by standalone scripts to access the Homebrew code base
HOMEBREW_LOAD_PATH = HOMEBREW_LIBRARY_PATH
HOMEBREW_LOAD_PATH = [
HOMEBREW_LIBRARY_PATH,
HOMEBREW_LIBRARY_PATH/"cask/lib",
].join(File::PATH_SEPARATOR)

View File

@ -8,6 +8,6 @@ module Homebrew
module_function
def ruby
exec ENV["HOMEBREW_RUBY_PATH"], "-I#{HOMEBREW_LIBRARY_PATH}", "-rglobal", "-rdev-cmd/irb", *ARGV
exec ENV["HOMEBREW_RUBY_PATH"], "-I", HOMEBREW_LOAD_PATH, "-rglobal", "-rdev-cmd/irb", *ARGV
end
end

View File

@ -14,8 +14,8 @@ require "rubocop"
require "rubocop/rspec/support"
require "find"
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew"))
$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"))
require "global"

View File

@ -83,9 +83,7 @@ RSpec.shared_context "integration test" do
@ruby_args ||= begin
ruby_args = [
"-W0",
"-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib",
"-I", HOMEBREW_LIBRARY_PATH.to_s,
"-I", "#{HOMEBREW_LIBRARY_PATH}/cask/lib",
"-I", HOMEBREW_LOAD_PATH,
"-rconfig"
]
if ENV["HOMEBREW_TESTS_COVERAGE"]

View File

@ -15,7 +15,11 @@ 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].join(":")
HOMEBREW_LOAD_PATH = [
File.expand_path(__dir__),
HOMEBREW_LIBRARY_PATH,
HOMEBREW_LIBRARY_PATH.join("cask/lib"),
].join(File::PATH_SEPARATOR)
# Paths redirected to a temporary directory and wiped at the end of the test run
HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix")