aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2017-07-10 07:51:04 +0100
committerMike McQuaid2017-07-10 07:51:04 +0100
commitcabb7e898aaf56404bc692b4cfae5ede7914f78c (patch)
treebc6c5b85f3db3ca08d8fa1aa7d45e625da0fe7b7 /Library
parentcb3a47d9e24fadfacaa304b7788f22d1851d57cd (diff)
downloadbrew-cabb7e898aaf56404bc692b4cfae5ede7914f78c.tar.bz2
integration_test: add simplecov libs when needed.
Don't add these unconditionally or with Bundler to speed things up a bit. Also, to speed things up further cache these arguments so we don't have to do the same generation every time.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb36
1 files changed, 26 insertions, 10 deletions
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 f688ef8e5..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
@@ -80,18 +80,34 @@ RSpec.shared_context "integration test" do
"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
+ @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, stderr, status = Open3.capture3(env, RUBY_PATH, *@ruby_args, *args)
$stdout.print stdout
$stderr.print stderr
status