From 8f4aa4fd2a609a3eca2f415a12964e86cab94abc Mon Sep 17 00:00:00 2001 From: hsbt Date: Mon, 12 Nov 2018 00:53:15 +0000 Subject: Merge Bundler-2.0.0.pre1 from upstream. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/bundler/bundler/ui/shell_spec.rb | 4 +-- spec/bundler/commands/binstubs_spec.rb | 27 ++++++++++++++++ spec/bundler/commands/clean_spec.rb | 2 +- spec/bundler/commands/exec_spec.rb | 41 ++---------------------- spec/bundler/commands/init_spec.rb | 2 +- spec/bundler/commands/pristine_spec.rb | 2 +- spec/bundler/commands/show_spec.rb | 8 ++--- spec/bundler/install/deploy_spec.rb | 2 +- spec/bundler/install/post_bundle_message_spec.rb | 2 +- spec/bundler/install/redownload_spec.rb | 4 +-- spec/bundler/other/major_deprecation_spec.rb | 10 +++--- spec/bundler/other/platform_spec.rb | 2 +- spec/bundler/quality_spec.rb | 1 + spec/bundler/realworld/edgecases_spec.rb | 4 +-- spec/bundler/runtime/gem_tasks_spec.rb | 4 +-- spec/bundler/support/helpers.rb | 4 +-- spec/bundler/support/path.rb | 2 +- spec/bundler/support/platforms.rb | 2 +- spec/bundler/support/rubygems_ext.rb | 2 +- spec/bundler/update/redownload_spec.rb | 8 ++--- 20 files changed, 63 insertions(+), 70 deletions(-) (limited to 'spec') diff --git a/spec/bundler/bundler/ui/shell_spec.rb b/spec/bundler/bundler/ui/shell_spec.rb index 6de2330687..951a446aff 100644 --- a/spec/bundler/bundler/ui/shell_spec.rb +++ b/spec/bundler/bundler/ui/shell_spec.rb @@ -21,7 +21,7 @@ RSpec.describe Bundler::UI::Shell do describe "#warn" do before { subject.level = "warn" } - it "prints to stdout", :bundler => "< 3" do + it "prints to stdout", :bundler => "< 2" do expect { subject.warn("warning") }.to output("warning\n").to_stdout end @@ -46,7 +46,7 @@ RSpec.describe Bundler::UI::Shell do describe "#error" do before { subject.level = "error" } - it "prints to stdout", :bundler => "< 3" do + it "prints to stdout", :bundler => "< 2" do expect { subject.error("error!!!") }.to output("error!!!\n").to_stdout end diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb index 849c5a4f75..7f2e81c099 100644 --- a/spec/bundler/commands/binstubs_spec.rb +++ b/spec/bundler/commands/binstubs_spec.rb @@ -134,6 +134,33 @@ RSpec.describe "bundle binstubs " do if ENV["BUNDLER_SPEC_SUB_VERSION"] let(:system_bundler_version) { Bundler::VERSION } end + + before do + gemfile <<-G + source "file:///Users/colby/Projects/bundler/tmp/gems/remote2" + gem "rack" + gem "prints_loaded_gems" + G + + lockfile <<-G + GEM + remote: file:///Users/colby/Projects/bundler/tmp/gems/remote2/ + specs: + prints_loaded_gems (1.0) + rack (1.2) + + PLATFORMS + ruby + + DEPENDENCIES + prints_loaded_gems + rack + + BUNDLED WITH + #{system_bundler_version} + G + end + it "runs bundler" do sys_exec! "#{bundled_app("bin/bundle")} install" expect(out).to eq %(system bundler #{system_bundler_version}\n["install"]) diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb index da860e62f8..158d58d67c 100644 --- a/spec/bundler/commands/clean_spec.rb +++ b/spec/bundler/commands/clean_spec.rb @@ -142,7 +142,7 @@ RSpec.describe "bundle clean" do bundle :clean digest = Digest(:SHA1).hexdigest(git_path.to_s) - cache_path = Bundler::VERSION.start_with?("1.") ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}") + cache_path = Bundler.bundler_major_version < 3 ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}") expect(cache_path).to exist end diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index a08f2b6fe8..76841dcff6 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -570,22 +570,7 @@ RSpec.describe "bundle exec" do it_behaves_like "it runs" end - context "the executable is empty", :bundler => "< 3" do - let(:executable) { "" } - - let(:exit_code) { 0 } - let(:expected) { "#{path} is empty" } - let(:expected_err) { "" } - if LessThanProc.with(RUBY_VERSION).call("1.9") - # Kernel#exec in ruby < 1.9 will raise Errno::ENOEXEC if the command content is empty, - # even if the command is set as an executable. - pending "Kernel#exec is different" - else - it_behaves_like "it runs" - end - end - - context "the executable is empty", :bundler => "3" do + context "the executable is empty" do let(:executable) { "" } let(:exit_code) { 0 } @@ -594,18 +579,7 @@ RSpec.describe "bundle exec" do it_behaves_like "it runs" end - context "the executable raises", :bundler => "< 3" do - let(:executable) { super() << "\nraise 'ERROR'" } - let(:exit_code) { 1 } - let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" } - let(:expected_err) do - "RuntimeError: ERROR\n #{path}:10" + - (Bundler.current_ruby.ruby_18? ? "" : ":in `'") - end - it_behaves_like "it runs" - end - - context "the executable raises", :bundler => "3" do + context "the executable raises" do let(:executable) { super() << "\nraise 'ERROR'" } let(:exit_code) { 1 } let(:expected_err) do @@ -615,16 +589,7 @@ RSpec.describe "bundle exec" do it_behaves_like "it runs" end - context "the executable raises an error without a backtrace", :bundler => "< 3" do - let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" } - let(:exit_code) { 1 } - let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" } - let(:expected_err) { "Err: Err" } - - it_behaves_like "it runs" - end - - context "the executable raises an error without a backtrace", :bundler => "3" do + context "the executable raises an error without a backtrace" do let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" } let(:exit_code) { 1 } let(:expected_err) { "bundler: failed to load command: #{path} (#{path})\nErr: Err" } diff --git a/spec/bundler/commands/init_spec.rb b/spec/bundler/commands/init_spec.rb index e0782f28f7..8a8f0effa0 100644 --- a/spec/bundler/commands/init_spec.rb +++ b/spec/bundler/commands/init_spec.rb @@ -115,7 +115,7 @@ RSpec.describe "bundle init" do bundle :init, :gemspec => spec_file - gemfile = if Bundler::VERSION[0, 2] == "1." + gemfile = if Bundler::VERSION[0, 2].to_i < 3 bundled_app("Gemfile").read else bundled_app("gems.rb").read diff --git a/spec/bundler/commands/pristine_spec.rb b/spec/bundler/commands/pristine_spec.rb index 0bfc37560a..d8761bba26 100644 --- a/spec/bundler/commands/pristine_spec.rb +++ b/spec/bundler/commands/pristine_spec.rb @@ -49,7 +49,7 @@ RSpec.describe "bundle pristine", :ruby_repo do bundle! "pristine", :system_bundler => true bundle! "-v", :system_bundler => true - expected = if Bundler::VERSION < "2.0" + expected = if Bundler::VERSION < "3.0" "Bundler version" else Bundler::VERSION diff --git a/spec/bundler/commands/show_spec.rb b/spec/bundler/commands/show_spec.rb index bf96ec489a..a5c6beec1a 100644 --- a/spec/bundler/commands/show_spec.rb +++ b/spec/bundler/commands/show_spec.rb @@ -36,7 +36,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do it "prints path if gem exists in bundle" do bundle "show rails" expect(out).to eq( - "[DEPRECATED FOR 2.0] use `bundle info rails` instead of `bundle show rails`\n" + + "[DEPRECATED FOR 3.0] use `bundle info rails` instead of `bundle show rails`\n" + default_bundle_path("gems", "rails-2.3.2").to_s ) end @@ -44,7 +44,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do it "prints the path to the running bundler" do bundle "show bundler" expect(out).to eq( - "[DEPRECATED FOR 2.0] use `bundle info bundler` instead of `bundle show bundler`\n" + + "[DEPRECATED FOR 3.0] use `bundle info bundler` instead of `bundle show bundler`\n" + root.to_s ) end @@ -52,7 +52,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do it "prints path if gem exists in bundle (with --paths option)" do bundle "show rails --paths" expect(out).to eq( - "[DEPRECATED FOR 2.0] use `bundle info rails --path` instead of `bundle show rails --paths`\n" + + "[DEPRECATED FOR 3.0] use `bundle info rails --path` instead of `bundle show rails --paths`\n" + default_bundle_path("gems", "rails-2.3.2").to_s ) end @@ -64,7 +64,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s) out_lines = out.split("\n") - expect(out_lines[0]).to eq("[DEPRECATED FOR 2.0] use `bundle list` instead of `bundle show --paths`") + expect(out_lines[0]).to eq("[DEPRECATED FOR 3.0] use `bundle list` instead of `bundle show --paths`") # Gem names are the last component of their path. gem_list = out_lines[1..-1].map {|p| p.split("/").last } diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index 21b93e57c0..ec72ff69fc 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -297,7 +297,7 @@ RSpec.describe "install with --deployment or --frozen" do context "when replacing a host with the same host with credentials" do let(:success_message) do - if Bundler::VERSION.split(".", 2).first == "1" + if Bundler.bundler_major_version < 3 "Could not reach host localgemserver.test" else "Bundle complete!" diff --git a/spec/bundler/install/post_bundle_message_spec.rb b/spec/bundler/install/post_bundle_message_spec.rb index c41dc67458..394134f523 100644 --- a/spec/bundler/install/post_bundle_message_spec.rb +++ b/spec/bundler/install/post_bundle_message_spec.rb @@ -19,7 +19,7 @@ RSpec.describe "post bundle message" do let(:bundle_complete_message) { "Bundle complete!" } let(:bundle_updated_message) { "Bundle updated!" } let(:installed_gems_stats) { "4 Gemfile dependencies, 5 gems now installed." } - let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 2 ? bundle_show_system_message : bundle_show_path_message } + let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 3 ? bundle_show_system_message : bundle_show_path_message } describe "for fresh bundle install" do it "without any options" do diff --git a/spec/bundler/install/redownload_spec.rb b/spec/bundler/install/redownload_spec.rb index 25d49999fc..f9caeed58a 100644 --- a/spec/bundler/install/redownload_spec.rb +++ b/spec/bundler/install/redownload_spec.rb @@ -65,12 +65,12 @@ RSpec.describe "bundle install", :bundler => "< 3", :ruby => ">= 2.0" do it "shows a deprecation when single flag passed" do bundle! "install --force" - expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end it "shows a deprecation when multiple flags passed" do bundle! "install --no-color --force" - expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end end diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index a147d053e1..32827dbd54 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -205,7 +205,7 @@ The :github git source is deprecated, and will be removed in Bundler 2.0. Change git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } EOS - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) subject.gem("sparks", :github => "indirect/sparks") end @@ -217,8 +217,8 @@ The :github git source is deprecated, and will be removed in Bundler 2.0. Change git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } EOS - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, "The `github.https` setting will be removed") + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, "The `github.https` setting will be removed") subject.gem("sparks", :github => "indirect/sparks") github_uri = "https://github.com/indirect/sparks.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) @@ -238,7 +238,7 @@ The :bitbucket git source is deprecated, and will be removed in Bundler 2.0. Add end EOS - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails") end end @@ -250,7 +250,7 @@ The :bitbucket git source is deprecated, and will be removed in Bundler 2.0. Add "in Bundler 2.0. Add this code to the top of your Gemfile to ensure it " \ "continues to work:\n\n git_source(:gist) {|repo_name| " \ "\"https://gist.github.com/\#{repo_name}.git\" }\n\n" - expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) + expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg) subject.gem("not-really-a-gem", :gist => "1234") end end diff --git a/spec/bundler/other/platform_spec.rb b/spec/bundler/other/platform_spec.rb index 96527e1641..6c59fd893c 100644 --- a/spec/bundler/other/platform_spec.rb +++ b/spec/bundler/other/platform_spec.rb @@ -4,7 +4,7 @@ RSpec.describe "bundle platform" do context "without flags" do let(:bundle_platform_platforms_string) do platforms = [rb] - platforms.unshift(specific_local_platform) if Bundler.feature_flag.bundler_2_mode? + platforms.unshift(specific_local_platform) if Bundler.feature_flag.bundler_3_mode? platforms.map {|pl| "* #{pl}" }.join("\n") end diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb index 14d6bb99b9..812acc344f 100644 --- a/spec/bundler/quality_spec.rb +++ b/spec/bundler/quality_spec.rb @@ -181,6 +181,7 @@ RSpec.describe "The library itself" do gem.coc gem.mit inline + lockfile_upgrade_warning lockfile_uses_separate_rubygems_sources use_gem_version_promoter_for_major_updates viz_command diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb index aa60e20b8a..bbfd0f68fd 100644 --- a/spec/bundler/realworld/edgecases_spec.rb +++ b/spec/bundler/realworld/edgecases_spec.rb @@ -57,7 +57,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do expect(lockfile).to include("activemodel (3.0.5)") end - it "resolves dependencies correctly", :ruby => "1.9.3" do + it "resolves dependencies correctly", :ruby => "<= 1.9.3" do gemfile <<-G source "https://rubygems.org" @@ -70,7 +70,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do expect(lockfile).to include("capybara (2.2.1)") end - it "installs the latest version of gxapi_rails", :ruby => "1.9.3" do + it "installs the latest version of gxapi_rails", :ruby => "<= 1.9.3" do gemfile <<-G source "https://rubygems.org" diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb index 0510c80632..de72869dc3 100644 --- a/spec/bundler/runtime/gem_tasks_spec.rb +++ b/spec/bundler/runtime/gem_tasks_spec.rb @@ -19,7 +19,7 @@ RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do it "includes the relevant tasks" do with_gem_path_as(Spec::Path.base_system_gems.to_s) do - sys_exec "ruby -S rake -T" + sys_exec "#{rake} -T" end expect(err).to eq("") @@ -37,7 +37,7 @@ RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do it "adds 'pkg' to rake/clean's CLOBBER" do with_gem_path_as(Spec::Path.base_system_gems.to_s) do - sys_exec! %('#{Gem.ruby}' -S rake -e 'load "Rakefile"; puts CLOBBER.inspect') + sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect') end expect(last_command.stdout).to eq '["pkg"]' end diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index b027e7a922..181dac3220 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -53,7 +53,7 @@ module Spec end def bundle_update_requires_all? - Bundler::VERSION.start_with?("1.") ? nil : true + Bundler::VERSION.start_with?("2.") ? nil : true end def in_app_root(&blk) @@ -152,7 +152,7 @@ module Spec bang :bundle def forgotten_command_line_options(options) - remembered = Bundler::VERSION.split(".", 2).first == "1" + remembered = Bundler.bundler_major_version < 3 options = options.map do |k, v| k = Array(k)[remembered ? 0 : -1] v = '""' if v && v.to_s.empty? diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index 2eea088eea..97153226bd 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -29,7 +29,7 @@ module Spec end def default_bundle_path(*path) - if Bundler::VERSION.split(".").first.to_i < 2 + if Bundler::VERSION.split(".").first.to_i < 3 system_gem_path(*path) else bundled_app(*[".bundle", ENV.fetch("BUNDLER_SPEC_RUBY_ENGINE", Gem.ruby_engine), Gem::ConfigMap[:ruby_version], *path].compact) diff --git a/spec/bundler/support/platforms.rb b/spec/bundler/support/platforms.rb index 39040a61bd..950311d20e 100644 --- a/spec/bundler/support/platforms.rb +++ b/spec/bundler/support/platforms.rb @@ -106,7 +106,7 @@ module Spec end def local_platforms - if Bundler::VERSION.split(".").first.to_i > 1 + if Bundler::VERSION.split(".").first.to_i > 2 [local, specific_local_platform] else [local] diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb index 806933fe2f..c18f7650fc 100644 --- a/spec/bundler/support/rubygems_ext.rb +++ b/spec/bundler/support/rubygems_ext.rb @@ -33,7 +33,7 @@ module Spec ENV["BUNDLE_PATH"] = nil ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s - ENV["PATH"] = ["#{Path.root}/exe", "#{Path.system_gem_path}/bin", ENV["PATH"]].join(File::PATH_SEPARATOR) + ENV["PATH"] = [Path.bindir, "#{Path.system_gem_path}/bin", ENV["PATH"]].join(File::PATH_SEPARATOR) manifest = DEPS.to_a.sort_by(&:first).map {|k, v| "#{k} => #{v}\n" } manifest_path = "#{Path.base_system_gems}/manifest.txt" diff --git a/spec/bundler/update/redownload_spec.rb b/spec/bundler/update/redownload_spec.rb index 2138af510c..1bbc3a66fc 100644 --- a/spec/bundler/update/redownload_spec.rb +++ b/spec/bundler/update/redownload_spec.rb @@ -13,24 +13,24 @@ RSpec.describe "bundle update", :bundler => "< 3", :ruby => ">= 2.0" do describe "with --force" do it "shows a deprecation when single flag passed" do bundle! "update rack --force" - expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end it "shows a deprecation when multiple flags passed" do bundle! "update rack --no-color --force" - expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end end describe "with --redownload" do it "does not show a deprecation when single flag passed" do bundle! "update rack --redownload" - expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end it "does not show a deprecation when single multiple flags passed" do bundle! "update rack --no-color --redownload" - expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" + expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`" end end end -- cgit v1.2.3