diff options
author | Homu <homu@barosl.com> | 2016-07-26 10:38:26 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-07-26 10:38:26 +0900 |
commit | f26eec76ed6356a53a09a2e34f3552366b6c7d8b (patch) | |
tree | 3abff2110dca8997fef6883dadb525420603af03 /spec | |
parent | 4e85e96cacf5406a801ae8ce04c646a8bd4906a5 (diff) | |
parent | 3050ab317bbfc127b38e165fba8257e3015a0ffe (diff) | |
download | bundler-f26eec76ed6356a53a09a2e34f3552366b6c7d8b.tar.gz |
Auto merge of #4800 - bundler:seg-locked-resolve-keep-platforms, r=indirect
[Definition] Ensure gemspec dependencies include all lockfile platforms
Closes #4798
This is necessary since `gemspec` declares platforms for the dependency as the reverse platform map of the generic local platform, thus missing out on all those platforms that aren't currently being resolved for
Diffstat (limited to 'spec')
-rw-r--r-- | spec/commands/package_spec.rb | 2 | ||||
-rw-r--r-- | spec/install/gemfile/gemspec_spec.rb | 146 | ||||
-rw-r--r-- | spec/install/gemfile/path_spec.rb | 2 | ||||
-rw-r--r-- | spec/support/builders.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers.rb | 1 |
5 files changed, 149 insertions, 4 deletions
diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb index 9c722b3491..83b56f304e 100644 --- a/spec/commands/package_spec.rb +++ b/spec/commands/package_spec.rb @@ -127,7 +127,7 @@ describe "bundle package" do source "file://#{gem_repo1}" gem 'rack' gemspec :name => 'mygem' - gemspec :name => 'mygem_client' + gemspec :name => 'mygem_test' D bundle! "package --all" diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb index f860f55f13..454dbcf8c2 100644 --- a/spec/install/gemfile/gemspec_spec.rb +++ b/spec/install/gemfile/gemspec_spec.rb @@ -67,7 +67,7 @@ describe "bundle install from an existing gemspec" do it "should raise if there are too many gemspecs available" do build_lib("foo", :path => tmp.join("foo")) do |s| - s.write("foo2.gemspec", "") + s.write("foo2.gemspec", build_spec("foo", "4.0").first.to_ruby) end error = install_gemfile(<<-G, :expect_err => true) @@ -196,7 +196,17 @@ describe "bundle install from an existing gemspec" do before do build_lib("foo", :path => tmp.join("foo")) do |s| s.add_dependency "rack", "=1.0.0" - s.platform = platform if explicit_platform + end + + if explicit_platform + create_file( + tmp.join("foo", "foo-#{platform}.gemspec"), + build_spec("foo", "1.0", platform) do + dep "rack", "=1.0.0" + @spec.authors = "authors" + @spec.summary = "summary" + end.first.to_ruby + ) end gemfile <<-G @@ -266,5 +276,137 @@ describe "bundle install from an existing gemspec" do end end end + + context "bundled for ruby and jruby" do + let(:platform_specific_type) { :runtime } + let(:dependency) { "platform_specific" } + before do + build_repo2 do + build_gem "indirect_platform_specific" do |s| + s.add_runtime_dependency "platform_specific" + end + end + + build_lib "foo", :path => "." do |s| + if platform_specific_type == :runtime + s.add_runtime_dependency dependency + elsif platform_specific_type == :development + s.add_development_dependency dependency + else + raise "wrong dependency type #{platform_specific_type}, can only be :development or :runtime" + end + end + + %w(ruby jruby).each do |platform| + simulate_platform(platform) do + install_gemfile <<-G + source "file://#{gem_repo2}" + gemspec + G + end + end + end + + context "on ruby" do + before do + simulate_platform("ruby") + bundle :install + end + + context "as a runtime dependency" do + it "keeps java dependencies in the lockfile" do + should_be_installed "foo 1.0", "platform_specific 1.0 RUBY" + expect(lockfile).to eq strip_whitespace(<<-L) + PATH + remote: . + specs: + foo (1.0) + platform_specific + + GEM + remote: file:#{gem_repo2}/ + specs: + platform_specific (1.0) + platform_specific (1.0-java) + + PLATFORMS + java + ruby + + DEPENDENCIES + foo! + + BUNDLED WITH + #{Bundler::VERSION} + L + end + end + + context "as a development dependency" do + let(:platform_specific_type) { :development } + + it "keeps java dependencies in the lockfile" do + should_be_installed "foo 1.0", "platform_specific 1.0 RUBY" + expect(lockfile).to eq strip_whitespace(<<-L) + PATH + remote: . + specs: + foo (1.0) + + GEM + remote: file:#{gem_repo2}/ + specs: + platform_specific (1.0) + platform_specific (1.0-java) + + PLATFORMS + java + ruby + + DEPENDENCIES + foo! + platform_specific + + BUNDLED WITH + #{Bundler::VERSION} + L + end + end + + context "with an indirect platform-specific development dependency" do + let(:platform_specific_type) { :development } + let(:dependency) { "indirect_platform_specific" } + + it "keeps java dependencies in the lockfile" do + should_be_installed "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY" + expect(lockfile).to eq strip_whitespace(<<-L) + PATH + remote: . + specs: + foo (1.0) + + GEM + remote: file:#{gem_repo2}/ + specs: + indirect_platform_specific (1.0) + platform_specific + platform_specific (1.0) + platform_specific (1.0-java) + + PLATFORMS + java + ruby + + DEPENDENCIES + foo! + indirect_platform_specific + + BUNDLED WITH + #{Bundler::VERSION} + L + end + end + end + end end end diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index 9f2893a01c..d3910748cc 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -241,7 +241,7 @@ describe "bundle install with explicit source paths" do it "raises if there are multiple gemspecs" do build_lib "foo", "1.0", :path => lib_path("foo") do |s| - s.write "bar.gemspec" + s.write "bar.gemspec", build_spec("bar", "1.0").first.to_ruby end install_gemfile <<-G diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 3c10cba757..6ed3a2904e 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -395,6 +395,8 @@ module Spec s.name = name s.version = Gem::Version.new(v) s.platform = platform + s.authors = ["no one in particular"] + s.summary = "a gemspec used only for testing" DepBuilder.run(s, &block) if block_given? end end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 0293f08716..0d2338df90 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -217,6 +217,7 @@ module Spec opts[:retry] ||= 0 bundle :install, opts end + bang :install_gemfile def lock_gemfile(*args) gemfile(*args) |