aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2017-07-10 08:18:17 +0100
committerGitHub2017-07-10 08:18:17 +0100
commit287ba7a6afe12f36b90cddfc337246541d814d72 (patch)
tree494bb9db7a6a61bcaa93dab977b1919027617b27
parent4cb839132d75ab3342579de47bdc40d98cdf7076 (diff)
parentcabb7e898aaf56404bc692b4cfae5ede7914f78c (diff)
downloadbrew-287ba7a6afe12f36b90cddfc337246541d814d72.tar.bz2
Merge pull request #2872 from MikeMcQuaid/fix-high-sierra-tests
Fix `brew tests` on High Sierra.
-rw-r--r--Library/Homebrew/brew.rb4
-rw-r--r--Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb41
2 files changed, 32 insertions, 13 deletions
diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb
index 11ea8df67..ec86bd794 100644
--- a/Library/Homebrew/brew.rb
+++ b/Library/Homebrew/brew.rb
@@ -11,7 +11,9 @@ raise "Homebrew must be run under Ruby 2!" unless RUBY_TWO
require "pathname"
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
require "English"
-$LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s)
+unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
+ $LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s)
+end
require "global"
require "tap"
diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
index ae1854f58..94a47acc5 100644
--- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
+++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb
@@ -77,20 +77,37 @@ RSpec.shared_context "integration test" do
"HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args),
"HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
"HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"],
+ "GEM_HOME" => nil,
)
- ruby_args = [
- "-W0",
- "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib",
- "-I", HOMEBREW_LIBRARY_PATH.to_s,
- "-rconfig"
- ]
- ruby_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
- ruby_args << "-rtest/support/helper/integration_mocks"
- ruby_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s
-
- Bundler.with_original_env do
- stdout, stderr, status = Open3.capture3(env, RUBY_PATH, *ruby_args, *args)
+ @ruby_args ||= begin
+ ruby_args = [
+ "-W0",
+ "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib",
+ "-I", HOMEBREW_LIBRARY_PATH.to_s,
+ "-rconfig"
+ ]
+ if ENV["HOMEBREW_TESTS_COVERAGE"]
+ simplecov_spec = Gem.loaded_specs["simplecov"]
+ specs = simplecov_spec.runtime_dependencies.flat_map(&:to_specs)
+ specs << simplecov_spec
+ libs = specs.flat_map do |spec|
+ full_gem_path = spec.full_gem_path
+ # full_require_paths isn't available in RubyGems < 2.2.
+ spec.require_paths.map do |lib|
+ next lib if lib.include?(full_gem_path)
+ "#{full_gem_path}/#{lib}"
+ end
+ end
+ libs.each { |lib| ruby_args << "-I" << lib }
+ ruby_args << "-rsimplecov"
+ end
+ ruby_args << "-rtest/support/helper/integration_mocks"
+ ruby_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s
+ end
+
+ Bundler.with_clean_env do
+ stdout, stderr, status = Open3.capture3(env, RUBY_PATH, *@ruby_args, *args)
$stdout.print stdout
$stderr.print stderr
status