diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/dsl_spec.rb | 35 | ||||
-rw-r--r-- | spec/install/gemfile/platform_spec.rb | 4 | ||||
-rw-r--r-- | spec/install/gems/resolving_spec.rb | 11 | ||||
-rw-r--r-- | spec/resolver/platform_spec.rb | 96 | ||||
-rw-r--r-- | spec/runtime/platform_spec.rb | 1 | ||||
-rw-r--r-- | spec/support/indexes.rb | 4 |
6 files changed, 108 insertions, 43 deletions
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index 319472d4b0..9299c014af 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -174,41 +174,6 @@ RSpec.describe Bundler::Dsl do end end - describe "#gemspec" do - let(:spec) do - Gem::Specification.new do |gem| - gem.name = "example" - gem.platform = platform - end - end - - before do - allow(Dir).to receive(:[]).and_return(["spec_path"]) - allow(Bundler).to receive(:load_gemspec).with("spec_path").and_return(spec) - allow(Bundler).to receive(:default_gemfile).and_return(Pathname.new("./Gemfile")) - end - - context "with a ruby platform" do - let(:platform) { "ruby" } - - it "keeps track of the ruby platforms in the dependency" do - allow(Gem::Platform).to receive(:local).and_return(rb) - subject.gemspec - expect(subject.dependencies.last.platforms).to eq(Bundler::Dependency::REVERSE_PLATFORM_MAP[Gem::Platform::RUBY]) - end - end - - context "with a jruby platform" do - let(:platform) { "java" } - - it "keeps track of the jruby platforms in the dependency" do - allow(Gem::Platform).to receive(:local).and_return(java) - subject.gemspec - expect(subject.dependencies.last.platforms).to eq(Bundler::Dependency::REVERSE_PLATFORM_MAP[Gem::Platform::JAVA]) - end - end - end - context "can bundle groups of gems with" do # git "https://github.com/rails/rails.git" do # gem "railties" diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index eab5e7f00c..52e1cf86fa 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -379,8 +379,6 @@ RSpec.describe "bundle install with platform conditionals" do end it "prints a helpful warning when a dependency is unused on any platform" do - skip "prints warning but bundle install fails" if Gem.win_platform? - simulate_platform "ruby" simulate_ruby_engine "ruby" @@ -401,8 +399,6 @@ The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of t before { bundle! "config set disable_platform_warnings true" } it "does not print the warning when a dependency is unused on any platform" do - skip "skips warning but bundle install fails" if Gem.win_platform? - simulate_platform "ruby" simulate_ruby_engine "ruby" diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb index 523f9eb151..547d13134f 100644 --- a/spec/install/gems/resolving_spec.rb +++ b/spec/install/gems/resolving_spec.rb @@ -156,6 +156,13 @@ RSpec.describe "bundle install with install-time dependencies" do let(:ruby_requirement) { %("#{RUBY_VERSION}") } let(:error_message_requirement) { "~> #{RUBY_VERSION}.0" } + let(:error_message_platform) do + if Bundler.feature_flag.specific_platform? + " #{Bundler.local_platform}" + else + "" + end + end shared_examples_for "ruby version conflicts" do it "raises an error during resolution" do @@ -172,9 +179,9 @@ RSpec.describe "bundle install with install-time dependencies" do nice_error = strip_whitespace(<<-E).strip Bundler found conflicting requirements for the Ruby\0 version: In Gemfile: - Ruby\0 (#{error_message_requirement}) + Ruby\0 (#{error_message_requirement})#{error_message_platform} - require_ruby was resolved to 1.0, which depends on + require_ruby#{error_message_platform} was resolved to 1.0, which depends on Ruby\0 (> 9000) Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation diff --git a/spec/resolver/platform_spec.rb b/spec/resolver/platform_spec.rb index fee0cf1f1c..415c5458df 100644 --- a/spec/resolver/platform_spec.rb +++ b/spec/resolver/platform_spec.rb @@ -28,6 +28,98 @@ RSpec.describe "Resolving platform craziness" do end end + it "takes the latest ruby gem, even if an older platform specific version is available" do + @index = build_index do + gem "foo", "1.0.0" + gem "foo", "1.0.0", "x64-mingw32" + gem "foo", "1.1.0" + end + dep "foo" + platforms "x64-mingw32" + + should_resolve_as %w[foo-1.1.0] + end + + it "takes the ruby version if the platform version is incompatible" do + @index = build_index do + gem "bar", "1.0.0" + gem "foo", "1.0.0" + gem "foo", "1.0.0", "x64-mingw32" do + dep "bar", "< 1" + end + end + dep "foo" + platforms "x64-mingw32" + + should_resolve_as %w[foo-1.0.0] + end + + it "prefers the platform specific gem to the ruby version" do + @index = build_index do + gem "foo", "1.0.0" + gem "foo", "1.0.0", "x64-mingw32" + end + dep "foo" + platforms "x64-mingw32" + + should_resolve_as %w[foo-1.0.0-x64-mingw32] + end + + it "takes the latest ruby gem if the platform specific gem doesn't match the required_ruby_version" do + @index = build_index do + gem "foo", "1.0.0" + gem "foo", "1.0.0", "x64-mingw32" + gem "foo", "1.1.0" + gem "foo", "1.1.0", "x64-mingw32" do |s| + s.required_ruby_version = [">= 2.0", "< 2.4"] + end + gem "Ruby\0", "2.5.1" + end + dep "foo" + dep "Ruby\0", "2.5.1" + platforms "x64-mingw32" + + should_resolve_as %w[foo-1.1.0] + end + + it "takes the latest ruby gem with required_ruby_version if the platform specific gem doesn't match the required_ruby_version" do + @index = build_index do + gem "foo", "1.0.0" + gem "foo", "1.0.0", "x64-mingw32" + gem "foo", "1.1.0" do |s| + s.required_ruby_version = [">= 2.0"] + end + gem "foo", "1.1.0", "x64-mingw32" do |s| + s.required_ruby_version = [">= 2.0", "< 2.4"] + end + gem "Ruby\0", "2.5.1" + end + dep "foo" + dep "Ruby\0", "2.5.1" + platforms "x64-mingw32" + + should_resolve_as %w[foo-1.1.0] + end + + it "takes the latest ruby gem if the platform specific gem doesn't match the required_ruby_version with multiple platforms" do + @index = build_index do + gem "foo", "1.0.0" + gem "foo", "1.0.0", "x64-mingw32" + gem "foo", "1.1.0" do |s| + s.required_ruby_version = [">= 2.0"] + end + gem "foo", "1.1.0", "x64-mingw32" do |s| + s.required_ruby_version = [">= 2.0", "< 2.4"] + end + gem "Ruby\0", "2.5.1" + end + dep "foo" + dep "Ruby\0", "2.5.1" + platforms "x86_64-linux", "x64-mingw32" + + should_resolve_as %w[foo-1.1.0] + end + describe "with mingw32" do before :each do @index = build_index do @@ -90,11 +182,11 @@ RSpec.describe "Resolving platform craziness" do end end - it "reports on the conflict" do + it "takes the ruby version as fallback" do platforms "ruby", "java" dep "foo" - should_conflict_on "baz" + should_resolve_as %w[bar-1.0.0 baz-1.0.0 foo-1.0.0] end end end diff --git a/spec/runtime/platform_spec.rb b/spec/runtime/platform_spec.rb index ad9c56d14e..70c7594395 100644 --- a/spec/runtime/platform_spec.rb +++ b/spec/runtime/platform_spec.rb @@ -113,6 +113,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do bundle! "install" expect(the_bundle).to include_gems "platform_specific 1.0 RUBY" + expect(the_bundle).to not_include_gems "nokogiri" end end diff --git a/spec/support/indexes.rb b/spec/support/indexes.rb index dc6e0bd1e9..7440523fc9 100644 --- a/spec/support/indexes.rb +++ b/spec/support/indexes.rb @@ -26,6 +26,10 @@ module Spec end end source_requirements ||= {} + args[0] ||= [] # base + args[1] ||= Bundler::GemVersionPromoter.new # gem_version_promoter + args[2] ||= [] # additional_base_requirements + args[3] ||= @platforms # platforms Bundler::Resolver.resolve(deps, @index, source_requirements, *args) end |