diff options
author | Homu <homu@barosl.com> | 2016-08-23 10:56:35 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-08-23 10:56:35 +0900 |
commit | 799f045c4aa8572fefd8250025e59365340612b9 (patch) | |
tree | 4e195919ee57584fd0c8a97caab4610df97f2bc3 | |
parent | cb24b6d43f8923c487afb5368e06fd3c2249cf8d (diff) | |
parent | ac51bf9515f07697d39d6184bfc5f6f615d74fc2 (diff) | |
download | bundler-799f045c4aa8572fefd8250025e59365340612b9.tar.gz |
Auto merge of #4897 - bundler:seg-lock-platform, r=indirect
[Resolver] Ensure all platforms are activated for the activated spec group
Closes #4896
-rw-r--r-- | lib/bundler/definition.rb | 3 | ||||
-rw-r--r-- | lib/bundler/resolver.rb | 8 | ||||
-rw-r--r-- | spec/commands/lock_spec.rb | 91 | ||||
-rw-r--r-- | spec/support/matchers.rb | 6 |
4 files changed, 99 insertions, 9 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 2d328e0de1..e1826746ff 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -816,7 +816,8 @@ module Bundler def additional_base_requirements_for_resolve return [] unless @locked_gems && Bundler.settings[:only_update_to_newer_versions] @locked_gems.specs.reduce({}) do |requirements, locked_spec| - requirements[locked_spec.name] = Gem::Dependency.new(locked_spec.name, ">= #{locked_spec.version}") + dep = Gem::Dependency.new(locked_spec.name, ">= #{locked_spec.version}") + requirements[locked_spec.name] = DepProxy.new(dep, locked_spec.platform) requirements end.values end diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 10d5404028..e1d993831f 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -189,7 +189,10 @@ module Bundler @resolver = Molinillo::Resolver.new(self, self) @search_for = {} @base_dg = Molinillo::DependencyGraph.new - @base.each {|ls| @base_dg.add_vertex(ls.name, Dependency.new(ls.name, ls.version), true) } + @base.each do |ls| + dep = Dependency.new(ls.name, ls.version) + @base_dg.add_vertex(ls.name, DepProxy.new(dep, ls.platform), true) + end additional_base_requirements.each {|d| @base_dg.add_vertex(d.name, d) } @ruby_version = ruby_version @gem_version_promoter = gem_version_promoter @@ -303,7 +306,8 @@ module Bundler end def requirement_satisfied_by?(requirement, activated, spec) - requirement.matches_spec?(spec) || spec.source.is_a?(Source::Gemspec) + return false unless requirement.matches_spec?(spec) || spec.source.is_a?(Source::Gemspec) + spec.activate_platform!(requirement.__platform) || spec.for?(requirement.__platform, nil) end def sort_dependencies(dependencies, activated, conflicts) diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index 1e189a9659..fc605dc5a6 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -132,4 +132,95 @@ describe "bundle lock" do bundle "lock --remove-platform #{local}" expect(out).to include("Removing all platforms from the bundle is not allowed") end + + # from https://github.com/bundler/bundler/issues/4896 + it "properly adds platforms when platform requirements come from different dependencies" do + build_repo4 do + build_gem "ffi", "1.9.14" + build_gem "ffi", "1.9.14" do |s| + s.platform = mingw + end + + build_gem "gssapi", "0.1" + build_gem "gssapi", "0.2" + build_gem "gssapi", "0.3" + build_gem "gssapi", "1.2.0" do |s| + s.add_dependency "ffi", ">= 1.0.1" + end + + build_gem "mixlib-shellout", "2.2.6" + build_gem "mixlib-shellout", "2.2.6" do |s| + s.platform = "universal-mingw32" + s.add_dependency "win32-process", "~> 0.8.2" + end + + # we need all these versions to get the sorting the same as it would be + # pulling from rubygems.org + %w(0.8.3 0.8.2 0.8.1 0.8.0).each do |v| + build_gem "win32-process", v do |s| + s.add_dependency "ffi", ">= 1.0.0" + end + end + end + + gemfile <<-G + source "file:#{gem_repo4}" + + gem "mixlib-shellout" + gem "gssapi" + G + + simulate_platform(mingw) { bundle! :lock } + + expect(the_bundle.lockfile).to read_as(strip_whitespace(<<-G)) + GEM + remote: file:#{gem_repo4}/ + specs: + ffi (1.9.14-x86-mingw32) + gssapi (1.2.0) + ffi (>= 1.0.1) + mixlib-shellout (2.2.6-universal-mingw32) + win32-process (~> 0.8.2) + win32-process (0.8.3) + ffi (>= 1.0.0) + + PLATFORMS + x86-mingw32 + + DEPENDENCIES + gssapi + mixlib-shellout + + BUNDLED WITH + #{Bundler::VERSION} + G + + simulate_platform(rb) { bundle! :lock } + + expect(the_bundle.lockfile).to read_as(strip_whitespace(<<-G)) + GEM + remote: file:#{gem_repo4}/ + specs: + ffi (1.9.14) + ffi (1.9.14-x86-mingw32) + gssapi (1.2.0) + ffi (>= 1.0.1) + mixlib-shellout (2.2.6) + mixlib-shellout (2.2.6-universal-mingw32) + win32-process (~> 0.8.2) + win32-process (0.8.3) + ffi (>= 1.0.0) + + PLATFORMS + ruby + x86-mingw32 + + DEPENDENCIES + gssapi + mixlib-shellout + + BUNDLED WITH + #{Bundler::VERSION} + G + end end diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 9476f18984..9248360639 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -110,15 +110,9 @@ module Spec define_compound_matcher :read_as, [exist] do |file_contents| diffable - attr_reader :strip_whitespace - - chain :stripping_whitespace do - @strip_whitespace = true - end match do |actual| @actual = Bundler.read_file(actual) - file_contents = strip_whitespace(file_contents) if strip_whitespace values_match?(file_contents, @actual) end end |