summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-07-22 16:08:23 +0000
committerThe Bundler Bot <bot@bundler.io>2018-07-22 16:08:23 +0000
commit7b603f39e32a466cb1a8235a963968b2103e665e (patch)
treed9efdc2eb32a7f3785e90c0e87cb259ebc276569 /spec
parentccb1bf0d8fa3dcf8da8a3d57f5a524ca027d9cdb (diff)
parente2e8e5aec2edd9d7508306f72fad1a5312c3bfaf (diff)
downloadbundler-7b603f39e32a466cb1a8235a963968b2103e665e.tar.gz
Auto merge of #6495 - bundler:segiddins/6491-extra-gem-platform-in-lockfile, r=segiddins
[Definition] Filter out unneeded gem platforms after resolving ### What was the end-user problem that led to this PR? The problem was the lockfile would contain platform-specific gems that it didn't need Closes https://github.com/bundler/bundler/issues/6491 ### What was your diagnosis of the problem? My diagnosis was the resolver sometimes activates platforms it doesn't need, since it can't know it won't need them ### What is your fix for the problem, implemented in this PR? My fix is to use `SpecSet#for` to filter out gems that won't ever be used ### Why did you choose this fix out of the possible options? I chose this fix because it isn't re-inventing the wheel!
Diffstat (limited to 'spec')
-rw-r--r--spec/install/gemfile/platform_spec.rb143
1 files changed, 143 insertions, 0 deletions
diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb
index 43374b0f8a..6c226eb29f 100644
--- a/spec/install/gemfile/platform_spec.rb
+++ b/spec/install/gemfile/platform_spec.rb
@@ -73,6 +73,149 @@ RSpec.describe "bundle install across platforms" do
expect(the_bundle).not_to include_gems "weakling"
end
+ it "does not keep unneeded platforms for gems that are used" do
+ build_repo4 do
+ build_gem "empyrean", "0.1.0"
+ build_gem "coderay", "1.1.2"
+ build_gem "method_source", "0.9.0"
+ build_gem("spoon", "0.0.6") {|s| s.add_runtime_dependency "ffi" }
+ build_gem "pry", "0.11.3" do |s|
+ s.platform = "java"
+ s.add_runtime_dependency "coderay", "~> 1.1.0"
+ s.add_runtime_dependency "method_source", "~> 0.9.0"
+ s.add_runtime_dependency "spoon", "~> 0.0"
+ end
+ build_gem "pry", "0.11.3" do |s|
+ s.add_runtime_dependency "coderay", "~> 1.1.0"
+ s.add_runtime_dependency "method_source", "~> 0.9.0"
+ end
+ build_gem("ffi", "1.9.23") {|s| s.platform = "java" }
+ build_gem("ffi", "1.9.23")
+ end
+
+ simulate_platform java
+
+ install_gemfile! <<-G
+ source "file://localhost/#{gem_repo4}"
+
+ gem "empyrean", "0.1.0"
+ gem "pry"
+ G
+
+ expect(the_bundle.lockfile).to read_as strip_whitespace(<<-L)
+ GEM
+ remote: file://localhost/#{gem_repo4}/
+ specs:
+ coderay (1.1.2)
+ empyrean (0.1.0)
+ ffi (1.9.23-java)
+ method_source (0.9.0)
+ pry (0.11.3-java)
+ coderay (~> 1.1.0)
+ method_source (~> 0.9.0)
+ spoon (~> 0.0)
+ spoon (0.0.6)
+ ffi
+
+ PLATFORMS
+ java
+
+ DEPENDENCIES
+ empyrean (= 0.1.0)
+ pry
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ bundle! "lock --add-platform ruby"
+
+ good_lockfile = strip_whitespace(<<-L)
+ GEM
+ remote: file://localhost/#{gem_repo4}/
+ specs:
+ coderay (1.1.2)
+ empyrean (0.1.0)
+ ffi (1.9.23-java)
+ method_source (0.9.0)
+ pry (0.11.3)
+ coderay (~> 1.1.0)
+ method_source (~> 0.9.0)
+ pry (0.11.3-java)
+ coderay (~> 1.1.0)
+ method_source (~> 0.9.0)
+ spoon (~> 0.0)
+ spoon (0.0.6)
+ ffi
+
+ PLATFORMS
+ java
+ ruby
+
+ DEPENDENCIES
+ empyrean (= 0.1.0)
+ pry
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ expect(the_bundle.lockfile).to read_as good_lockfile
+
+ bad_lockfile = strip_whitespace <<-L
+ GEM
+ remote: file://localhost/#{gem_repo4}/
+ specs:
+ coderay (1.1.2)
+ empyrean (0.1.0)
+ ffi (1.9.23)
+ ffi (1.9.23-java)
+ method_source (0.9.0)
+ pry (0.11.3)
+ coderay (~> 1.1.0)
+ method_source (~> 0.9.0)
+ pry (0.11.3-java)
+ coderay (~> 1.1.0)
+ method_source (~> 0.9.0)
+ spoon (~> 0.0)
+ spoon (0.0.6)
+ ffi
+
+ PLATFORMS
+ java
+ ruby
+
+ DEPENDENCIES
+ empyrean (= 0.1.0)
+ pry
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ aggregate_failures do
+ lockfile bad_lockfile
+ bundle! :install
+ expect(the_bundle.lockfile).to read_as good_lockfile
+
+ lockfile bad_lockfile
+ bundle! :update, :all => true
+ expect(the_bundle.lockfile).to read_as good_lockfile
+
+ lockfile bad_lockfile
+ bundle! "update ffi"
+ expect(the_bundle.lockfile).to read_as good_lockfile
+
+ lockfile bad_lockfile
+ bundle! "update empyrean"
+ expect(the_bundle.lockfile).to read_as good_lockfile
+
+ lockfile bad_lockfile
+ bundle! :lock
+ expect(the_bundle.lockfile).to read_as good_lockfile
+ end
+ end
+
it "works the other way with gems that have different dependencies" do
simulate_platform "ruby"
install_gemfile <<-G