From 339227363ce0cf967fa17efa4489d823932ddabd Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 23 Dec 2020 08:45:19 +0900 Subject: Merge RubyGems 3.2.3 and Bundler 2.2.3 --- spec/bundler/commands/exec_spec.rb | 26 +++++++++++ spec/bundler/commands/install_spec.rb | 43 ++++++++++++++++++ spec/bundler/commands/lock_spec.rb | 84 +++++++++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+) (limited to 'spec/bundler/commands') diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index 85f8ceef62..1449bb642e 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -67,6 +67,32 @@ RSpec.describe "bundle exec" do expect(out).to eq(Gem::VERSION) end + it "works when exec'ing back to bundler with a lockfile that doesn't include the current platform" do + install_gemfile <<-G + gem "rack", "0.9.1" + G + + # simulate lockfile generated with old version not including specific platform + lockfile <<-L + GEM + specs: + rack (0.9.1) + + PLATFORMS + RUBY + + DEPENDENCIES + rack (= 0.9.1) + + BUNDLED WITH + 2.1.4 + L + + bundle "exec bundle cache", :env => { "BUNDLER_VERSION" => Bundler::VERSION } + + expect(out).to include("Updating files in vendor/cache") + end + it "respects custom process title when loading through ruby" do skip "https://github.com/rubygems/rubygems/issues/3351" if Gem.win_platform? diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index a8b174a547..043805df79 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -630,4 +630,47 @@ RSpec.describe "bundle install with gem sources" do "setting them for authentication.") end end + + context "in a frozen bundle" do + before do + build_repo4 do + build_gem "libv8", "8.4.255.0" do |s| + s.platform = "x86_64-darwin-19" + end + end + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + + gem "libv8" + G + + lockfile <<-L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + libv8 (8.4.255.0-x86_64-darwin-19) + + PLATFORMS + x86_64-darwin-19 + + DEPENDENCIES + libv8 + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "config set --local deployment true" + end + + it "should fail loudly if the lockfile platforms don't include the current platform" do + simulate_platform(Gem::Platform.new("x86_64-linux")) { bundle "install", :raise_on_error => false } + + expect(err).to eq( + "Your bundle only supports platforms [\"x86_64-darwin-19\"] but your local platform is x86_64-linux. " \ + "Add the current platform to the lockfile with `bundle lock --add-platform x86_64-linux` and try again." + ) + end + end end diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index 6400152039..afc3b03a53 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -383,6 +383,90 @@ RSpec.describe "bundle lock" do expect(out).to match(/Writing lockfile to.+Gemfile\.lock/) end + it "adds all more specific candidates when they all have the same dependencies" do + build_repo4 do + build_gem "libv8", "8.4.255.0" do |s| + s.platform = "x86_64-darwin-19" + end + + build_gem "libv8", "8.4.255.0" do |s| + s.platform = "x86_64-darwin-20" + end + end + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + + gem "libv8" + G + + simulate_platform(Gem::Platform.new("x86_64-darwin")) { bundle "lock" } + + lockfile_should_be <<-G + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + libv8 (8.4.255.0-x86_64-darwin-19) + libv8 (8.4.255.0-x86_64-darwin-20) + + PLATFORMS + x86_64-darwin + + DEPENDENCIES + libv8 + + BUNDLED WITH + #{Bundler::VERSION} + G + end + + it "respects the previous lockfile if it had a matching less specific platform already locked, and installs the best variant for each platform" do + build_repo4 do + build_gem "libv8", "8.4.255.0" do |s| + s.platform = "x86_64-darwin-19" + end + + build_gem "libv8", "8.4.255.0" do |s| + s.platform = "x86_64-darwin-20" + end + end + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + + gem "libv8" + G + + lockfile <<-G + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + libv8 (8.4.255.0-x86_64-darwin-19) + libv8 (8.4.255.0-x86_64-darwin-20) + + PLATFORMS + x86_64-darwin + + DEPENDENCIES + libv8 + + BUNDLED WITH + #{Bundler::VERSION} + G + + previous_lockfile = lockfile + + %w[x86_64-darwin-19 x86_64-darwin-20].each do |platform| + simulate_platform(Gem::Platform.new(platform)) do + bundle "lock" + expect(lockfile).to eq(previous_lockfile) + + bundle "install" + expect(the_bundle).to include_gem("libv8 8.4.255.0 #{platform}") + end + end + end + context "when an update is available" do let(:repo) { gem_repo2 } -- cgit v1.2.3