diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-02-18 20:18:26 -0800 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-02-18 22:17:53 -0800 |
commit | 3e2ac90ca0213a0b9025c26052a49f1ffa767dfb (patch) | |
tree | 0983574c8a7bd667b539e0fd57f8b6a72204eb48 | |
parent | 42215fe7279bd90d48f2d4e09227d327e007b5bc (diff) | |
download | bundler-seg-stub-specification-missing-extensions.tar.gz |
[StubSpecification] Avoid loading all installed gemspecsseg-stub-specification-missing-extensions
Call through to the stub instead of materializing the full remote_spec since all gems added to the local index are asked whether they are missing extensions or not
-rw-r--r-- | lib/bundler/stub_specification.rb | 7 | ||||
-rw-r--r-- | spec/runtime/setup_spec.rb | 28 |
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb index f4ee7d0644..cbcadee269 100644 --- a/lib/bundler/stub_specification.rb +++ b/lib/bundler/stub_specification.rb @@ -15,6 +15,13 @@ module Bundler _remote_specification.to_yaml end + if Bundler.rubygems.provides?(">= 2.3") + # This is defined directly to avoid having to load every installed spec + def missing_extensions? + stub.missing_extensions? + end + end + private def _remote_specification diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index f5b74833be..be0c7a1593 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -673,6 +673,34 @@ RSpec.describe "Bundler.setup" do expect(out).to be_empty end + it "does not load all gemspecs", :rubygems => ">= 2.3" do + install_gemfile! <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + run! <<-R + File.open(File.join(Gem.dir, "specifications", "broken.gemspec"), "w") do |f| + f.write <<-RUBY +# -*- encoding: utf-8 -*- +# stub: broken 1.0.0 ruby lib + +Gem::Specification.new do |s| + s.name = "broken" + s.version = "1.0.0" + raise "BROKEN GEMSPEC" +end + RUBY + end + R + + run! <<-R + puts "WIN" + R + + expect(out).to eq("WIN") + end + it "ignores empty gem paths" do install_gemfile <<-G source "file://#{gem_repo1}" |