diff options
| author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-07-19 14:14:12 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2023-08-29 23:25:18 +0900 |
| commit | e44e42c3039d26c016554f3db1c0d6817abbad87 (patch) | |
| tree | 0e0b4c2d04443b34b9deaba59d00af6c33d8b8e1 /spec | |
| parent | a36c8364331d39dd7da6308c6ae99f5a810ac510 (diff) | |
Merge RubyGems-3.4.15 and Bundler-2.4.15
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/bundler/commands/cache_spec.rb | 2 | ||||
| -rw-r--r-- | spec/bundler/commands/inject_spec.rb | 2 | ||||
| -rw-r--r-- | spec/bundler/commands/lock_spec.rb | 23 | ||||
| -rw-r--r-- | spec/bundler/commands/update_spec.rb | 22 | ||||
| -rw-r--r-- | spec/bundler/install/deploy_spec.rb | 62 | ||||
| -rw-r--r-- | spec/bundler/install/gemfile/gemspec_spec.rb | 2 | ||||
| -rw-r--r-- | spec/bundler/install/gemfile/specific_platform_spec.rb | 13 | ||||
| -rw-r--r-- | spec/bundler/lock/lockfile_spec.rb | 2 | ||||
| -rw-r--r-- | spec/bundler/support/builders.rb | 6 |
9 files changed, 84 insertions, 50 deletions
diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb index 356a658e7c..a9ed389233 100644 --- a/spec/bundler/commands/cache_spec.rb +++ b/spec/bundler/commands/cache_spec.rb @@ -291,7 +291,7 @@ RSpec.describe "bundle cache" do G subject expect(exitstatus).to eq(16) - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).to include("You have added to the Gemfile") expect(err).to include("* rack-obama") bundle "env" diff --git a/spec/bundler/commands/inject_spec.rb b/spec/bundler/commands/inject_spec.rb index 92e86bd6cc..d711fe010d 100644 --- a/spec/bundler/commands/inject_spec.rb +++ b/spec/bundler/commands/inject_spec.rb @@ -109,7 +109,7 @@ Usage: "bundle inject GEM VERSION" gem "rack-obama" G bundle "inject 'rack' '> 0'", :raise_on_error => false - expect(err).to match(/trying to install in deployment mode after changing/) + expect(err).to match(/the lockfile can't be updated because frozen mode is set/) expect(bundled_app_lock.read).not_to match(/rack-obama/) end diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index 85b3d4a075..491fa30949 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -297,24 +297,27 @@ RSpec.describe "bundle lock" do end end - it "updates the bundler version in the lockfile without re-resolving", :rubygems => ">= 3.3.0.dev" do + it "updates the bundler version in the lockfile to the latest bundler version" do build_repo4 do - build_gem "rack", "1.0" + build_gem "bundler", "55" end - install_gemfile <<-G - source "#{file_uri_for(gem_repo4)}" - gem "rack" + system_gems "bundler-55", :gem_repo => gem_repo4 + + install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + source "https://gems.repo4" G lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2') - FileUtils.rm_r gem_repo4 + bundle "lock --update --bundler --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + expect(lockfile).to end_with("BUNDLED WITH\n 55\n") - bundle "lock --update --bundler" - expect(the_bundle).to include_gem "rack 1.0" + update_repo4 do + build_gem "bundler", "99" + end - allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) - expect(the_bundle.locked_gems.bundler_version).to eq v(Bundler::VERSION) + bundle "lock --update --bundler --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + expect(lockfile).to end_with("BUNDLED WITH\n 99\n") end it "supports adding new platforms" do diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index 7a0d435860..4a720a9120 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -658,27 +658,27 @@ RSpec.describe "bundle update" do bundle "update", :all => true, :raise_on_error => false expect(last_command).to be_failure - expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m) - expect(err).to match(/freeze \nby running `bundle config set frozen false`./m) + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/) + expect(err).to match(/freeze by running `bundle config set frozen false`./) end it "should fail loudly when frozen is set globally" do bundle "config set --global frozen 1" bundle "update", :all => true, :raise_on_error => false - expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m). - and match(/freeze \nby running `bundle config set frozen false`./m) + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/). + and match(/freeze by running `bundle config set frozen false`./) end it "should fail loudly when deployment is set globally" do bundle "config set --global deployment true" bundle "update", :all => true, :raise_on_error => false - expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m). - and match(/freeze \nby running `bundle config set frozen false`./m) + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/). + and match(/freeze by running `bundle config set frozen false`./) end it "should not suggest any command to unfreeze bundler if frozen is set through ENV" do bundle "update", :all => true, :raise_on_error => false, :env => { "BUNDLE_FROZEN" => "true" } - expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m) + expect(err).to match(/Bundler is unlocking, but the lockfile can't be updated because frozen mode is set/) expect(err).not_to match(/by running/) end end @@ -1239,7 +1239,7 @@ RSpec.describe "bundle update --ruby" do end RSpec.describe "bundle update --bundler" do - it "updates the bundler version in the lockfile without re-resolving" do + it "updates the bundler version in the lockfile" do build_repo4 do build_gem "rack", "1.0" end @@ -1250,8 +1250,6 @@ RSpec.describe "bundle update --bundler" do G lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2') - FileUtils.rm_r gem_repo4 - bundle :update, :bundler => true, :artifice => "compact_index", :verbose => true expect(out).to include("Using bundler #{Bundler::VERSION}") @@ -1473,8 +1471,8 @@ RSpec.describe "bundle update --bundler" do 2.1.4 L - bundle "update --bundler=2.3.9", :env => { "BUNDLE_FROZEN" => "true" } - expect(err).to include("Cannot write a changed lockfile while frozen") + bundle "update --bundler=2.3.9", :env => { "BUNDLE_FROZEN" => "true" }, :raise_on_error => false + expect(err).to include("An update to the version of bundler itself was requested, but the lockfile can't be updated because frozen mode is set") end end diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index 3f98d56f41..2a88ed5b06 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -66,7 +66,7 @@ RSpec.describe "install in deployment or frozen mode" do G bundle "install --deployment", :raise_on_error => false - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).to include("You have added to the Gemfile") expect(err).to include("* rack-obama") expect(err).not_to include("You have deleted from the Gemfile") @@ -272,7 +272,7 @@ RSpec.describe "install in deployment or frozen mode" do bundle "config set --local deployment true" bundle :install, :raise_on_error => false - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).to include("You have added to the Gemfile") expect(err).to include("* rack-obama") expect(err).not_to include("You have deleted from the Gemfile") @@ -297,8 +297,12 @@ RSpec.describe "install in deployment or frozen mode" do expect(out).to eq("WIN") end - it "works if a gem is missing, but it's on a different platform, and the Gemfile has no global source", :bundler => "< 3" do + it "works if a gem is missing, but it's on a different platform" do + build_repo2 + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + source "#{file_uri_for(gem_repo1)}" do gem "rake", platform: :#{not_local_tag} end @@ -308,6 +312,40 @@ RSpec.describe "install in deployment or frozen mode" do expect(last_command).to be_success end + it "shows a good error if a gem is missing from the lockfile" do + build_repo4 do + build_gem "foo" + build_gem "bar" + end + + gemfile <<-G + source "https://gem.repo4" + + gem "foo" + gem "bar" + G + + lockfile <<~L + GEM + remote: https://gem.repo4/ + specs: + foo (1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo + bar + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle :install, :env => { "BUNDLE_FROZEN" => "true" }, :raise_on_error => false, :artifice => "compact_index" + expect(err).to include("Your lock file is missing \"bar\", but the lockfile can't be updated because frozen mode is set") + end + it "explodes if a path gem is missing" do build_lib "path_gem" install_gemfile <<-G @@ -333,7 +371,7 @@ RSpec.describe "install in deployment or frozen mode" do ENV["BUNDLE_FROZEN"] = "1" bundle "install", :raise_on_error => false - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).to include("You have added to the Gemfile") expect(err).to include("* rack-obama") expect(err).not_to include("You have deleted from the Gemfile") @@ -349,7 +387,7 @@ RSpec.describe "install in deployment or frozen mode" do ENV["BUNDLE_DEPLOYMENT"] = "true" bundle "install", :raise_on_error => false - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).to include("You have added to the Gemfile") expect(err).to include("* rack-obama") expect(err).not_to include("You have deleted from the Gemfile") @@ -379,7 +417,7 @@ RSpec.describe "install in deployment or frozen mode" do ENV["BUNDLE_FROZEN"] = "false" ENV["BUNDLE_DEPLOYMENT"] = "false" bundle "install" - expect(out).not_to include("deployment mode") + expect(out).not_to include("frozen mode") expect(out).not_to include("You have added to the Gemfile") expect(out).not_to include("* rack-obama") end @@ -392,7 +430,7 @@ RSpec.describe "install in deployment or frozen mode" do bundle "config set --local deployment true" bundle :install, :raise_on_error => false - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).to include("You have added to the Gemfile:\n* activesupport\n\n") expect(err).to include("You have deleted from the Gemfile:\n* rack") expect(err).not_to include("You have changed in the Gemfile") @@ -406,7 +444,7 @@ RSpec.describe "install in deployment or frozen mode" do bundle "config set --local deployment true" bundle :install, :raise_on_error => false - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).not_to include("You have added to the Gemfile") expect(err).to include("You have changed in the Gemfile:\n* rack from `no specified source` to `git://hubz.com`") end @@ -426,7 +464,7 @@ RSpec.describe "install in deployment or frozen mode" do bundle "config set --local deployment true" bundle :install, :raise_on_error => false - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).not_to include("You have deleted from the Gemfile") expect(err).not_to include("You have added to the Gemfile") expect(err).to include("You have changed in the Gemfile:\n* rack from `#{lib_path("rack-1.0")}` to `no specified source`") @@ -450,7 +488,7 @@ RSpec.describe "install in deployment or frozen mode" do bundle "config set --local deployment true" bundle :install, :raise_on_error => false - expect(err).to include("deployment mode") + expect(err).to include("frozen mode") expect(err).to include("You have changed in the Gemfile:\n* rack from `#{lib_path("rack")}` to `no specified source`") expect(err).not_to include("You have added to the Gemfile") expect(err).not_to include("You have deleted from the Gemfile") @@ -469,7 +507,7 @@ RSpec.describe "install in deployment or frozen mode" do run "require 'rack'", :raise_on_error => false expect(err).to include strip_whitespace(<<-E).strip -The dependencies in your gemfile changed +The dependencies in your gemfile changed, but the lockfile can't be updated because frozen mode is set (Bundler::ProductionError) You have added to the Gemfile: * rack (= 1.0.0) @@ -502,7 +540,7 @@ You have deleted from the Gemfile: simulate_new_machine bundle "config set --local deployment true" bundle "install --verbose" - expect(out).not_to include("You are trying to install in deployment mode after changing your Gemfile") + expect(out).not_to include("but the lockfile can't be updated because frozen mode is set") expect(out).not_to include("You have added to the Gemfile") expect(out).not_to include("You have deleted from the Gemfile") expect(out).to include("vendor/cache/foo") diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb index 2aa4214818..73f04f071d 100644 --- a/spec/bundler/install/gemfile/gemspec_spec.rb +++ b/spec/bundler/install/gemfile/gemspec_spec.rb @@ -150,7 +150,7 @@ RSpec.describe "bundle install from an existing gemspec" do output = bundle("install", :dir => tmp.join("foo")) expect(output).not_to match(/You have added to the Gemfile/) expect(output).not_to match(/You have deleted from the Gemfile/) - expect(output).not_to match(/install in deployment mode after changing/) + expect(output).not_to match(/the lockfile can't be updated because frozen mode is set/) end it "should match a lockfile without needing to re-resolve" do diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb index 6974af3270..cab53a663a 100644 --- a/spec/bundler/install/gemfile/specific_platform_spec.rb +++ b/spec/bundler/install/gemfile/specific_platform_spec.rb @@ -115,8 +115,6 @@ RSpec.describe "bundle install with specific platforms" do s.platform = "arm64-darwin" s.required_ruby_version = "< #{Gem.ruby_version}" end - - build_gem "bundler", "2.1.4" end gemfile <<~G @@ -137,22 +135,21 @@ RSpec.describe "bundle install with specific platforms" do DEPENDENCIES nokogiri - RUBY VERSION - 2.5.3p105 - BUNDLED WITH - 2.1.4 + #{Bundler::VERSION} L simulate_platform "arm64-darwin-22", &example end it "still installs the generic RUBY variant if necessary" do - bundle "update --bundler", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + expect(out).to include("Installing nokogiri 1.3.10") end it "still installs the generic RUBY variant if necessary, even in frozen mode" do - bundle "update --bundler", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s, "BUNDLE_FROZEN" => "true" } + bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s, "BUNDLE_FROZEN" => "true" } + expect(out).to include("Installing nokogiri 1.3.10") end end diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 8d9554c68d..4b78cb261d 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -1371,7 +1371,7 @@ RSpec.describe "the lockfile format" do L bundle "install --verbose" - expect(out).to include("re-resolving dependencies because your lock file is missing some gems") + expect(out).to include("re-resolving dependencies because your lock file is missing \"minitest-bisect\"") expect(lockfile).to eq <<~L GEM diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb index 6cba9000ac..dfc7139523 100644 --- a/spec/bundler/support/builders.rb +++ b/spec/bundler/support/builders.rb @@ -208,10 +208,8 @@ module Spec update_repo(gem_repo4, &blk) end - def update_repo2 - update_repo gem_repo2 do - yield if block_given? - end + def update_repo2(&blk) + update_repo(gem_repo2, &blk) end def build_security_repo |
