diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-01-08 16:11:52 +0900 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2020-03-27 14:43:20 +0900 |
commit | 7b5133801340cfa7e4e4e5dd61384cb90c3f6085 (patch) | |
tree | f00b7f885a6c43d82222ce65f3b92451ba5aa870 /spec/bundler | |
parent | 572021c6e4e01c3b8ece90ad42fdd4ee71b8acc5 (diff) |
Merge bundler-2.1.4
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/commands/outdated_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/pristine_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/update_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/install/deploy_spec.rb | 178 | ||||
-rw-r--r-- | spec/bundler/install/gemfile/gemspec_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/plugins/source/example_spec.rb | 10 | ||||
-rw-r--r-- | spec/bundler/runtime/gem_tasks_spec.rb | 14 | ||||
-rw-r--r-- | spec/bundler/runtime/inline_spec.rb | 17 | ||||
-rw-r--r-- | spec/bundler/runtime/require_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/runtime/setup_spec.rb | 29 | ||||
-rw-r--r-- | spec/bundler/support/builders.rb | 20 | ||||
-rw-r--r-- | spec/bundler/support/helpers.rb | 6 | ||||
-rw-r--r-- | spec/bundler/support/indexes.rb | 2 | ||||
-rw-r--r-- | spec/bundler/support/matchers.rb | 4 |
14 files changed, 185 insertions, 105 deletions
diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb index 6e82d34b05..df911eaffd 100644 --- a/spec/bundler/commands/outdated_spec.rb +++ b/spec/bundler/commands/outdated_spec.rb @@ -423,7 +423,7 @@ RSpec.describe "bundle outdated" do expect(err).to include("You are trying to check outdated gems in deployment mode.") expect(err).to include("Run `bundle outdated` elsewhere.") expect(err).to include("If this is a development machine, remove the ") - expect(err).to include("Gemfile freeze\nby running `bundle install --no-deployment`.") + expect(err).to include("Gemfile freeze\nby running `bundle config unset deployment`.") end end diff --git a/spec/bundler/commands/pristine_spec.rb b/spec/bundler/commands/pristine_spec.rb index aa5c2213d1..cc7f760d74 100644 --- a/spec/bundler/commands/pristine_spec.rb +++ b/spec/bundler/commands/pristine_spec.rb @@ -99,7 +99,7 @@ RSpec.describe "bundle pristine", :ruby_repo do it "reinstall gemspec dependency" do spec = Bundler.definition.specs["baz-dev"].first - changed_file = Pathname.new(spec.full_gem_path).join("lib/baz-dev.rb") + changed_file = Pathname.new(spec.full_gem_path).join("lib/baz/dev.rb") diff = "#Pristine spec changes" File.open(changed_file, "a") {|f| f.puts "#Pristine spec changes" } diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index a0c7e33299..e4449312eb 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -286,7 +286,7 @@ RSpec.describe "bundle update" do 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 install --no-deployment`./m) + expect(err).to match(/freeze \nby running `bundle config unset deployment`./m) end it "should suggest different command when frozen is set globally", :bundler => "< 3" do diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index 89da3fc801..f92a531bf5 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -34,7 +34,7 @@ RSpec.describe "install with --deployment or --frozen" do expect(exitstatus).to eq(15) if exitstatus end - it "works after you try to deploy without a lock" do + it "doesn't mess up a subsequent `bundle install` after you try to deploy without a lock" do bundle "install --deployment" bundle! :install expect(the_bundle).to include_gems "rack 1.0" @@ -42,7 +42,7 @@ RSpec.describe "install with --deployment or --frozen" do end it "still works if you are not in the app directory and specify --gemfile" do - bundle "install" + bundle! "install" Dir.chdir tmp do simulate_new_machine bundle! :install, @@ -60,12 +60,12 @@ RSpec.describe "install with --deployment or --frozen" do gem "foo", :git => "#{lib_path("foo-1.0")}" end G - bundle :install + bundle! :install bundle! :install, forgotten_command_line_options(:deployment => true, :without => "test") end it "works when you bundle exec bundle" do - bundle :install + bundle! :install bundle "install --deployment" bundle! "exec bundle check" end @@ -104,9 +104,90 @@ RSpec.describe "install with --deployment or --frozen" do expect(the_bundle).to include_gems "rack 1.0" end + context "when replacing a host with the same host with credentials" do + before do + bundle! "install", forgotten_command_line_options(:path => "vendor/bundle") + gemfile <<-G + source "http://user_name:password@localgemserver.test/" + gem "rack" + G + + lockfile <<-G + GEM + remote: http://localgemserver.test/ + specs: + rack (1.0.0) + + PLATFORMS + #{local} + + DEPENDENCIES + rack + G + + bundle! "config set --local deployment true" + end + + it "prevents the replace by default" do + bundle :install + + expect(err).to match(/The list of sources changed/) + end + + context "when allow_deployment_source_credential_changes is true" do + before { bundle! "config set allow_deployment_source_credential_changes true" } + + it "allows the replace" do + bundle! :install + + expect(out).to match(/Bundle complete!/) + end + end + + context "when allow_deployment_source_credential_changes is false" do + before { bundle! "config set allow_deployment_source_credential_changes false" } + + it "prevents the replace" do + bundle :install + + expect(err).to match(/The list of sources changed/) + end + end + + context "when BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES env var is true" do + before { ENV["BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES"] = "true" } + + it "allows the replace" do + bundle :install + + expect(out).to match(/Bundle complete!/) + end + end + + context "when BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES env var is false" do + before { ENV["BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES"] = "false" } + + it "prevents the replace" do + bundle :install + + expect(err).to match(/The list of sources changed/) + end + end + end + describe "with an existing lockfile" do before do - bundle "install" + bundle! "install" + end + + it "installs gems by default to vendor/bundle", :bundler => "< 3" do + bundle! "install --deployment" + expect(out).to include("vendor/bundle") + end + + it "installs gems to custom path if specified", :bundler => "< 3" do + bundle! "install --path vendor/bundle2 --deployment" + expect(out).to include("vendor/bundle2") end it "works with the --deployment flag if you didn't change anything", :bundler => "< 3" do @@ -197,6 +278,19 @@ RSpec.describe "install with --deployment or --frozen" do expect(err).not_to include("You have changed in the Gemfile") end + it "installs gems by default to vendor/bundle when `--deployment` is set via an environment variable", :bundler => "< 3" do + ENV["BUNDLE_DEPLOYMENT"] = "true" + bundle "install" + expect(out).to include("vendor/bundle") + end + + it "installs gems to custom path when deployment mode is set via an environment variable ", :bundler => "< 3" do + ENV["BUNDLE_DEPLOYMENT"] = "true" + ENV["BUNDLE_PATH"] = "vendor/bundle2" + bundle "install" + expect(out).to include("vendor/bundle2") + end + it "can have --frozen set to false via an environment variable" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -280,80 +374,6 @@ RSpec.describe "install with --deployment or --frozen" do expect(err).not_to include("You have deleted from the Gemfile") end - context "when replacing a host with the same host with credentials" do - let(:success_message) do - "Bundle complete!" - end - - before do - install_gemfile <<-G - source "http://user_name:password@localgemserver.test/" - gem "rack" - G - - lockfile <<-G - GEM - remote: http://localgemserver.test/ - specs: - rack (1.0.0) - - PLATFORMS - #{local} - - DEPENDENCIES - rack - G - - bundle! "config set --local deployment true" - end - - it "prevents the replace by default" do - bundle :install - - expect(err).to match(/The list of sources changed/) - end - - context "when allow_deployment_source_credential_changes is true" do - before { bundle! "config set allow_deployment_source_credential_changes true" } - - it "allows the replace" do - bundle :install - - expect(out).to match(/#{success_message}/) - end - end - - context "when allow_deployment_source_credential_changes is false" do - before { bundle! "config set allow_deployment_source_credential_changes false" } - - it "prevents the replace" do - bundle :install - - expect(err).to match(/The list of sources changed/) - end - end - - context "when BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES env var is true" do - before { ENV["BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES"] = "true" } - - it "allows the replace" do - bundle :install - - expect(out).to match(/#{success_message}/) - end - end - - context "when BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES env var is false" do - before { ENV["BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES"] = "false" } - - it "prevents the replace" do - bundle :install - - expect(err).to match(/The list of sources changed/) - end - end - end - it "remembers that the bundle is frozen at runtime" do bundle! :lock diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb index c50f8c9668..26a6235166 100644 --- a/spec/bundler/install/gemfile/gemspec_spec.rb +++ b/spec/bundler/install/gemfile/gemspec_spec.rb @@ -210,7 +210,7 @@ RSpec.describe "bundle install from an existing gemspec" do build_lib("foo", :path => bundled_app) gemspec = bundled_app("foo.gemspec").read bundled_app("foo.gemspec").open("w") do |f| - f.write "#{gemspec.strip}.tap { gem 'rack-obama'; require 'rack-obama' }" + f.write "#{gemspec.strip}.tap { gem 'rack-obama'; require 'rack/obama' }" end install_gemfile! <<-G diff --git a/spec/bundler/plugins/source/example_spec.rb b/spec/bundler/plugins/source/example_spec.rb index 64002d8f46..f2151a5a73 100644 --- a/spec/bundler/plugins/source/example_spec.rb +++ b/spec/bundler/plugins/source/example_spec.rb @@ -125,14 +125,14 @@ RSpec.describe "real source plugins" do end it "installs the gem executables" do - build_lib "gem-with-bin" do |s| + build_lib "gem_with_bin" do |s| s.executables = ["foo"] end install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" # plugin source - source "#{lib_path("gem-with-bin-1.0")}", :type => :mpath do - gem "gem-with-bin" + source "#{lib_path("gem_with_bin-1.0")}", :type => :mpath do + gem "gem_with_bin" end G @@ -451,7 +451,7 @@ RSpec.describe "real source plugins" do bundle "install" run <<-RUBY - require 'ma-gitp-gem' + require 'ma/gitp/gem' puts "WIN" unless defined?(MAGITPGEM_PREV_REF) RUBY expect(out).to eq("WIN") @@ -462,7 +462,7 @@ RSpec.describe "real source plugins" do bundle "update ma-gitp-gem" run <<-RUBY - require 'ma-gitp-gem' + require 'ma/gitp/gem' puts "WIN" if defined?(MAGITPGEM_PREV_REF) RUBY expect(out).to eq("WIN") diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb index 4b92de76bb..74270a2316 100644 --- a/spec/bundler/runtime/gem_tasks_spec.rb +++ b/spec/bundler/runtime/gem_tasks_spec.rb @@ -57,6 +57,20 @@ RSpec.describe "require 'bundler/gem_tasks'" do expect(err).to be_empty end + context "rake build when path has spaces" do + before do + spaced_bundled_app = tmp.join("bundled app") + FileUtils.mv bundled_app, spaced_bundled_app + Dir.chdir(spaced_bundled_app) + end + + it "still runs successfully" do + bundle! "exec rake build" + + expect(err).to be_empty + end + end + it "adds 'pkg' to rake/clean's CLOBBER" do with_gem_path_as(Spec::Path.base_system_gems.to_s) do sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect') diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb index 94d8b086a2..cd762fe636 100644 --- a/spec/bundler/runtime/inline_spec.rb +++ b/spec/bundler/runtime/inline_spec.rb @@ -333,4 +333,21 @@ RSpec.describe "bundler/inline#gemfile" do expect(last_command).to be_success expect(out).to include("BUNDLE_GEMFILE is empty") end + + it "resets BUNDLE_GEMFILE to the empty string if it wasn't set previously" do + ENV["BUNDLE_GEMFILE"] = nil + script <<-RUBY + gemfile do + source "#{file_uri_for(gem_repo1)}" + gem "rack" + end + + puts "BUNDLE_GEMFILE is empty" if ENV["BUNDLE_GEMFILE"].empty? + system("#{Gem.ruby} -w -e '42'") # this should see original value of BUNDLE_GEMFILE + exit $?.exitstatus + RUBY + + expect(last_command).to be_success + expect(out).to include("BUNDLE_GEMFILE is empty") + end end diff --git a/spec/bundler/runtime/require_spec.rb b/spec/bundler/runtime/require_spec.rb index 490b8c7631..a8d7826123 100644 --- a/spec/bundler/runtime/require_spec.rb +++ b/spec/bundler/runtime/require_spec.rb @@ -168,7 +168,6 @@ RSpec.describe "Bundler.require" do build_lib "jquery-rails", "1.0.0" do |s| s.write "lib/jquery/rails.rb", "puts 'jquery/rails'" end - lib_path("jquery-rails-1.0.0/lib/jquery-rails.rb").rmtree end it "requires gem names that are namespaced" do @@ -241,7 +240,6 @@ RSpec.describe "Bundler.require" do build_lib "load-fuuu", "1.0.0" do |s| s.write "lib/load/fuuu.rb", "raise LoadError.new(\"cannot load such file -- load-bar\")" end - lib_path("load-fuuu-1.0.0/lib/load-fuuu.rb").rmtree gemfile <<-G path "#{lib_path}" do diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index 39240b7404..7f00a63078 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -899,17 +899,17 @@ end describe "with git gems that don't have gemspecs" do before :each do - build_git "no-gemspec", :gemspec => false + build_git "no_gemspec", :gemspec => false install_gemfile <<-G - gem "no-gemspec", "1.0", :git => "#{lib_path("no-gemspec-1.0")}" + gem "no_gemspec", "1.0", :git => "#{lib_path("no_gemspec-1.0")}" G end it "loads the library via a virtual spec" do run <<-R - require 'no-gemspec' - puts NOGEMSPEC + require 'no_gemspec' + puts NO_GEMSPEC R expect(out).to eq("1.0") @@ -1263,6 +1263,27 @@ end expect(out).to eq("{}") end + it "does not load net-http-pipeline too early" do + build_repo4 do + build_gem "net-http-pipeline", "1.0.1" + end + + system_gems "net-http-pipeline-1.0.1", :gem_repo => gem_repo4 do + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "net-http-pipeline", "1.0.1" + G + + bundle "config set --local path vendor/bundle" + + bundle! :install + + bundle! :check + + expect(out).to eq("The Gemfile's dependencies are satisfied") + end + end + Gem::Specification.select(&:default_gem?).map(&:name).each do |g| it "activates newer versions of #{g}" do skip if exemptions.include?(g) diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb index c7f299487c..b3f5f9b876 100644 --- a/spec/bundler/support/builders.rb +++ b/spec/bundler/support/builders.rb @@ -611,7 +611,7 @@ module Spec unless options[:no_default] gem_source = options[:source] || "path@#{path}" @files = _default_files. - merge("lib/#{name}/source.rb" => "#{Builders.constantize(name)}_SOURCE = #{gem_source.to_s.dump}"). + merge("lib/#{entrypoint}/source.rb" => "#{Builders.constantize(name)}_SOURCE = #{gem_source.to_s.dump}"). merge(@files) end @@ -627,15 +627,20 @@ module Spec end def _default_files - @_default_files ||= begin - platform_string = " #{@spec.platform}" unless @spec.platform == Gem::Platform::RUBY - { "lib/#{name}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'" } - end + @_default_files ||= { "lib/#{entrypoint}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'" } + end + + def entrypoint + name.tr("-", "/") end def _default_path @context.tmp("libs", @spec.full_name) end + + def platform_string + " #{@spec.platform}" unless @spec.platform == Gem::Platform::RUBY + end end class GitBuilder < LibBuilder @@ -755,7 +760,10 @@ module Spec class PluginBuilder < GemBuilder def _default_files - @_default_files ||= super.merge("plugins.rb" => "") + @_default_files ||= { + "lib/#{name}.rb" => "#{Builders.constantize(name)} = '#{version}#{platform_string}'", + "plugins.rb" => "", + } end end diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index 7d1bd65185..e9c9e766cf 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -210,8 +210,10 @@ module Spec yield stdin, stdout, wait_thr if block_given? stdin.close - command_execution.stdout = Thread.new { stdout.read }.value.strip - command_execution.stderr = Thread.new { stderr.read }.value.strip + stdout_read_thread = Thread.new { stdout.read } + stderr_read_thread = Thread.new { stderr.read } + command_execution.stdout = stdout_read_thread.value.strip + command_execution.stderr = stderr_read_thread.value.strip command_execution.exitstatus = wait_thr && wait_thr.value.exitstatus end diff --git a/spec/bundler/support/indexes.rb b/spec/bundler/support/indexes.rb index b76f493d01..dc6e0bd1e9 100644 --- a/spec/bundler/support/indexes.rb +++ b/spec/bundler/support/indexes.rb @@ -45,7 +45,7 @@ module Spec def should_conflict_on(names) got = resolve - flunk "The resolve succeeded with: #{got.map(&:full_name).sort.inspect}" + raise "The resolve succeeded with: #{got.map(&:full_name).sort.inspect}" rescue Bundler::VersionConflict => e expect(Array(names).sort).to eq(e.conflicts.sort) end diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb index e1a08a30cc..df35854c2f 100644 --- a/spec/bundler/support/matchers.rb +++ b/spec/bundler/support/matchers.rb @@ -128,7 +128,7 @@ module Spec groups << opts @errors = names.map do |name| name, version, platform = name.split(/\s+/) - require_path = name == "bundler" ? "#{lib_dir}/bundler" : name + require_path = name == "bundler" ? "#{lib_dir}/bundler" : name.tr("-", "/") version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name) begin run! "require '#{require_path}.rb'; puts #{version_const}", *groups @@ -145,7 +145,7 @@ module Spec next unless source begin source_const = "#{Spec::Builders.constantize(name)}_SOURCE" - run! "require '#{name}/source'; puts #{source_const}", *groups + run! "require '#{require_path}/source'; puts #{source_const}", *groups rescue StandardError next "#{name} does not have a source defined:\n#{indent(e)}" end |