diff options
31 files changed, 326 insertions, 352 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 02c2d19c83..f178560938 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -552,7 +552,7 @@ module Bundler method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version." method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group." def viz - SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/rubygems/bundler-graph" + SharedHelpers.major_deprecation 2, "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph" require_relative "cli/viz" Viz.new(options.dup).run end diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index b88e41ea39..ebfc78c031 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -649,25 +649,16 @@ module Bundler end def converge_dependencies - frozen = Bundler.frozen_bundle? (@dependencies + locked_dependencies).each do |dep| - locked_source = @locked_deps[dep.name] - # This is to make sure that if bundler is installing in deployment mode and - # after locked_source and sources don't match, we still use locked_source. - if frozen && !locked_source.nil? && - locked_source.respond_to?(:source) && locked_source.source.instance_of?(Source::Path) && locked_source.source.path.exist? - dep.source = locked_source.source - elsif dep.source + if dep.source dep.source = sources.get(dep.source) end end changes = false - # We want to know if all match, but don't want to check all entries - # This means we need to return false if any dependency doesn't match - # the lock or doesn't exist in the lock. - @dependencies.each do |dependency| - unless locked_dep = @locked_deps[dependency.name] + + @dependencies.each do |dep| + unless locked_dep = @locked_deps[dep.name] changes = true next end @@ -678,11 +669,11 @@ module Bundler # directive, the lockfile dependencies and resolved dependencies end up # with a mismatch on #type. Work around that by setting the type on the # dep from the lockfile. - locked_dep.instance_variable_set(:@type, dependency.type) + locked_dep.instance_variable_set(:@type, dep.type) # We already know the name matches from the hash lookup # so we only need to check the requirement now - changes ||= dependency.requirement != locked_dep.requirement + changes ||= dep.requirement != locked_dep.requirement end changes @@ -692,34 +683,34 @@ module Bundler # commonly happen if the Gemfile has changed since the lockfile was last # generated def converge_locked_specs - deps = [] - - # Build a list of dependencies that are the same in the Gemfile - # and Gemfile.lock. If the Gemfile modified a dependency, but - # the gem in the Gemfile.lock still satisfies it, this is fine - # too. - @dependencies.each do |dep| - locked_dep = @locked_deps[dep.name] + resolve = converge_specs(@locked_specs) - # If the locked_dep doesn't match the dependency we're looking for then we ignore the locked_dep - locked_dep = nil unless locked_dep == dep + diff = nil - if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep) - deps << dep - elsif dep.source.is_a?(Source::Path) && dep.current_platform? && (!locked_dep || dep.source != locked_dep.source) - @locked_specs.each do |s| - @unlock[:gems] << s.name if s.source == dep.source - end + # Now, we unlock any sources that do not have anymore gems pinned to it + sources.all_sources.each do |source| + next unless source.respond_to?(:unlock!) - dep.source.unlock! if dep.source.respond_to?(:unlock!) - dep.source.specs.each {|s| @unlock[:gems] << s.name } + unless resolve.any? {|s| s.source == source } + diff ||= @locked_specs.to_a - resolve.to_a + source.unlock! if diff.any? {|s| s.source == source } end end + resolve + end + + def converge_specs(specs) + deps = [] converged = [] - @locked_specs.each do |s| + specs.each do |s| # Replace the locked dependency's source with the equivalent source from the Gemfile dep = @dependencies.find {|d| s.satisfies?(d) } + + if dep && (!dep.source || s.source.include?(dep.source)) + deps << dep + end + s.source = (dep && dep.source) || sources.get(s.source) unless multisource_allowed? # Don't add a spec to the list if its source is expired. For example, @@ -737,7 +728,7 @@ module Bundler rescue PathError, GitError # if we won't need the source (according to the lockfile), # don't error if the path/git source isn't available - next if @locked_specs. + next if specs. for(requested_dependencies, false, true). none? {|locked_spec| locked_spec.source == s.source } @@ -753,35 +744,15 @@ module Bundler s.dependencies.replace(new_spec.dependencies) end - converged << s - end - - resolve = SpecSet.new(converged) - resolve = SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false).reject{|s| @unlock[:gems].include?(s.name) }) - diff = nil - - # Now, we unlock any sources that do not have anymore gems pinned to it - sources.all_sources.each do |source| - next unless source.respond_to?(:unlock!) - - unless resolve.any? {|s| s.source == source } - diff ||= @locked_specs.to_a - resolve.to_a - source.unlock! if diff.any? {|s| s.source == source } + if dep.nil? && @dependencies.find {|d| s.name == d.name } + @unlock[:gems] << s.name + else + converged << s end end - resolve - end - - def in_locked_deps?(dep, locked_dep) - # Because the lockfile can't link a dep to a specific remote, we need to - # treat sources as equivalent anytime the locked dep has all the remotes - # that the Gemfile dep does. - locked_dep && locked_dep.source && dep.source && locked_dep.source.include?(dep.source) - end - - def satisfies_locked_spec?(dep) - @locked_specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) } + resolve = SpecSet.new(converged) + SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false).reject{|s| @unlock[:gems].include?(s.name) }) end def metadata_dependencies @@ -874,16 +845,11 @@ module Bundler def additional_base_requirements_for_resolve return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources) - dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) } - @locked_gems.specs.reduce({}) do |requirements, locked_spec| + converge_specs(@locked_gems.specs).map do |locked_spec| name = locked_spec.name - dependency = dependencies_by_name[name] - next requirements if @locked_gems.dependencies[name] != dependency - next requirements if dependency && dependency.source.is_a?(Source::Path) dep = Gem::Dependency.new(name, ">= #{locked_spec.version}") - requirements[name] = DepProxy.get_proxy(dep, locked_spec.platform) - requirements - end.values + DepProxy.get_proxy(dep, locked_spec.platform) + end end def equivalent_rubygems_remotes?(source) diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index 60b9e57887..034f2e5960 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -129,8 +129,8 @@ module Bundler def git_push(remote = nil) remote ||= default_remote - sh(%W[git push #{remote} refs/heads/#{current_branch}]) - sh(%W[git push #{remote} refs/tags/#{version_tag}]) + sh("git push #{remote} refs/heads/#{current_branch}".shellsplit) + sh("git push #{remote} refs/tags/#{version_tag}".shellsplit) Bundler.ui.confirm "Pushed git commits and release tag." end diff --git a/lib/bundler/templates/newgem/standard.yml.tt b/lib/bundler/templates/newgem/standard.yml.tt index e720f41031..9e88fbbe8b 100644 --- a/lib/bundler/templates/newgem/standard.yml.tt +++ b/lib/bundler/templates/newgem/standard.yml.tt @@ -1,4 +1,2 @@ # For available configuration options, see: # https://github.com/testdouble/standard - -default_ignores: false diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index a540110962..9abcdbc657 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false module Bundler - VERSION = "2.2.31".freeze + VERSION = "2.2.32".freeze def self.bundler_major_version @bundler_major_version ||= VERSION.split(".").first.to_i diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 717546e3ec..79857b80b9 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = "3.2.31".freeze + VERSION = "3.2.32".freeze end # Must be first since it unloads the prelude from 1.9.2 @@ -1327,22 +1327,6 @@ require_relative 'rubygems/exceptions' # REFACTOR: This should be pulled out into some kind of hacks file. begin ## - # Defaults the operating system (or packager) wants to provide for RubyGems. - - require 'rubygems/defaults/operating_system' -rescue LoadError - # Ignored -rescue StandardError => e - msg = "#{e.message}\n" \ - "Loading the rubygems/defaults/operating_system.rb file caused an error. " \ - "This file is owned by your OS, not by rubygems upstream. " \ - "Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \ - "the problem and ask for help." - raise e.class, msg -end - -begin - ## # Defaults the Ruby implementation wants to provide for RubyGems require "rubygems/defaults/#{RUBY_ENGINE}" @@ -1356,3 +1340,19 @@ Gem::Specification.load_defaults require_relative 'rubygems/core_ext/kernel_gem' require_relative 'rubygems/core_ext/kernel_require' require_relative 'rubygems/core_ext/kernel_warn' + +begin + ## + # Defaults the operating system (or packager) wants to provide for RubyGems. + + require 'rubygems/defaults/operating_system' +rescue LoadError + # Ignored +rescue StandardError => e + msg = "#{e.message}\n" \ + "Loading the rubygems/defaults/operating_system.rb file caused an error. " \ + "This file is owned by your OS, not by rubygems upstream. " \ + "Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \ + "the problem and ask for help." + raise e.class, msg +end diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index dd6dd06eef..10341a9398 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -67,8 +67,6 @@ class Gem::Installer @path_warning = false - @install_lock = Thread::Mutex.new - class << self # # Changes in rubygems to lazily loading `rubygems/command` (in order to @@ -93,12 +91,6 @@ class Gem::Installer attr_accessor :path_warning ## - # Certain aspects of the install process are not thread-safe. This lock is - # used to allow multiple threads to install Gems at the same time. - - attr_reader :install_lock - - ## # Overrides the executable format. # # This is a sprintf format with a "%s" which will be replaced with the @@ -342,7 +334,7 @@ class Gem::Installer say spec.post_install_message if options[:post_install_message] && !spec.post_install_message.nil? - Gem::Installer.install_lock.synchronize { Gem::Specification.reset } + Gem::Specification.reset run_post_install_hooks @@ -527,7 +519,7 @@ class Gem::Installer end def generate_plugins # :nodoc: - latest = Gem::Installer.install_lock.synchronize { Gem::Specification.latest_spec_for(spec.name) } + latest = Gem::Specification.latest_spec_for(spec.name) return if latest && latest.version > spec.version ensure_writable_dir @plugins_dir diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 7e49620381..2b3792ed94 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -102,12 +102,8 @@ class Gem::Specification < Gem::BasicSpecification today = Time.now.utc TODAY = Time.utc(today.year, today.month, today.day) # :nodoc: - # rubocop:disable Style/MutableConstant - LOAD_CACHE = {} # :nodoc: - # rubocop:enable Style/MutableConstant - LOAD_CACHE_MUTEX = Thread::Mutex.new - - private_constant :LOAD_CACHE if defined? private_constant + @load_cache = {} # :nodoc: + @load_cache_mutex = Thread::Mutex.new VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc: @@ -182,13 +178,23 @@ class Gem::Specification < Gem::BasicSpecification @@default_value[k].nil? end - @@stubs = nil - @@stubs_by_name = {} + def self.clear_specs # :nodoc: + @@all_specs_mutex.synchronize do + @@all = nil + @@stubs = nil + @@stubs_by_name = {} + @@spec_with_requirable_file = {} + @@active_stub_with_requirable_file = {} + end + end + private_class_method :clear_specs + + @@all_specs_mutex = Thread::Mutex.new + + clear_specs # Sentinel object to represent "not found" stubs NOT_FOUND = Struct.new(:to_spec, :this).new # :nodoc: - @@spec_with_requirable_file = {} - @@active_stub_with_requirable_file = {} # Tracking removed method calls to warn users during build time. REMOVED_METHODS = [:rubyforge_project=].freeze # :nodoc: @@ -748,23 +754,15 @@ class Gem::Specification < Gem::BasicSpecification attr_accessor :specification_version def self._all # :nodoc: - unless defined?(@@all) && @@all - @@all = stubs.map(&:to_spec) - - # After a reset, make sure already loaded specs - # are still marked as activated. - specs = {} - Gem.loaded_specs.each_value{|s| specs[s] = true } - @@all.each{|s| s.activated = true if specs[s] } - end - @@all + @@all_specs_mutex.synchronize { @@all ||= Gem.loaded_specs.values | stubs.map(&:to_spec) } end - def self._clear_load_cache # :nodoc: - LOAD_CACHE_MUTEX.synchronize do - LOAD_CACHE.clear + def self.clear_load_cache # :nodoc: + @load_cache_mutex.synchronize do + @load_cache.clear end end + private_class_method :clear_load_cache def self.each_gemspec(dirs) # :nodoc: dirs.each do |dir| @@ -1112,7 +1110,7 @@ class Gem::Specification < Gem::BasicSpecification def self.load(file) return unless file - _spec = LOAD_CACHE_MUTEX.synchronize { LOAD_CACHE[file] } + _spec = @load_cache_mutex.synchronize { @load_cache[file] } return _spec if _spec file = file.dup.tap(&Gem::UNTAINT) @@ -1127,12 +1125,12 @@ class Gem::Specification < Gem::BasicSpecification if Gem::Specification === _spec _spec.loaded_from = File.expand_path file.to_s - LOAD_CACHE_MUTEX.synchronize do - prev = LOAD_CACHE[file] + @load_cache_mutex.synchronize do + prev = @load_cache[file] if prev _spec = prev else - LOAD_CACHE[file] = _spec + @load_cache[file] = _spec end end return _spec @@ -1230,12 +1228,8 @@ class Gem::Specification < Gem::BasicSpecification def self.reset @@dirs = nil Gem.pre_reset_hooks.each {|hook| hook.call } - @@all = nil - @@stubs = nil - @@stubs_by_name = {} - @@spec_with_requirable_file = {} - @@active_stub_with_requirable_file = {} - _clear_load_cache + clear_specs + clear_load_cache unresolved = unresolved_deps unless unresolved.empty? w = "W" + "ARN" diff --git a/spec/bundler/bundler/definition_spec.rb b/spec/bundler/bundler/definition_spec.rb index d1cbc8171a..cd70d77cba 100644 --- a/spec/bundler/bundler/definition_spec.rb +++ b/spec/bundler/bundler/definition_spec.rb @@ -49,7 +49,7 @@ RSpec.describe Bundler::Definition do bundle :install, :env => { "DEBUG" => "1" } expect(out).to match(/re-resolving dependencies/) - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: #{lib_path("foo")} specs: @@ -86,7 +86,7 @@ RSpec.describe Bundler::Definition do bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: #{lib_path("foo")} specs: @@ -119,7 +119,7 @@ RSpec.describe Bundler::Definition do bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo1)}/ specs: @@ -145,7 +145,7 @@ RSpec.describe Bundler::Definition do bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo1)}/ specs: diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb index 419deae19b..1fa35136eb 100644 --- a/spec/bundler/commands/check_spec.rb +++ b/spec/bundler/commands/check_spec.rb @@ -433,7 +433,7 @@ RSpec.describe "bundle check" do describe "BUNDLED WITH" do def lock_with(bundler_version = nil) - lock = <<-L + lock = <<~L GEM remote: #{file_uri_for(gem_repo1)}/ specs: @@ -447,7 +447,7 @@ RSpec.describe "bundle check" do L if bundler_version - lock += "\n BUNDLED WITH\n #{bundler_version}\n" + lock += "\nBUNDLED WITH\n #{bundler_version}\n" end lock @@ -466,7 +466,7 @@ RSpec.describe "bundle check" do it "does not change the lock" do lockfile lock_with(nil) bundle :check - lockfile_should_be lock_with(nil) + expect(lockfile).to eq lock_with(nil) end end @@ -475,7 +475,7 @@ RSpec.describe "bundle check" do lockfile lock_with(Bundler::VERSION.succ) bundle :check expect(err).to include("the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ})") - lockfile_should_be lock_with(Bundler::VERSION.succ) + expect(lockfile).to eq lock_with(Bundler::VERSION.succ) end end @@ -484,7 +484,7 @@ RSpec.describe "bundle check" do system_gems "bundler-1.18.0" lockfile lock_with("1.18.0") bundle :check - lockfile_should_be lock_with("1.18.0") + expect(lockfile).to eq lock_with("1.18.0") end end end diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 2c7f0360e6..e00caa5315 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -518,7 +518,7 @@ RSpec.describe "bundle install with gem sources" do end it "writes current Ruby version to Gemfile.lock" do - lockfile_should_be <<-L + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo1)}/ specs: @@ -544,7 +544,7 @@ RSpec.describe "bundle install with gem sources" do source "#{file_uri_for(gem_repo1)}" G - lockfile_should_be <<-L + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo1)}/ specs: diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index 171ec1ba1d..22709f4528 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -314,7 +314,7 @@ RSpec.describe "bundle lock" do simulate_platform(mingw) { bundle :lock } - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo4)}/ specs: @@ -339,7 +339,7 @@ RSpec.describe "bundle lock" do simulate_platform(rb) { bundle :lock } - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo4)}/ specs: @@ -426,7 +426,7 @@ RSpec.describe "bundle lock" do simulate_platform(Gem::Platform.new("x86_64-darwin")) { bundle "lock" } - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo4)}/ specs: diff --git a/spec/bundler/commands/remove_spec.rb b/spec/bundler/commands/remove_spec.rb index 9e2586bae6..70dc09c9b6 100644 --- a/spec/bundler/commands/remove_spec.rb +++ b/spec/bundler/commands/remove_spec.rb @@ -41,7 +41,7 @@ RSpec.describe "bundle remove" do expect(out).to include("rack was removed.") expect(the_bundle).to_not include_gems "rack" - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -61,7 +61,7 @@ RSpec.describe "bundle remove" do bundle "remove rack" expect(out).to include("rack was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source '#{file_uri_for(gem_repo1)}' gem 'git' @@ -98,7 +98,7 @@ RSpec.describe "bundle remove" do expect(out).to include("rack was removed.") expect(out).to include("rails was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -117,7 +117,7 @@ RSpec.describe "bundle remove" do bundle "remove rails rack minitest", :raise_on_error => false expect(err).to include("`rack` is not specified in #{bundled_app_gemfile} so it could not be removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" gem "rails" @@ -139,7 +139,7 @@ RSpec.describe "bundle remove" do bundle "remove rack" expect(out).to include("rack was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -159,7 +159,7 @@ RSpec.describe "bundle remove" do bundle "remove rspec" expect(out).to include("rspec was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -179,7 +179,7 @@ RSpec.describe "bundle remove" do bundle "remove rack" expect(out).to include("rack was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" group :test do @@ -205,7 +205,7 @@ RSpec.describe "bundle remove" do bundle "remove rspec" expect(out).to include("rspec was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -224,7 +224,7 @@ RSpec.describe "bundle remove" do bundle "remove rspec" expect(out).to include("rspec was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -247,7 +247,7 @@ RSpec.describe "bundle remove" do bundle "remove rspec" expect(out).to include("rspec was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -270,7 +270,7 @@ RSpec.describe "bundle remove" do bundle "remove rspec" expect(out).to include("rspec was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -293,7 +293,7 @@ RSpec.describe "bundle remove" do bundle "remove rspec" expect(out).to include("rspec was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" group :test do @@ -320,7 +320,7 @@ RSpec.describe "bundle remove" do bundle "remove rspec" expect(out).to include("rspec was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" group :test do @@ -344,7 +344,7 @@ RSpec.describe "bundle remove" do bundle "remove rails", :raise_on_error => false expect(err).to include("Gems could not be removed. rack (>= 0) would also have been removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" gem "rack"; gem "rails" G @@ -366,7 +366,7 @@ RSpec.describe "bundle remove" do expect(out).to include("rails was removed.") expect(out).to include("minitest was removed.") expect(out).to include("rack, rspec could not be removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" gem"rack" gem"rspec" @@ -398,7 +398,7 @@ RSpec.describe "bundle remove" do bundle "remove rspec" expect(out).to include("rspec was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -482,7 +482,7 @@ RSpec.describe "bundle remove" do expect(out).to include("rack was removed.") expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile-other")} so it could not be removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" eval_gemfile "Gemfile-other" @@ -507,7 +507,7 @@ RSpec.describe "bundle remove" do expect(out).to include("rack was removed.") expect(err).to include("Gems could not be removed. rails (>= 0) would also have been removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" eval_gemfile "Gemfile-other" @@ -532,7 +532,7 @@ RSpec.describe "bundle remove" do expect(err).to include("Gems could not be removed. rails (>= 0) would also have been removed.") expect(bundled_app("Gemfile-other").read).to include("gem \"rack\"") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" eval_gemfile "Gemfile-other" @@ -575,7 +575,7 @@ RSpec.describe "bundle remove" do bundle "remove rack" expect(out).to include("rack was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -594,7 +594,7 @@ RSpec.describe "bundle remove" do bundle "remove rack" expect(out).to include("rack was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -631,7 +631,7 @@ RSpec.describe "bundle remove" do bundle "remove rack" expect(out).to include("rack was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" # gem "rack" might be used in the future @@ -650,7 +650,7 @@ RSpec.describe "bundle remove" do bundle "remove rack" expect(out).to include("rack was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" G end @@ -669,7 +669,7 @@ RSpec.describe "bundle remove" do expect(out).to_not include("puma was removed.") expect(out).to include("rack was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" gem "puma" # implements interface provided by gem "rack" G @@ -689,7 +689,7 @@ RSpec.describe "bundle remove" do expect(out).to include("puma was removed.") expect(out).to_not include("rack was removed.") - gemfile_should_be <<-G + expect(gemfile).to eq <<~G source "#{file_uri_for(gem_repo1)}" gem "rack" diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index 14fe3e245b..403a48a508 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -354,6 +354,67 @@ RSpec.describe "bundle update" do expect(the_bundle).to include_gems("a 1.0", "b 1.0") end + + it "should still downgrade if forced by the Gemfile, when transitive dependencies also need downgrade" do + build_repo4 do + build_gem "activesupport", "6.1.4.1" do |s| + s.add_dependency "tzinfo", "~> 2.0" + end + + build_gem "activesupport", "6.0.4.1" do |s| + s.add_dependency "tzinfo", "~> 1.1" + end + + build_gem "tzinfo", "2.0.4" + build_gem "tzinfo", "1.2.9" + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "activesupport", "~> 6.1.0" + G + + expect(the_bundle).to include_gems("activesupport 6.1.4.1", "tzinfo 2.0.4") + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "activesupport", "~> 6.0.0" + G + + original_lockfile = lockfile + + expected_lockfile = <<~L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + activesupport (6.0.4.1) + tzinfo (~> 1.1) + tzinfo (1.2.9) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + activesupport (~> 6.0.0) + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "update activesupport" + expect(the_bundle).to include_gems("activesupport 6.0.4.1", "tzinfo 1.2.9") + expect(lockfile).to eq(expected_lockfile) + + lockfile original_lockfile + bundle "update" + expect(the_bundle).to include_gems("activesupport 6.0.4.1", "tzinfo 1.2.9") + expect(lockfile).to eq(expected_lockfile) + + lockfile original_lockfile + bundle "lock --update" + expect(the_bundle).to include_gems("activesupport 6.0.4.1", "tzinfo 1.2.9") + expect(lockfile).to eq(expected_lockfile) + end end describe "with --local option" do @@ -939,7 +1000,7 @@ RSpec.describe "bundle update --ruby" do it "removes the Ruby from the Gemfile.lock" do bundle "update --ruby" - lockfile_should_be <<-L + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo1)}/ specs: @@ -967,7 +1028,7 @@ RSpec.describe "bundle update --ruby" do it "updates the Gemfile.lock with the latest version" do bundle "update --ruby" - lockfile_should_be <<-L + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo1)}/ specs: @@ -1014,7 +1075,7 @@ RSpec.describe "bundle update --ruby" do it "updates the Gemfile.lock with the latest version" do bundle "update --ruby" - lockfile_should_be <<-L + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo1)}/ specs: diff --git a/spec/bundler/install/gemfile/install_if_spec.rb b/spec/bundler/install/gemfile/install_if_spec.rb index 786e0e9258..3d2d15a698 100644 --- a/spec/bundler/install/gemfile/install_if_spec.rb +++ b/spec/bundler/install/gemfile/install_if_spec.rb @@ -18,7 +18,7 @@ RSpec.describe "bundle install with install_if conditionals" do expect(the_bundle).not_to include_gems("thin") expect(the_bundle).not_to include_gems("foo") - lockfile_should_be <<-L + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo1)}/ specs: diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb index 566fdcf65a..4143b04c2a 100644 --- a/spec/bundler/install/gemfile/path_spec.rb +++ b/spec/bundler/install/gemfile/path_spec.rb @@ -127,9 +127,9 @@ RSpec.describe "bundle install with explicit source paths" do L bundle :install, :dir => lib_path("demo") - expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile) + expect(lib_path("demo/Gemfile.lock")).to read_as(lockfile) bundle :update, :all => true, :dir => lib_path("demo") - expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile) + expect(lib_path("demo/Gemfile.lock")).to read_as(lockfile) end it "expands paths when comparing locked paths to Gemfile paths" do @@ -552,7 +552,7 @@ RSpec.describe "bundle install with explicit source paths" do expect(the_bundle).to include_gems "rack 0.9.1" - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: #{lib_path("foo")} specs: @@ -580,7 +580,7 @@ RSpec.describe "bundle install with explicit source paths" do bundle "install" - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: #{lib_path("foo")} specs: @@ -614,7 +614,7 @@ RSpec.describe "bundle install with explicit source paths" do expect(the_bundle).to include_gems "rack 0.9.1" - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: #{lib_path("foo")} specs: @@ -643,7 +643,7 @@ RSpec.describe "bundle install with explicit source paths" do bundle "install" - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: #{lib_path("foo")} specs: diff --git a/spec/bundler/install/gemfile/platform_spec.rb b/spec/bundler/install/gemfile/platform_spec.rb index 7cd06b7e08..221c52c448 100644 --- a/spec/bundler/install/gemfile/platform_spec.rb +++ b/spec/bundler/install/gemfile/platform_spec.rb @@ -128,7 +128,7 @@ RSpec.describe "bundle install across platforms" do gem "pry" G - lockfile_should_be <<-L + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo4)}/ specs: @@ -156,7 +156,7 @@ RSpec.describe "bundle install across platforms" do bundle "lock --add-platform ruby" - good_lockfile = strip_whitespace(<<-L) + good_lockfile = <<~L GEM remote: #{file_uri_for(gem_repo4)}/ specs: @@ -186,9 +186,9 @@ RSpec.describe "bundle install across platforms" do #{Bundler::VERSION} L - lockfile_should_be good_lockfile + expect(lockfile).to eq good_lockfile - bad_lockfile = strip_whitespace <<-L + bad_lockfile = <<~L GEM remote: #{file_uri_for(gem_repo4)}/ specs: @@ -222,23 +222,23 @@ RSpec.describe "bundle install across platforms" do aggregate_failures do lockfile bad_lockfile bundle :install - lockfile_should_be good_lockfile + expect(lockfile).to eq good_lockfile lockfile bad_lockfile bundle :update, :all => true - lockfile_should_be good_lockfile + expect(lockfile).to eq good_lockfile lockfile bad_lockfile bundle "update ffi" - lockfile_should_be good_lockfile + expect(lockfile).to eq good_lockfile lockfile bad_lockfile bundle "update empyrean" - lockfile_should_be good_lockfile + expect(lockfile).to eq good_lockfile lockfile bad_lockfile bundle :lock - lockfile_should_be good_lockfile + expect(lockfile).to eq good_lockfile end end @@ -310,7 +310,7 @@ RSpec.describe "bundle install across platforms" do expect(the_bundle).to include_gem "platform_specific 1.0 RUBY" - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo1)}/ specs: @@ -447,7 +447,7 @@ RSpec.describe "bundle install with platform conditionals" do expect(err).to be_empty - lockfile_should_be <<-L + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo1)}/ specs: diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb index 19ac8c6b78..ce2823ce9a 100644 --- a/spec/bundler/install/gemfile/specific_platform_spec.rb +++ b/spec/bundler/install/gemfile/specific_platform_spec.rb @@ -87,7 +87,7 @@ RSpec.describe "bundle install with specific platforms" do expect(the_bundle).to include_gem("google-protobuf 3.0.0.alpha.5.0.5.1 universal-darwin") # make sure we're still only locked to ruby - lockfile_should_be <<-L + expect(lockfile).to eq <<~L GEM remote: #{file_uri_for(gem_repo2)}/ specs: diff --git a/spec/bundler/install/gems/flex_spec.rb b/spec/bundler/install/gems/flex_spec.rb index 326ec51214..f9b374cf01 100644 --- a/spec/bundler/install/gems/flex_spec.rb +++ b/spec/bundler/install/gems/flex_spec.rb @@ -229,14 +229,27 @@ RSpec.describe "bundle flex_install" do G end - it "does something" do - expect do - bundle "install", :raise_on_error => false - end.not_to change { File.read(bundled_app_lock) } - - expect(err).to include("rack = 0.9.1") - expect(err).to include("locked at 1.0.0") - expect(err).to include("bundle update rack") + it "should work when you install" do + bundle "install" + + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + rack (0.9.1) + rack-obama (1.0) + rack + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack (= 0.9.1) + rack-obama + + BUNDLED WITH + #{Bundler::VERSION} + L end it "should work when you update" do @@ -259,24 +272,24 @@ RSpec.describe "bundle flex_install" do gem "rack" G - lockfile_should_be <<-L - GEM - remote: #{file_uri_for(gem_repo1)}/ - specs: - rack (1.0.0) + expect(lockfile).to eq <<~L + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + rack (1.0.0) - GEM - remote: #{file_uri_for(gem_repo2)}/ - specs: + GEM + remote: #{file_uri_for(gem_repo2)}/ + specs: - PLATFORMS - #{lockfile_platforms} + PLATFORMS + #{lockfile_platforms} - DEPENDENCIES - rack + DEPENDENCIES + rack - BUNDLED WITH - #{Bundler::VERSION} + BUNDLED WITH + #{Bundler::VERSION} L end end diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 9170efeedd..8befb0d400 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -22,7 +22,7 @@ RSpec.describe "the lockfile format" do gem "rack" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -70,7 +70,7 @@ RSpec.describe "the lockfile format" do gem "rack" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -112,7 +112,7 @@ RSpec.describe "the lockfile format" do gem "rack" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -149,7 +149,7 @@ RSpec.describe "the lockfile format" do gem "rack", "> 0" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -199,7 +199,7 @@ RSpec.describe "the lockfile format" do "lockfile by running `gem install bundler:#{newer_minor}`." expect(err).to include warning_message - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -249,7 +249,7 @@ RSpec.describe "the lockfile format" do "lockfile by running `gem install bundler:#{newer_minor} --pre`." expect(err).to include warning_message - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -295,7 +295,7 @@ RSpec.describe "the lockfile format" do expect(err).to be_empty - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -345,7 +345,7 @@ RSpec.describe "the lockfile format" do "#{current_version.split(".").first}, after which you will be unable to return to Bundler #{older_major.split(".").first}." ) - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -369,7 +369,7 @@ RSpec.describe "the lockfile format" do gem "rack-obama" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -395,7 +395,7 @@ RSpec.describe "the lockfile format" do gem "rack-obama", ">= 1.0" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -429,7 +429,7 @@ RSpec.describe "the lockfile format" do end G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo1)}/ specs: @@ -462,7 +462,7 @@ RSpec.describe "the lockfile format" do gem "net-sftp" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -491,7 +491,7 @@ RSpec.describe "the lockfile format" do gem "foo", :git => "#{lib_path("foo-1.0")}" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GIT remote: #{lib_path("foo-1.0")} revision: #{git.ref_for("master")} @@ -562,7 +562,7 @@ RSpec.describe "the lockfile format" do end G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GIT remote: #{lib_path("foo-1.0")} revision: #{git.ref_for("master")} @@ -593,7 +593,7 @@ RSpec.describe "the lockfile format" do gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GIT remote: #{lib_path("foo-1.0")} revision: #{git.ref_for("omg")} @@ -625,7 +625,7 @@ RSpec.describe "the lockfile format" do gem "foo", :git => "#{lib_path("foo-1.0")}", :tag => "omg" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GIT remote: #{lib_path("foo-1.0")} revision: #{git.ref_for("omg")} @@ -656,7 +656,7 @@ RSpec.describe "the lockfile format" do gem "foo", :path => "#{lib_path("foo-1.0")}" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: #{lib_path("foo-1.0")} specs: @@ -689,7 +689,7 @@ RSpec.describe "the lockfile format" do bundle :cache bundle :install, :local => true - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: #{lib_path("foo-1.0")} specs: @@ -722,7 +722,7 @@ RSpec.describe "the lockfile format" do gem "bar", :git => "#{lib_path("bar-1.0")}" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GIT remote: #{lib_path("bar-1.0")} revision: #{bar.ref_for("master")} @@ -759,7 +759,7 @@ RSpec.describe "the lockfile format" do gem "rack", :source => "#{file_uri_for(gem_repo2)}/" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -785,7 +785,7 @@ RSpec.describe "the lockfile format" do gem "rack-obama" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -818,7 +818,7 @@ RSpec.describe "the lockfile format" do gem "rails" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -856,7 +856,7 @@ RSpec.describe "the lockfile format" do gem 'double_deps' G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -883,7 +883,7 @@ RSpec.describe "the lockfile format" do gem "rack-obama", ">= 1.0", :require => "rack/obama" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -909,7 +909,7 @@ RSpec.describe "the lockfile format" do gem "rack-obama", ">= 1.0", :group => :test G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -938,7 +938,7 @@ RSpec.describe "the lockfile format" do end G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: foo specs: @@ -969,7 +969,7 @@ RSpec.describe "the lockfile format" do end G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: ../foo specs: @@ -1000,7 +1000,7 @@ RSpec.describe "the lockfile format" do end G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: foo specs: @@ -1029,7 +1029,7 @@ RSpec.describe "the lockfile format" do gemspec :path => "../foo" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PATH remote: ../foo specs: @@ -1073,7 +1073,7 @@ RSpec.describe "the lockfile format" do gem "rack" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -1104,7 +1104,7 @@ RSpec.describe "the lockfile format" do gem "platform_specific" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -1133,7 +1133,7 @@ RSpec.describe "the lockfile format" do gem "activesupport" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -1159,7 +1159,7 @@ RSpec.describe "the lockfile format" do gem "rack" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -1183,7 +1183,7 @@ RSpec.describe "the lockfile format" do gem "rack", "1.0" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -1207,7 +1207,7 @@ RSpec.describe "the lockfile format" do gem "rack", "1.0", :group => :two G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -1252,7 +1252,7 @@ RSpec.describe "the lockfile format" do gem "rack", "> 0.9", "< 1.0" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: @@ -1276,7 +1276,7 @@ RSpec.describe "the lockfile format" do gem "rack", "> 0.9", "< 1.0" G - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GEM remote: #{file_uri_for(gem_repo2)}/ specs: diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index d59f64662d..b228027c03 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -665,7 +665,7 @@ The :gist git source is deprecated, and will be removed in the future. Add this end it "prints a deprecation warning", :bundler => "< 3" do - expect(deprecations).to include "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/rubygems/bundler-graph" + expect(deprecations).to include "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph" end pending "fails with a helpful message", :bundler => "3" diff --git a/spec/bundler/plugins/source/example_spec.rb b/spec/bundler/plugins/source/example_spec.rb index e2bab9c199..7d098997ec 100644 --- a/spec/bundler/plugins/source/example_spec.rb +++ b/spec/bundler/plugins/source/example_spec.rb @@ -70,7 +70,7 @@ RSpec.describe "real source plugins" do it "writes to lock file" do bundle "install" - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PLUGIN SOURCE remote: #{lib_path("a-path-gem-1.0")} type: mpath @@ -342,7 +342,7 @@ RSpec.describe "real source plugins" do revision = revision_for(lib_path("ma-gitp-gem-1.0")) bundle "install" - lockfile_should_be <<-G + expect(lockfile).to eq <<~G PLUGIN SOURCE remote: #{file_uri_for(lib_path("ma-gitp-gem-1.0"))} type: gitp diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index 00fed52011..804e29c3c1 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -1135,7 +1135,7 @@ end describe "when BUNDLED WITH" do def lock_with(bundler_version = nil) - lock = <<-L + lock = <<~L GEM remote: #{file_uri_for(gem_repo1)}/ specs: @@ -1149,7 +1149,7 @@ end L if bundler_version - lock += "\n BUNDLED WITH\n #{bundler_version}\n" + lock += "\nBUNDLED WITH\n #{bundler_version}\n" end lock @@ -1168,7 +1168,7 @@ end it "does not change the lock" do lockfile lock_with(nil) ruby "require '#{entrypoint}/setup'" - lockfile_should_be lock_with(nil) + expect(lockfile).to eq lock_with(nil) end end @@ -1178,7 +1178,7 @@ end ruby "require 'bundler/setup'" expect(out).to be_empty expect(err).to be_empty - lockfile_should_be lock_with(Bundler::VERSION.succ) + expect(lockfile).to eq lock_with(Bundler::VERSION.succ) end end @@ -1187,7 +1187,7 @@ end system_gems "bundler-1.10.1" lockfile lock_with("1.10.1") ruby "require '#{entrypoint}/setup'" - lockfile_should_be lock_with("1.10.1") + expect(lockfile).to eq lock_with("1.10.1") end end end @@ -1196,7 +1196,7 @@ end let(:ruby_version) { nil } def lock_with(ruby_version = nil) - lock = <<-L + lock = <<~L GEM remote: #{file_uri_for(gem_repo1)}/ specs: @@ -1210,10 +1210,10 @@ end L if ruby_version - lock += "\n RUBY VERSION\n ruby #{ruby_version}\n" + lock += "\nRUBY VERSION\n ruby #{ruby_version}\n" end - lock += <<-L + lock += <<~L BUNDLED WITH #{Bundler::VERSION} diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb index 180ad54c5b..3c2a7f9f58 100644 --- a/spec/bundler/support/matchers.rb +++ b/spec/bundler/support/matchers.rb @@ -208,10 +208,6 @@ module Spec RSpec::Matchers.define_negated_matcher :not_include_gems, :include_gems RSpec::Matchers.alias_matcher :include_gem, :include_gems - def have_lockfile(expected) - read_as(strip_whitespace(expected)) - end - def plugin_should_be_installed(*names) names.each do |name| expect(Bundler::Plugin).to be_installed(name) @@ -225,13 +221,5 @@ module Spec expect(Bundler::Plugin).not_to be_installed(name) end end - - def lockfile_should_be(expected) - expect(bundled_app_lock).to have_lockfile(expected) - end - - def gemfile_should_be(expected) - expect(bundled_app_gemfile).to read_as(strip_whitespace(expected)) - end end end diff --git a/spec/bundler/update/git_spec.rb b/spec/bundler/update/git_spec.rb index f35d5857c6..0787ee41a7 100644 --- a/spec/bundler/update/git_spec.rb +++ b/spec/bundler/update/git_spec.rb @@ -293,7 +293,7 @@ RSpec.describe "bundle update" do G end - it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "< 3" do + it "the --source flag updates version of gems that were originally pulled in by the source" do spec_lines = lib_path("bar/foo.gemspec").read.split("\n") spec_lines[5] = "s.version = '2.0'" @@ -305,43 +305,7 @@ RSpec.describe "bundle update" do bundle "update --source bar" - lockfile_should_be <<-G - GIT - remote: #{@git.path} - revision: #{ref} - specs: - foo (2.0) - - GEM - remote: #{file_uri_for(gem_repo2)}/ - specs: - rack (1.0.0) - - PLATFORMS - #{lockfile_platforms} - - DEPENDENCIES - foo! - rack - - BUNDLED WITH - #{Bundler::VERSION} - G - end - - it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "3" do - spec_lines = lib_path("bar/foo.gemspec").read.split("\n") - spec_lines[5] = "s.version = '2.0'" - - update_git "foo", "2.0", :path => @git.path do |s| - s.write "foo.gemspec", spec_lines.join("\n") - end - - ref = @git.ref_for "master" - - bundle "update --source bar" - - lockfile_should_be <<-G + expect(lockfile).to eq <<~G GIT remote: #{@git.path} revision: #{ref} diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb index 9bd194f871..a09d0783f6 100644 --- a/test/rubygems/helper.rb +++ b/test/rubygems/helper.rb @@ -247,16 +247,14 @@ class Gem::TestCase < Test::Unit::TestCase output.scan(/^#{Regexp.escape make_command}(?:[[:blank:]].*)?$/) end - def parse_make_command_line(line) - command, *args = line.shellsplit + def parse_make_command_line_targets(line) + args = line.sub(/^#{Regexp.escape make_command}/, "").shellsplit targets = [] - macros = {} args.each do |arg| case arg when /\A(\w+)=/ - macros[$1] = $' else targets << arg end @@ -264,11 +262,7 @@ class Gem::TestCase < Test::Unit::TestCase targets << '' if targets.empty? - { - :command => command, - :targets => targets, - :macros => macros, - } + targets end def assert_contains_make_command(target, output, msg = nil) @@ -281,7 +275,7 @@ class Gem::TestCase < Test::Unit::TestCase ) else msg = build_message(msg, - 'Expected make command "%s": %s' % [ + 'Expected make command "%s", but was "%s"' % [ ('%s %s' % [make_command, target]).rstrip, output, ] @@ -289,10 +283,9 @@ class Gem::TestCase < Test::Unit::TestCase end assert scan_make_command_lines(output).any? {|line| - make = parse_make_command_line(line) + targets = parse_make_command_line_targets(line) - if make[:targets].include?(target) - yield make, line if block_given? + if targets.include?(target) true else false @@ -489,7 +482,6 @@ class Gem::TestCase < Test::Unit::TestCase Gem.instance_variable_set :@default_dir, nil end - Gem::Specification._clear_load_cache Gem::Specification.unresolved_deps.clear Gem::refresh diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb index 70833f35cf..10a544cbbc 100644 --- a/test/rubygems/test_gem_ext_ext_conf_builder.rb +++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb @@ -66,8 +66,11 @@ class TestGemExtExtConfBuilder < Gem::TestCase end end - def test_class_build_env_make - env_make = ENV.delete 'MAKE' + def test_class_build_env_MAKE + env_make = ENV.delete 'make' + ENV['make'] = nil + + env_MAKE = ENV.delete 'MAKE' ENV['MAKE'] = 'anothermake' if java_platform? @@ -89,7 +92,8 @@ class TestGemExtExtConfBuilder < Gem::TestCase assert_contains_make_command 'clean', output[4] end ensure - ENV['MAKE'] = env_make + ENV['MAKE'] = env_MAKE + ENV['make'] = env_make end def test_class_build_extconf_fail diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb index 07e412cc76..4d0301742e 100644 --- a/test/rubygems/test_require.rb +++ b/test/rubygems/test_require.rb @@ -466,8 +466,7 @@ class TestGemRequire < Gem::TestCase end def test_realworld_default_gem - testing_ruby_repo = !ENV["GEM_COMMAND"].nil? - pend "this test can't work under ruby-core setup" if testing_ruby_repo || java_platform? + omit "this test can't work under ruby-core setup" if testing_ruby_repo? cmd = <<-RUBY $stderr = $stdout @@ -480,8 +479,7 @@ class TestGemRequire < Gem::TestCase end def test_realworld_upgraded_default_gem - testing_ruby_repo = !ENV["GEM_COMMAND"].nil? - pend "this test can't work under ruby-core setup" if testing_ruby_repo + omit "this test can't work under ruby-core setup" if testing_ruby_repo? newer_json = util_spec("json", "999.99.9", nil, ["lib/json.rb"]) install_gem newer_json @@ -720,6 +718,10 @@ class TestGemRequire < Gem::TestCase private + def testing_ruby_repo? + !ENV["GEM_COMMAND"].nil? + end + def silence_warnings old_verbose, $VERBOSE = $VERBOSE, false yield diff --git a/tool/bundler/rubocop_gems.rb.lock b/tool/bundler/rubocop_gems.rb.lock index 60a385f865..c3d9f4b562 100644 --- a/tool/bundler/rubocop_gems.rb.lock +++ b/tool/bundler/rubocop_gems.rb.lock @@ -26,20 +26,20 @@ GEM rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) - rspec-support (3.10.2) - rubocop (1.21.0) + rspec-support (3.10.3) + rubocop (1.23.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.9.1, < 2.0) + rubocop-ast (>= 1.12.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.11.0) + rubocop-ast (1.13.0) parser (>= 3.0.1.1) ruby-progressbar (1.11.0) - test-unit (3.4.7) + test-unit (3.5.1) power_assert unicode-display_width (2.1.0) @@ -58,4 +58,4 @@ DEPENDENCIES test-unit BUNDLED WITH - 2.2.31 + 2.2.32 diff --git a/tool/bundler/standard_gems.rb.lock b/tool/bundler/standard_gems.rb.lock index 326d88b5a7..5edb9a1120 100644 --- a/tool/bundler/standard_gems.rb.lock +++ b/tool/bundler/standard_gems.rb.lock @@ -26,26 +26,26 @@ GEM rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) - rspec-support (3.10.2) - rubocop (1.20.0) + rspec-support (3.10.3) + rubocop (1.22.3) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.9.1, < 2.0) + rubocop-ast (>= 1.12.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.11.0) + rubocop-ast (1.13.0) parser (>= 3.0.1.1) rubocop-performance (1.11.5) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) ruby-progressbar (1.11.0) - standard (1.3.0) - rubocop (= 1.20.0) + standard (1.4.0) + rubocop (= 1.22.3) rubocop-performance (= 1.11.5) - test-unit (3.4.7) + test-unit (3.5.1) power_assert unicode-display_width (2.1.0) diff --git a/tool/bundler/test_gems.rb.lock b/tool/bundler/test_gems.rb.lock index bcff1fce9c..de1c247cac 100644 --- a/tool/bundler/test_gems.rb.lock +++ b/tool/bundler/test_gems.rb.lock @@ -13,7 +13,7 @@ GEM rack-test (1.1.0) rack (>= 1.0, < 3) rake (13.0.1) - ruby2_keywords (0.0.2) + ruby2_keywords (0.0.5) sinatra (2.0.8.1) mustermann (~> 1.0) rack (~> 2.0) @@ -40,4 +40,4 @@ DEPENDENCIES webrick (= 1.7.0) BUNDLED WITH - 2.2.31 + 2.2.32 |