diff options
author | Carl Lerche <carllerche@mac.com> | 2010-06-05 18:12:23 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-06-05 18:12:23 -0700 |
commit | 4388ce09a3e96eacb87bf9663115df4aa395acbe (patch) | |
tree | 9d49c50d6a24304ba152c9d4db29f4dbd9e14922 | |
parent | 666c369fc0924fdf45cf73e3611402a6bfe0d235 (diff) | |
download | bundler-4388ce09a3e96eacb87bf9663115df4aa395acbe.tar.gz |
Fix more platform resolving bugs
-rw-r--r-- | lib/bundler/definition.rb | 4 | ||||
-rw-r--r-- | lib/bundler/resolver.rb | 3 | ||||
-rw-r--r-- | spec/install/gems/platform_spec.rb | 60 | ||||
-rw-r--r-- | spec/support/builders.rb | 9 | ||||
-rw-r--r-- | spec/support/helpers.rb | 5 | ||||
-rw-r--r-- | spec/support/matchers.rb | 9 |
6 files changed, 82 insertions, 8 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index b6f4eb8d12..3a6626ec10 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -159,9 +159,7 @@ module Bundler converged = [] @last_resolve.each do |s| - if source = @sources.find { |src| s.source == src } - s.source = source - end + s.source = @sources.find { |src| s.source == src } next if s.source.nil? || @unlock[:sources].include?(s.name) diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 577cc223e2..3e2bc891eb 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -356,7 +356,8 @@ module Bundler end index = @source_requirements[d.name] || @index - results = index.search_for_all_platforms(d) + results + # results = index.search_for_all_platforms(d) + results + results += index.search_for_all_platforms(d) if results.any? version = results.first.version diff --git a/spec/install/gems/platform_spec.rb b/spec/install/gems/platform_spec.rb index 01e8960a1e..01409ed1ef 100644 --- a/spec/install/gems/platform_spec.rb +++ b/spec/install/gems/platform_spec.rb @@ -23,4 +23,64 @@ describe "bundle install across platforms" do should_be_installed "rack 0.9.1" end + + it "pulls in the correct platform specific gem" do + lockfile <<-G + GEM + remote: file:#{gem_repo1} + specs: + platform_specific (1.0) + + PLATFORMS + ruby + + DEPENDENCIES + platform_specific + G + + install_gemfile <<-G + Gem.platforms = [Gem::Platform::RUBY, Gem::Platform.new('#{java}')] + source "file://#{gem_repo1}" + + gem "platform_specific" + G + + should_be_installed "platform_specific 1.0 JAVA" + end + + it "works with gems that have different dependencies" do + lockfile <<-G + GEM + remote: file:#{gem_repo1} + specs: + nokogiri (1.4.2) + + PLATFORMS + ruby + + DEPENDENCIES + platform_specific + G + + install_gemfile <<-G + Gem.platforms = [Gem::Platform::RUBY, Gem::Platform.new('#{java}')] + source "file://#{gem_repo1}" + + gem "nokogiri" + G + + should_be_installed "nokogiri 1.4.2 JAVA", "weakling 0.0.3" + + simulate_new_machine + + install_gemfile <<-G + Gem.platforms = [Gem::Platform::RUBY] + source "file://#{gem_repo1}" + + gem "nokogiri" + G + + should_be_installed "nokogiri 1.4.2" + should_not_be_installed "weakling" + end end
\ No newline at end of file diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 4974dd5206..8f3968a728 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -96,6 +96,15 @@ module Spec s.platform = "java" end + build_gem "nokogiri", "1.4.2" + build_gem "nokogiri", "1.4.2" do |s| + s.platform = "java" + s.write "lib/nokogiri.rb", "NOKOGIRI = '1.4.2 JAVA'" + s.add_dependency "weakling", ">= 0.0.3" + end + + build_gem "weakling", "0.0.3" + build_gem "not_released", "1.0.pre" build_gem "has_prerelease", "1.0" diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index ecba26d7dc..a667ccfb3c 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -29,11 +29,14 @@ module Spec opts = args.last.is_a?(Hash) ? args.pop : {} expect_err = opts.delete(:expect_err) groups = args.map {|a| a.inspect }.join(", ") + platform = opts[:platform] if opts[:lite_runtime] setup = "require 'rubygems' ; require 'bundler/setup' ; Bundler.setup(#{groups})\n" else - setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n" + setup = "require 'rubygems' ; " + setup << "Gem.platforms = [Gem::Platform::RUBY, Gem::Platform.new('#{platform}')] ; " if platform + setup = "require 'bundler' ; Bundler.setup(#{groups})\n" end @out = ruby(setup + cmd, :expect_err => expect_err) diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 441352f890..c70522c3c9 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -27,11 +27,14 @@ module Spec def should_be_installed(*names) opts = names.last.is_a?(Hash) ? names.pop : {} - groups = opts[:groups] || [] + groups = Array(opts[:groups]) + groups << opts names.each do |name| - name, version = name.split(/\s+/) + name, version, platform = name.split(/\s+/) run "load '#{name}.rb'; puts #{Spec::Builders.constantize(name)}", *groups - Gem::Version.new(out).should == Gem::Version.new(version) + actual_version, actual_platform = out.split(/\s+/) + Gem::Version.new(actual_version).should == Gem::Version.new(version) + platform.should == actual_platform end end |