diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-12-12 09:09:23 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-12-12 10:49:43 +0900 |
commit | bbe56a643734025aef6a3cbeb07c5306505040f6 (patch) | |
tree | c6980a39ce6571c032695702bd974431eee4d516 /spec | |
parent | f1cdc129d4d6440168b840fa852fa6c3e28d46a9 (diff) |
Merge RubyGems/Bundler master
from https://github.com/rubygems/rubygems/commit/bfb0ae69776069155d2092702bfbb5a12617d85a
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6906
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/bundler/env_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/commands/config_spec.rb | 32 | ||||
-rw-r--r-- | spec/bundler/commands/viz_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/install/bundler_spec.rb | 27 | ||||
-rw-r--r-- | spec/bundler/install/gemfile/git_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/install/gems/native_extensions_spec.rb | 8 | ||||
-rw-r--r-- | spec/bundler/other/major_deprecation_spec.rb | 3 | ||||
-rw-r--r-- | spec/bundler/quality_es_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/quality_spec.rb | 20 | ||||
-rw-r--r-- | spec/bundler/runtime/setup_spec.rb | 6 | ||||
-rw-r--r-- | spec/bundler/spec_helper.rb | 26 | ||||
-rw-r--r-- | spec/bundler/support/builders.rb | 2 | ||||
-rw-r--r-- | spec/bundler/support/bundle.rb | 2 | ||||
-rw-r--r-- | spec/bundler/support/hax.rb | 7 | ||||
-rw-r--r-- | spec/bundler/support/helpers.rb | 6 | ||||
-rw-r--r-- | spec/bundler/support/indexes.rb | 2 | ||||
-rw-r--r-- | spec/bundler/support/path.rb | 18 | ||||
-rw-r--r-- | spec/bundler/support/rubygems_version_manager.rb | 2 |
18 files changed, 83 insertions, 92 deletions
diff --git a/spec/bundler/bundler/env_spec.rb b/spec/bundler/bundler/env_spec.rb index fb950c3c60..186b207b9f 100644 --- a/spec/bundler/bundler/env_spec.rb +++ b/spec/bundler/bundler/env_spec.rb @@ -34,8 +34,6 @@ RSpec.describe Bundler::Env do end it "prints user home" do - skip "needs to use a valid HOME" if Gem.win_platform? && RUBY_VERSION < "2.6.0" - with_clear_paths("HOME", "/a/b/c") do out = described_class.report expect(out).to include("User Home /a/b/c") @@ -43,8 +41,6 @@ RSpec.describe Bundler::Env do end it "prints user path" do - skip "needs to use a valid HOME" if Gem.win_platform? && RUBY_VERSION < "2.6.0" - with_clear_paths("HOME", "/a/b/c") do allow(File).to receive(:exist?) allow(File).to receive(:exist?).with("/a/b/c/.gem").and_return(true) diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 6148b1c7ce..ede93f99eb 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -143,17 +143,15 @@ RSpec.describe ".bundle/config" do end it "has lower precedence than env" do - begin - ENV["BUNDLE_FOO"] = "env" + ENV["BUNDLE_FOO"] = "env" - bundle "config set --global foo global" - expect(out).to match(/You have a bundler environment variable for foo set to "env"/) + bundle "config set --global foo global" + expect(out).to match(/You have a bundler environment variable for foo set to "env"/) - run "puts Bundler.settings[:foo]" - expect(out).to eq("env") - ensure - ENV.delete("BUNDLE_FOO") - end + run "puts Bundler.settings[:foo]" + expect(out).to eq("env") + ensure + ENV.delete("BUNDLE_FOO") end it "can be deleted" do @@ -221,15 +219,13 @@ RSpec.describe ".bundle/config" do end it "has higher precedence than env" do - begin - ENV["BUNDLE_FOO"] = "env" - bundle "config set --local foo local" - - run "puts Bundler.settings[:foo]" - expect(out).to eq("local") - ensure - ENV.delete("BUNDLE_FOO") - end + ENV["BUNDLE_FOO"] = "env" + bundle "config set --local foo local" + + run "puts Bundler.settings[:foo]" + expect(out).to eq("local") + ensure + ENV.delete("BUNDLE_FOO") end it "can be deleted" do diff --git a/spec/bundler/commands/viz_spec.rb b/spec/bundler/commands/viz_spec.rb index 0efb24b504..811fc255ef 100644 --- a/spec/bundler/commands/viz_spec.rb +++ b/spec/bundler/commands/viz_spec.rb @@ -2,9 +2,7 @@ RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot") do before do - graphviz_version = RUBY_VERSION >= "2.4" ? "1.2.5" : "1.2.4" - - realworld_system_gems "ruby-graphviz --version #{graphviz_version}" + realworld_system_gems "ruby-graphviz --version 1.2.5" end it "graphs gems from the Gemfile" do diff --git a/spec/bundler/install/bundler_spec.rb b/spec/bundler/install/bundler_spec.rb index ae7c94c31f..e7ec3bc7e7 100644 --- a/spec/bundler/install/bundler_spec.rb +++ b/spec/bundler/install/bundler_spec.rb @@ -210,6 +210,33 @@ RSpec.describe "bundle install" do expect(err).to be_empty end + it "prints the previous version when switching to a previously downloaded gem" do + build_repo4 do + build_gem "rails", "7.0.3" + build_gem "rails", "7.0.4" + end + + bundle "config set path.system true" + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem 'rails', "7.0.4" + G + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem 'rails', "7.0.3" + G + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem 'rails', "7.0.4" + G + + expect(out).to include("Using rails 7.0.4 (was 7.0.3)") + expect(err).to be_empty + end + it "can install dependencies with newer bundler version with system gems" do bundle "config set path.system true" diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index 4ac9f186ec..7d263a2fe5 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -1237,7 +1237,7 @@ RSpec.describe "bundle install with git sources" do s.extensions = ["ext/extconf.rb"] s.write "ext/extconf.rb", <<-RUBY require "mkmf" - $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" + $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] create_makefile("foo") RUBY s.write "ext/foo.c", "void Init_foo() {}" diff --git a/spec/bundler/install/gems/native_extensions_spec.rb b/spec/bundler/install/gems/native_extensions_spec.rb index c3e05586bd..5c18d2cc51 100644 --- a/spec/bundler/install/gems/native_extensions_spec.rb +++ b/spec/bundler/install/gems/native_extensions_spec.rb @@ -7,7 +7,7 @@ RSpec.describe "installing a gem with native extensions" do s.extensions = ["ext/extconf.rb"] s.write "ext/extconf.rb", <<-E require "mkmf" - $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" + $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] name = "c_extension_bundle" dir_config(name) raise "OMG" unless with_config("c_extension") == "hello" @@ -52,7 +52,7 @@ RSpec.describe "installing a gem with native extensions" do s.extensions = ["ext/extconf.rb"] s.write "ext/extconf.rb", <<-E require "mkmf" - $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" + $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] name = "c_extension_bundle" dir_config(name) raise "OMG" unless with_config("c_extension") == "hello" @@ -97,7 +97,7 @@ RSpec.describe "installing a gem with native extensions" do s.extensions = ["ext/extconf.rb"] s.write "ext/extconf.rb", <<-E require "mkmf" - $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" + $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] name = "c_extension_bundle_#{n}" dir_config(name) raise "OMG" unless with_config("c_extension_#{n}") == "#{n}" @@ -150,7 +150,7 @@ RSpec.describe "installing a gem with native extensions" do s.extensions = ["ext/extconf.rb"] s.write "ext/extconf.rb", <<-E require "mkmf" - $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" + $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] name = "c_extension_bundle" dir_config(name) raise "OMG" unless with_config("c_extension") == "hello" && with_config("c_extension_bundle-dir") == "hola" diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index e14b5ff003..6465bea0d2 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -589,8 +589,7 @@ RSpec.describe "major deprecations" do context "bundle viz" do before do - graphviz_version = RUBY_VERSION >= "2.4" ? "1.2.5" : "1.2.4" - realworld_system_gems "ruby-graphviz --version #{graphviz_version}" + realworld_system_gems "ruby-graphviz --version 1.2.5" create_file "gems.rb", "source \"#{file_uri_for(gem_repo1)}\"" bundle "viz" end diff --git a/spec/bundler/quality_es_spec.rb b/spec/bundler/quality_es_spec.rb index 90968e6270..0dbd77e451 100644 --- a/spec/bundler/quality_es_spec.rb +++ b/spec/bundler/quality_es_spec.rb @@ -41,7 +41,7 @@ RSpec.describe "La biblioteca si misma" do included = /ronn/ error_messages = [] man_tracked_files.each do |filename| - next unless filename =~ included + next unless filename&.match?(included) error_messages << check_for_expendable_words(filename) error_messages << check_for_specific_pronouns(filename) end @@ -52,7 +52,7 @@ RSpec.describe "La biblioteca si misma" do error_messages = [] exempt = /vendor/ lib_tracked_files.each do |filename| - next if filename =~ exempt + next if filename&.match?(exempt) error_messages << check_for_expendable_words(filename) error_messages << check_for_specific_pronouns(filename) end diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb index 86a927c361..86e5a51f7f 100644 --- a/spec/bundler/quality_spec.rb +++ b/spec/bundler/quality_spec.rb @@ -12,7 +12,7 @@ RSpec.describe "The library itself" do failing_lines = [] each_line(filename) do |line, number| - failing_lines << number + 1 if line =~ merge_conflicts_regex + failing_lines << number + 1 if line&.match?(merge_conflicts_regex) end return if failing_lines.empty? @@ -32,8 +32,8 @@ RSpec.describe "The library itself" do def check_for_extra_spaces(filename) failing_lines = [] each_line(filename) do |line, number| - next if line =~ /^\s+#.*\s+\n$/ - failing_lines << number + 1 if line =~ /\s+\n$/ + next if /^\s+#.*\s+\n$/.match?(line) + failing_lines << number + 1 if /\s+\n$/.match?(line) end return if failing_lines.empty? @@ -45,7 +45,7 @@ RSpec.describe "The library itself" do failing_lines = [] each_line(filename) do |line, number| - failing_lines << number + 1 if line =~ /’/ + failing_lines << number + 1 if /’/.match?(line) end return if failing_lines.empty? @@ -89,7 +89,7 @@ RSpec.describe "The library itself" do exempt = /\.gitmodules|fixtures|vendor|LICENSE|vcr_cassettes|rbreadline\.diff|index\.txt$/ error_messages = [] tracked_files.each do |filename| - next if filename =~ exempt + next if filename&.match?(exempt) error_messages << check_for_tab_characters(filename) error_messages << check_for_extra_spaces(filename) end @@ -100,7 +100,7 @@ RSpec.describe "The library itself" do exempt = /vendor|vcr_cassettes|LICENSE|rbreadline\.diff/ error_messages = [] tracked_files.each do |filename| - next if filename =~ exempt + next if filename&.match?(exempt) error_messages << check_for_straneous_quotes(filename) end expect(error_messages.compact).to be_well_formed @@ -110,7 +110,7 @@ RSpec.describe "The library itself" do error_messages = [] exempt = %r{lock/lockfile_spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb} tracked_files.each do |filename| - next if filename =~ exempt + next if filename&.match?(exempt) error_messages << check_for_git_merge_conflicts(filename) end expect(error_messages.compact).to be_well_formed @@ -120,7 +120,7 @@ RSpec.describe "The library itself" do included = /ronn/ error_messages = [] man_tracked_files.each do |filename| - next unless filename =~ included + next unless filename&.match?(included) error_messages << check_for_expendable_words(filename) error_messages << check_for_specific_pronouns(filename) end @@ -131,7 +131,7 @@ RSpec.describe "The library itself" do error_messages = [] exempt = /vendor|vcr_cassettes|CODE_OF_CONDUCT/ lib_tracked_files.each do |filename| - next if filename =~ exempt + next if filename&.match?(exempt) error_messages << check_for_expendable_words(filename) error_messages << check_for_specific_pronouns(filename) end @@ -229,7 +229,7 @@ RSpec.describe "The library itself" do exempt = %r{templates/|\.5|\.1|vendor/} all_bad_requires = [] lib_tracked_files.each do |filename| - next if filename =~ exempt + next if filename&.match?(exempt) each_line(filename) do |line, number| line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" } end diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index 044be570b0..f244289c88 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -1304,11 +1304,7 @@ end describe "default gem activation" do let(:exemptions) do - exempts = if Gem.rubygems_version >= Gem::Version.new("2.7") - %w[did_you_mean] - else - %w[io-console openssl] - end << "bundler" + exempts = %w[did_you_mean bundler] exempts << "uri" if Gem.ruby_version >= Gem::Version.new("2.7") exempts << "pathname" if Gem.ruby_version >= Gem::Version.new("3.0") exempts << "set" unless Gem.rubygems_version >= Gem::Version.new("3.2.6") diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb index 2f4a1d45e4..6a7e2891a6 100644 --- a/spec/bundler/spec_helper.rb +++ b/spec/bundler/spec_helper.rb @@ -96,23 +96,21 @@ RSpec.configure do |config| end config.around :each do |example| - begin - FileUtils.cp_r pristine_system_gem_path, system_gem_path - - with_gem_path_as(system_gem_path) do - Bundler.ui.silence { example.run } - - all_output = all_commands_output - if example.exception && !all_output.empty? - message = all_output + "\n" + example.exception.message - (class << example.exception; self; end).send(:define_method, :message) do - message - end + FileUtils.cp_r pristine_system_gem_path, system_gem_path + + with_gem_path_as(system_gem_path) do + Bundler.ui.silence { example.run } + + all_output = all_commands_output + if example.exception && !all_output.empty? + message = all_output + "\n" + example.exception.message + (class << example.exception; self; end).send(:define_method, :message) do + message end end - ensure - reset! end + ensure + reset! end config.after :suite do diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb index 2af11e9874..b4d4976379 100644 --- a/spec/bundler/support/builders.rb +++ b/spec/bundler/support/builders.rb @@ -456,7 +456,7 @@ module Spec write "ext/extconf.rb", <<-RUBY require "mkmf" - $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" + $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] extension_name = "#{name}_c" if extra_lib_dir = with_config("ext-lib") diff --git a/spec/bundler/support/bundle.rb b/spec/bundler/support/bundle.rb index bb21526d35..5f808531ff 100644 --- a/spec/bundler/support/bundle.rb +++ b/spec/bundler/support/bundle.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require "rubygems" +Gem.instance_variable_set(:@ruby, ENV["RUBY"]) if ENV["RUBY"] + require_relative "path" bundler_gemspec = Spec::Path.loaded_gemspec bundler_gemspec.instance_variable_set(:@full_gem_path, Spec::Path.source_root) diff --git a/spec/bundler/support/hax.rb b/spec/bundler/support/hax.rb index 76e3b05ee1..ad7a6e0de9 100644 --- a/spec/bundler/support/hax.rb +++ b/spec/bundler/support/hax.rb @@ -33,11 +33,4 @@ module Gem if ENV["BUNDLER_SPEC_GEM_SOURCES"] self.sources = [ENV["BUNDLER_SPEC_GEM_SOURCES"]] end - - # We only need this hack for rubygems versions without the BundlerVersionFinder - if Gem.rubygems_version < Gem::Version.new("2.7.0") - @path_to_default_spec_map.delete_if do |_path, spec| - spec.name == "bundler" - end - end end diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index 1541f903c7..703c98eca3 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -290,7 +290,7 @@ module Spec if gem_name.start_with?("bundler") version = gem_name.match(/\Abundler-(?<version>.*)\z/)[:version] if gem_name != "bundler" with_built_bundler(version) {|gem_path| install_gem(gem_path, default) } - elsif gem_name =~ %r{\A(?:[a-zA-Z]:)?/.*\.gem\z} + elsif %r{\A(?:[a-zA-Z]:)?/.*\.gem\z}.match?(gem_name) install_gem(gem_name, default) else install_gem("#{gem_repo}/gems/#{gem_name}.gem", default) @@ -486,10 +486,10 @@ module Spec Gem.ruby_version.segments[0..1].map.with_index {|s, i| i == 1 ? s + 1 : s }.join(".") end - # versions providing a bundler version finder but not including + # versions not including # https://github.com/rubygems/rubygems/commit/929e92d752baad3a08f3ac92eaec162cb96aedd1 def rubygems_version_failing_to_activate_bundler_prereleases - Gem.rubygems_version < Gem::Version.new("3.1.0.pre.1") && Gem.rubygems_version >= Gem::Version.new("2.7.0") + Gem.rubygems_version < Gem::Version.new("3.1.0.pre.1") end def revision_for(path) diff --git a/spec/bundler/support/indexes.rb b/spec/bundler/support/indexes.rb index 744dd6e233..670f3b0230 100644 --- a/spec/bundler/support/indexes.rb +++ b/spec/bundler/support/indexes.rb @@ -126,7 +126,7 @@ module Spec next if version == v("1.4.2.1") && platform != pl("x86-mswin32") next if version == v("1.4.2") && platform == pl("x86-mswin32") gem "nokogiri", version, platform do - dep "weakling", ">= 0.0.3" if platform =~ pl("java") + dep "weakling", ">= 0.0.3" if platform =~ pl("java") # rubocop:disable Performance/RegexpMatch end end end diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index c9538f6b36..de03b2746e 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -295,25 +295,11 @@ module Spec end def rubocop_gemfile_basename - filename = if RUBY_VERSION.start_with?("2.3") - "rubocop23_gems" - elsif RUBY_VERSION.start_with?("2.4") - "rubocop24_gems" - else - "rubocop_gems" - end - tool_dir.join("#{filename}.rb") + source_root.join("tool/bundler/rubocop_gems.rb") end def standard_gemfile_basename - filename = if RUBY_VERSION.start_with?("2.3") - "standard23_gems" - elsif RUBY_VERSION.start_with?("2.4") - "standard24_gems" - else - "standard_gems" - end - tool_dir.join("#{filename}.rb") + source_root.join("tool/bundler/standard_gems.rb") end def tool_dir diff --git a/spec/bundler/support/rubygems_version_manager.rb b/spec/bundler/support/rubygems_version_manager.rb index d1b1f8dd03..5653601ae8 100644 --- a/spec/bundler/support/rubygems_version_manager.rb +++ b/spec/bundler/support/rubygems_version_manager.rb @@ -113,7 +113,7 @@ class RubygemsVersionManager end def resolve_target_tag - return "v#{@source}" if @source.match(/^\d/) + return "v#{@source}" if @source.match?(/^\d/) @source end |