mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	
							parent
							
								
									bd8df25cdc
								
							
						
					
					
						commit
						aeea88174d
					
				
					 43 changed files with 121 additions and 95 deletions
				
			
		| 
						 | 
				
			
			@ -40,7 +40,7 @@ module Bundler
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    def self.verbalize_groups(groups)
 | 
			
		||||
      groups.map!{|g| "'#{g}'" }
 | 
			
		||||
      groups.map! {|g| "'#{g}'" }
 | 
			
		||||
      group_list = [groups[0...-1].join(", "), groups[-1..-1]].
 | 
			
		||||
        reject {|s| s.to_s.empty? }.join(" and ")
 | 
			
		||||
      group_str = groups.size == 1 ? "group" : "groups"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -261,7 +261,7 @@ module Bundler
 | 
			
		|||
          @locked_specs
 | 
			
		||||
        elsif !unlocking? && nothing_changed?
 | 
			
		||||
          Bundler.ui.debug("Found no changes, using resolution from the lockfile")
 | 
			
		||||
          SpecSet.new(filter_specs(@locked_specs, @dependencies.select{|dep| @locked_specs[dep].any? }))
 | 
			
		||||
          SpecSet.new(filter_specs(@locked_specs, @dependencies.select {|dep| @locked_specs[dep].any? }))
 | 
			
		||||
        else
 | 
			
		||||
          last_resolve = converge_locked_specs
 | 
			
		||||
          # Run a resolve against the locally available gems
 | 
			
		||||
| 
						 | 
				
			
			@ -731,7 +731,7 @@ module Bundler
 | 
			
		|||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      SpecSet.new(filter_specs(converged, deps).reject{|s| @unlock[:gems].include?(s.name) })
 | 
			
		||||
      SpecSet.new(filter_specs(converged, deps).reject {|s| @unlock[:gems].include?(s.name) })
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def metadata_dependencies
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ module Bundler
 | 
			
		|||
      @gemfile = expanded_gemfile_path
 | 
			
		||||
      @gemfiles << expanded_gemfile_path
 | 
			
		||||
      contents ||= Bundler.read_file(@gemfile.to_s)
 | 
			
		||||
      instance_eval(contents.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
 | 
			
		||||
      instance_eval(contents.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
 | 
			
		||||
    rescue Exception => e # rubocop:disable Lint/RescueException
 | 
			
		||||
      message = "There was an error " \
 | 
			
		||||
        "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,7 +48,7 @@ module Bundler
 | 
			
		|||
      sorted_matching = matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) }
 | 
			
		||||
      exemplary_spec = sorted_matching.first
 | 
			
		||||
 | 
			
		||||
      sorted_matching.take_while{|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
 | 
			
		||||
      sorted_matching.take_while {|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
 | 
			
		||||
    end
 | 
			
		||||
    module_function :select_best_platform_match
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ module Bundler
 | 
			
		|||
      base = SpecSet.new(base) unless base.is_a?(SpecSet)
 | 
			
		||||
      resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
 | 
			
		||||
      result = resolver.start(requirements)
 | 
			
		||||
      SpecSet.new(SpecSet.new(result).for(requirements.reject{|dep| dep.name.end_with?("\0") }))
 | 
			
		||||
      SpecSet.new(SpecSet.new(result).for(requirements.reject {|dep| dep.name.end_with?("\0") }))
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,7 +34,7 @@ module Gem
 | 
			
		|||
 | 
			
		||||
    def full_gem_path
 | 
			
		||||
      if source.respond_to?(:root)
 | 
			
		||||
        Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
 | 
			
		||||
        Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
 | 
			
		||||
      else
 | 
			
		||||
        rg_full_gem_path
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,13 +13,13 @@ module Bundler
 | 
			
		|||
    def root
 | 
			
		||||
      gemfile = find_gemfile
 | 
			
		||||
      raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
 | 
			
		||||
      Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
 | 
			
		||||
      Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def default_gemfile
 | 
			
		||||
      gemfile = find_gemfile
 | 
			
		||||
      raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
 | 
			
		||||
      Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
 | 
			
		||||
      Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def default_lockfile
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ module Bundler
 | 
			
		|||
      case gemfile.basename.to_s
 | 
			
		||||
      when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
 | 
			
		||||
      else Pathname.new("#{gemfile}.lock")
 | 
			
		||||
      end.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
 | 
			
		||||
      end.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def default_bundle_dir
 | 
			
		||||
| 
						 | 
				
			
			@ -100,7 +100,7 @@ module Bundler
 | 
			
		|||
    #
 | 
			
		||||
    # @see {Bundler::PermissionError}
 | 
			
		||||
    def filesystem_access(path, action = :write, &block)
 | 
			
		||||
      yield(path.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" })
 | 
			
		||||
      yield(path.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" })
 | 
			
		||||
    rescue Errno::EACCES
 | 
			
		||||
      raise PermissionError.new(path, action)
 | 
			
		||||
    rescue Errno::EAGAIN
 | 
			
		||||
| 
						 | 
				
			
			@ -236,7 +236,7 @@ module Bundler
 | 
			
		|||
 | 
			
		||||
    def search_up(*names)
 | 
			
		||||
      previous = nil
 | 
			
		||||
      current  = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if RUBY_VERSION < "2.7" }
 | 
			
		||||
      current  = File.expand_path(SharedHelpers.pwd).tap {|x| x.untaint if RUBY_VERSION < "2.7" }
 | 
			
		||||
 | 
			
		||||
      until !File.directory?(current) || current == previous
 | 
			
		||||
        if ENV["BUNDLER_SPEC_RUN"]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -336,7 +336,7 @@ module Bundler
 | 
			
		|||
 | 
			
		||||
      def load_gemspec(file)
 | 
			
		||||
        stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
 | 
			
		||||
        stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
 | 
			
		||||
        stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
 | 
			
		||||
        StubSpecification.from_stub(stub)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ module Bundler
 | 
			
		|||
 | 
			
		||||
      loop do
 | 
			
		||||
        break unless dep = deps.shift
 | 
			
		||||
        next if handled.any?{|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
 | 
			
		||||
        next if handled.any? {|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
 | 
			
		||||
 | 
			
		||||
        handled << dep
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -174,7 +174,7 @@ module Bundler
 | 
			
		|||
    def spec_for_dependency(dep, match_current_platform)
 | 
			
		||||
      specs_for_platforms = lookup[dep.name]
 | 
			
		||||
      if match_current_platform
 | 
			
		||||
        GemHelpers.select_best_platform_match(specs_for_platforms.select{|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
 | 
			
		||||
        GemHelpers.select_best_platform_match(specs_for_platforms.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
 | 
			
		||||
      else
 | 
			
		||||
        GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform)
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -117,7 +117,7 @@ module Gem
 | 
			
		|||
  # Taint support is deprecated in Ruby 2.7.
 | 
			
		||||
  # This allows switching ".untaint" to ".tap(&Gem::UNTAINT)",
 | 
			
		||||
  # to avoid deprecation warnings in Ruby 2.7.
 | 
			
		||||
  UNTAINT = RUBY_VERSION < '2.7' ? :untaint.to_sym : proc{}
 | 
			
		||||
  UNTAINT = RUBY_VERSION < '2.7' ? :untaint.to_sym : proc {}
 | 
			
		||||
 | 
			
		||||
  # When https://bugs.ruby-lang.org/issues/17259 is available, there is no need to override Kernel#warn
 | 
			
		||||
  KERNEL_WARN_IGNORES_INTERNAL_ENTRIES = RUBY_ENGINE == "truffleruby" ||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,7 +113,7 @@ extensions will be restored.
 | 
			
		|||
      end.flatten
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
 | 
			
		||||
    specs = specs.select {|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
 | 
			
		||||
 | 
			
		||||
    if specs.to_a.empty?
 | 
			
		||||
      raise Gem::Exception,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -475,7 +475,7 @@ By default, this RubyGems will install gem as:
 | 
			
		|||
  def files_in(dir)
 | 
			
		||||
    Dir.chdir dir do
 | 
			
		||||
      Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH).
 | 
			
		||||
        select{|f| !File.directory?(f) }
 | 
			
		||||
        select {|f| !File.directory?(f) }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -129,7 +129,7 @@ Specific fields in the specification can be extracted in YAML format:
 | 
			
		|||
    platform = get_platform_from_requirements(options)
 | 
			
		||||
 | 
			
		||||
    if platform
 | 
			
		||||
      specs = specs.select{|s| s.platform.to_s == platform }
 | 
			
		||||
      specs = specs.select {|s| s.platform.to_s == platform }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    unless options[:all]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ class Gem::Ext::Builder
 | 
			
		|||
 | 
			
		||||
      require "open3"
 | 
			
		||||
      # Set $SOURCE_DATE_EPOCH for the subprocess.
 | 
			
		||||
      env = {'SOURCE_DATE_EPOCH' => Gem.source_date_epoch_string}
 | 
			
		||||
      env = { 'SOURCE_DATE_EPOCH' => Gem.source_date_epoch_string }
 | 
			
		||||
      output, status = begin
 | 
			
		||||
                         Open3.capture2e(env, *command, :chdir => dir)
 | 
			
		||||
                       rescue => error
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -135,7 +135,7 @@ module Gem::GemcutterUtilities
 | 
			
		|||
                                    sign_in_host, scope: scope) do |request|
 | 
			
		||||
      request.basic_auth email, password
 | 
			
		||||
      request["OTP"] = otp if otp
 | 
			
		||||
      request.body = URI.encode_www_form({:api_key => api_key }.merge(update_scope_params))
 | 
			
		||||
      request.body = URI.encode_www_form({ :api_key => api_key }.merge(update_scope_params))
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    with_response response do |resp|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -725,11 +725,11 @@ class Gem::Installer
 | 
			
		|||
      raise Gem::InstallError, "#{spec} has an invalid name"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if spec.raw_require_paths.any?{|path| path =~ /\R/ }
 | 
			
		||||
    if spec.raw_require_paths.any? {|path| path =~ /\R/ }
 | 
			
		||||
      raise Gem::InstallError, "#{spec} has an invalid require_paths"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if spec.extensions.any?{|ext| ext =~ /\R/ }
 | 
			
		||||
    if spec.extensions.any? {|ext| ext =~ /\R/ }
 | 
			
		||||
      raise Gem::InstallError, "#{spec} has an invalid extensions"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ module Gem::LocalRemoteOptions
 | 
			
		|||
 | 
			
		||||
      valid_uri_schemes = ["http", "https", "file", "s3"]
 | 
			
		||||
      unless valid_uri_schemes.include?(uri.scheme)
 | 
			
		||||
        msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map{|s| "#{s}://" }}"
 | 
			
		||||
        msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map {|s| "#{s}://" }}"
 | 
			
		||||
        raise ArgumentError, msg
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,7 +61,7 @@ module Gem::QueryUtils
 | 
			
		|||
    gem_names = if args.empty?
 | 
			
		||||
      [options[:name]]
 | 
			
		||||
    else
 | 
			
		||||
      options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
 | 
			
		||||
      options[:exact] ? args.map {|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map {|arg| /#{arg}/i }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    terminate_interaction(check_installed_gems(gem_names)) if check_installed_gems?
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -91,8 +91,8 @@ class Gem::SpecFetcher
 | 
			
		|||
 | 
			
		||||
    list.each do |source, specs|
 | 
			
		||||
      if dependency.name.is_a?(String) && specs.respond_to?(:bsearch)
 | 
			
		||||
        start_index = (0 ... specs.length).bsearch{|i| specs[i].name >= dependency.name }
 | 
			
		||||
        end_index   = (0 ... specs.length).bsearch{|i| specs[i].name > dependency.name }
 | 
			
		||||
        start_index = (0 ... specs.length).bsearch {|i| specs[i].name >= dependency.name }
 | 
			
		||||
        end_index   = (0 ... specs.length).bsearch {|i| specs[i].name > dependency.name }
 | 
			
		||||
        specs = specs[start_index ... end_index] if start_index && end_index
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -157,7 +157,7 @@ class Gem::Specification < Gem::BasicSpecification
 | 
			
		|||
  }.freeze
 | 
			
		||||
 | 
			
		||||
  # rubocop:disable Style/MutableConstant
 | 
			
		||||
  INITIALIZE_CODE_FOR_DEFAULTS = { } # :nodoc:
 | 
			
		||||
  INITIALIZE_CODE_FOR_DEFAULTS = {} # :nodoc:
 | 
			
		||||
  # rubocop:enable Style/MutableConstant
 | 
			
		||||
 | 
			
		||||
  @@default_value.each do |k,v|
 | 
			
		||||
| 
						 | 
				
			
			@ -1110,7 +1110,7 @@ class Gem::Specification < Gem::BasicSpecification
 | 
			
		|||
      result[spec.name] = spec
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    result.map(&:last).flatten.sort_by{|tup| tup.name }
 | 
			
		||||
    result.map(&:last).flatten.sort_by {|tup| tup.name }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  ##
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -154,7 +154,7 @@ class Gem::SpecificationPolicy
 | 
			
		|||
 | 
			
		||||
  def validate_duplicate_dependencies # :nodoc:
 | 
			
		||||
    # NOTE: see REFACTOR note in Gem::Dependency about types - this might be brittle
 | 
			
		||||
    seen = Gem::Dependency::TYPES.inject({}) {|types, type| types.merge({ type => {}}) }
 | 
			
		||||
    seen = Gem::Dependency::TYPES.inject({}) {|types, type| types.merge({ type => {} }) }
 | 
			
		||||
 | 
			
		||||
    error_messages = []
 | 
			
		||||
    @specification.dependencies.each do |dep|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -60,7 +60,7 @@ module Gem::Util
 | 
			
		|||
  # Invokes system, but silences all output.
 | 
			
		||||
 | 
			
		||||
  def self.silent_system(*command)
 | 
			
		||||
    opt = {:out => IO::NULL, :err => [:child, :out]}
 | 
			
		||||
    opt = { :out => IO::NULL, :err => [:child, :out] }
 | 
			
		||||
    if Hash === command.last
 | 
			
		||||
      opt.update(command.last)
 | 
			
		||||
      cmds = command[0...-1]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,7 +89,7 @@ RSpec.describe "bundler/inline#gemfile" do
 | 
			
		|||
 | 
			
		||||
    expect(out).to include("Installing activesupport")
 | 
			
		||||
    err_lines = err.split("\n")
 | 
			
		||||
    err_lines.reject!{|line| line =~ /\.rb:\d+: warning: / } unless RUBY_VERSION < "2.7"
 | 
			
		||||
    err_lines.reject! {|line| line =~ /\.rb:\d+: warning: / } unless RUBY_VERSION < "2.7"
 | 
			
		||||
    expect(err_lines).to be_empty
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,6 +113,10 @@ RSpec.configure do |config|
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  config.before :each, :sudo => true do
 | 
			
		||||
    Spec::Sudo.write_safe_config
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  config.after :suite do
 | 
			
		||||
    FileUtils.rm_r Spec::Path.pristine_system_gem_path
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -258,6 +258,10 @@ module Spec
 | 
			
		|||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def git_root
 | 
			
		||||
      ruby_core? ? source_root : source_root.parent
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    private
 | 
			
		||||
 | 
			
		||||
    def git_ls_files(glob)
 | 
			
		||||
| 
						 | 
				
			
			@ -278,10 +282,6 @@ module Spec
 | 
			
		|||
      ruby_core? ? "man/bundle* man/gemfile*" : "lib/bundler/man/bundle*.1 lib/bundler/man/gemfile*.5"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def git_root
 | 
			
		||||
      ruby_core? ? source_root : source_root.parent
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def ruby_core_tarball?
 | 
			
		||||
      !git_root.join(".git").directory?
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,6 +18,12 @@ module Spec
 | 
			
		|||
      gem_load_and_activate(gem_name, bin_container)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def gem_load_and_possibly_install(gem_name, bin_container)
 | 
			
		||||
      require_relative "switch_rubygems"
 | 
			
		||||
 | 
			
		||||
      gem_load_activate_and_possibly_install(gem_name, bin_container)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def gem_require(gem_name)
 | 
			
		||||
      gem_activate(gem_name)
 | 
			
		||||
      require gem_name
 | 
			
		||||
| 
						 | 
				
			
			@ -99,9 +105,21 @@ module Spec
 | 
			
		|||
      abort "We couldn't activate #{gem_name} (#{e.requirement}). Run `gem install #{gem_name}:'#{e.requirement}'`"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def gem_load_activate_and_possibly_install(gem_name, bin_container)
 | 
			
		||||
      gem_activate_and_possibly_install(gem_name)
 | 
			
		||||
      load Gem.bin_path(gem_name, bin_container)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def gem_activate_and_possibly_install(gem_name)
 | 
			
		||||
      gem_activate(gem_name)
 | 
			
		||||
    rescue Gem::LoadError => e
 | 
			
		||||
      Gem.install(gem_name, e.requirement)
 | 
			
		||||
      retry
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def gem_activate(gem_name)
 | 
			
		||||
      require "bundler"
 | 
			
		||||
      gem_requirement = Bundler::LockfileParser.new(File.read(dev_lockfile)).dependencies[gem_name]&.requirement
 | 
			
		||||
      gem_requirement = Bundler::LockfileParser.new(File.read(dev_lockfile)).specs.find {|spec| spec.name == gem_name }.version
 | 
			
		||||
      gem gem_name, gem_requirement
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,10 @@ module Spec
 | 
			
		|||
      @which_sudo ||= Bundler.which("sudo")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def self.write_safe_config
 | 
			
		||||
      File.write(Spec::Path.tmp("gitconfig"), "[safe]\n\tdirectory = #{Spec::Path.git_root}")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def sudo(cmd)
 | 
			
		||||
      raise "sudo not present" unless Sudo.present?
 | 
			
		||||
      sys_exec("sudo #{cmd}")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -618,7 +618,7 @@ class Gem::TestCase < Test::Unit::TestCase
 | 
			
		|||
      gem = File.join(@tempdir, File.basename(gem)).tap(&Gem::UNTAINT)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    Gem::Installer.at(gem, options.merge({:wrappers => true})).install
 | 
			
		||||
    Gem::Installer.at(gem, options.merge({ :wrappers => true })).install
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  ##
 | 
			
		||||
| 
						 | 
				
			
			@ -1294,7 +1294,7 @@ Also, a list:
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def rubygems_path
 | 
			
		||||
    $LOAD_PATH.find{|p| p == File.dirname($LOADED_FEATURES.find{|f| f.end_with?("/rubygems.rb") }) }
 | 
			
		||||
    $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/rubygems.rb") }) }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def with_clean_path_to_ruby
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,7 +67,7 @@ class Gem::Package::TarTestCase < Gem::TestCase
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def calc_checksum(header)
 | 
			
		||||
    sum = header.unpack("C*").inject{|s,a| s + a }
 | 
			
		||||
    sum = header.unpack("C*").inject {|s,a| s + a }
 | 
			
		||||
    SP(Z(to_oct(sum, 6)))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1061,7 +1061,7 @@ class TestGem < Gem::TestCase
 | 
			
		|||
 | 
			
		||||
    Gem.refresh
 | 
			
		||||
 | 
			
		||||
    Gem::Specification.each{|spec| assert spec.activated? if spec == s }
 | 
			
		||||
    Gem::Specification.each {|spec| assert spec.activated? if spec == s }
 | 
			
		||||
 | 
			
		||||
    Gem.loaded_specs.delete(s)
 | 
			
		||||
    Gem.refresh
 | 
			
		||||
| 
						 | 
				
			
			@ -1430,7 +1430,7 @@ class TestGem < Gem::TestCase
 | 
			
		|||
    a = util_spec "a", "1"
 | 
			
		||||
    b = util_spec "b", "1", "c" => nil
 | 
			
		||||
    c = util_spec "c", "2"
 | 
			
		||||
    d = util_spec "d", "1", {'e' => '= 1'}, "lib/d#{$$}.rb"
 | 
			
		||||
    d = util_spec "d", "1", { 'e' => '= 1' }, "lib/d#{$$}.rb"
 | 
			
		||||
    e = util_spec "e", "1"
 | 
			
		||||
 | 
			
		||||
    install_specs a, c, b, e, d
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -239,7 +239,7 @@ lib/foo.rb
 | 
			
		|||
      [RbConfig::CONFIG['bindir'], 'default_command'],
 | 
			
		||||
      [RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'],
 | 
			
		||||
      [RbConfig::CONFIG['archdir'], 'default_gem.so'],
 | 
			
		||||
    ].sort.map{|a|File.join a }.join "\n"
 | 
			
		||||
    ].sort.map {|a|File.join a }.join "\n"
 | 
			
		||||
 | 
			
		||||
    assert_equal expected, @ui.output.chomp
 | 
			
		||||
    assert_equal "", @ui.error
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -521,7 +521,7 @@ ERROR:  Possible alternatives: non_existent_with_hint
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_execute_required_ruby_version
 | 
			
		||||
    next_ruby = Gem.ruby_version.segments.map.with_index{|n, i| i == 1 ? n + 1 : n }.join(".")
 | 
			
		||||
    next_ruby = Gem.ruby_version.segments.map.with_index {|n, i| i == 1 ? n + 1 : n }.join(".")
 | 
			
		||||
 | 
			
		||||
    local = Gem::Platform.local
 | 
			
		||||
    spec_fetcher do |fetcher|
 | 
			
		||||
| 
						 | 
				
			
			@ -610,7 +610,7 @@ ERROR:  Possible alternatives: non_existent_with_hint
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_execute_required_ruby_version_specific_prerelease_not_met
 | 
			
		||||
    next_ruby_pre = Gem.ruby_version.segments.map.with_index{|n, i| i == 1 ? n + 1 : n }.join(".") + ".a"
 | 
			
		||||
    next_ruby_pre = Gem.ruby_version.segments.map.with_index {|n, i| i == 1 ? n + 1 : n }.join(".") + ".a"
 | 
			
		||||
 | 
			
		||||
    spec_fetcher do |fetcher|
 | 
			
		||||
      fetcher.gem 'a', '1.0' do |s|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -190,7 +190,7 @@ class TestGemConfigFile < Gem::TestCase
 | 
			
		|||
 | 
			
		||||
    util_config_file
 | 
			
		||||
 | 
			
		||||
    assert_equal({:rubygems => '701229f217cdf23b1344c7b4b54ca97'},
 | 
			
		||||
    assert_equal({ :rubygems => '701229f217cdf23b1344c7b4b54ca97' },
 | 
			
		||||
                 @cfg.api_keys)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -317,8 +317,8 @@ if you believe they were disclosed to a third party.
 | 
			
		|||
 | 
			
		||||
    util_config_file
 | 
			
		||||
 | 
			
		||||
    assert_equal({:rubygems => '701229f217cdf23b1344c7b4b54ca97',
 | 
			
		||||
                  :other => 'a5fdbb6ba150cbb83aad2bb2fede64c'}, @cfg.api_keys)
 | 
			
		||||
    assert_equal({ :rubygems => '701229f217cdf23b1344c7b4b54ca97',
 | 
			
		||||
                  :other => 'a5fdbb6ba150cbb83aad2bb2fede64c' }, @cfg.api_keys)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_load_api_keys_bad_permission
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@ gemspec = File.expand_path('custom_name.gemspec', __dir__)
 | 
			
		|||
 | 
			
		||||
Dir.mktmpdir("custom_name") do |dir|
 | 
			
		||||
  built_gem = File.expand_path(File.join(dir, "custom_name.gem"))
 | 
			
		||||
  system(*gem, "build", gemspec, "--output", built_gem)
 | 
			
		||||
  system(*gem, "install", "--verbose", "--local", built_gem, *ARGV)
 | 
			
		||||
  system *gem, "build", gemspec, "--output", built_gem
 | 
			
		||||
  system *gem, "install", "--verbose", "--local", built_gem, *ARGV
 | 
			
		||||
  system %q(ruby -rcustom_name -e "puts 'Result: ' + CustomName.say_hello")
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -254,7 +254,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_verify_api_key
 | 
			
		||||
    keys = {:other => 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'}
 | 
			
		||||
    keys = { :other => 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' }
 | 
			
		||||
    File.open Gem.configuration.credentials_path, 'w' do |f|
 | 
			
		||||
      f.write keys.to_yaml
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -218,7 +218,7 @@ class TestGemPackage < Gem::Package::TarTestCase
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal %w[lib/code.rb], files
 | 
			
		||||
    assert_equal [{'lib/code_sym.rb' => 'code.rb'}, {'lib/code_sym2.rb' => '../lib/code.rb'}], symlinks
 | 
			
		||||
    assert_equal [{ 'lib/code_sym.rb' => 'code.rb' }, { 'lib/code_sym2.rb' => '../lib/code.rb' }], symlinks
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_build
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -705,7 +705,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
  def test_fetch_http_with_additional_headers
 | 
			
		||||
    ENV["http_proxy"] = @proxy_uri
 | 
			
		||||
    ENV["no_proxy"] = URI::parse(@server_uri).host
 | 
			
		||||
    fetcher = Gem::RemoteFetcher.new nil, nil, {"X-Captain" => "murphy"}
 | 
			
		||||
    fetcher = Gem::RemoteFetcher.new nil, nil, { "X-Captain" => "murphy" }
 | 
			
		||||
    @fetcher = fetcher
 | 
			
		||||
    assert_equal "murphy", fetcher.fetch_path(@server_uri)
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -745,7 +745,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
 | 
			
		||||
  def test_fetch_s3_config_creds
 | 
			
		||||
    Gem.configuration[:s3_source] = {
 | 
			
		||||
      'my-bucket' => {:id => 'testuser', :secret => 'testpass'},
 | 
			
		||||
      'my-bucket' => { :id => 'testuser', :secret => 'testpass' },
 | 
			
		||||
    }
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
    Time.stub :now, Time.at(1561353581) do
 | 
			
		||||
| 
						 | 
				
			
			@ -757,7 +757,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
 | 
			
		||||
  def test_fetch_s3_config_creds_with_region
 | 
			
		||||
    Gem.configuration[:s3_source] = {
 | 
			
		||||
      'my-bucket' => {:id => 'testuser', :secret => 'testpass', :region => 'us-west-2'},
 | 
			
		||||
      'my-bucket' => { :id => 'testuser', :secret => 'testpass', :region => 'us-west-2' },
 | 
			
		||||
    }
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
    Time.stub :now, Time.at(1561353581) do
 | 
			
		||||
| 
						 | 
				
			
			@ -769,7 +769,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
 | 
			
		||||
  def test_fetch_s3_config_creds_with_token
 | 
			
		||||
    Gem.configuration[:s3_source] = {
 | 
			
		||||
      'my-bucket' => {:id => 'testuser', :secret => 'testpass', :security_token => 'testtoken'},
 | 
			
		||||
      'my-bucket' => { :id => 'testuser', :secret => 'testpass', :security_token => 'testtoken' },
 | 
			
		||||
    }
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
    Time.stub :now, Time.at(1561353581) do
 | 
			
		||||
| 
						 | 
				
			
			@ -784,7 +784,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
    ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
 | 
			
		||||
    ENV['AWS_SESSION_TOKEN'] = nil
 | 
			
		||||
    Gem.configuration[:s3_source] = {
 | 
			
		||||
      'my-bucket' => {:provider => 'env'},
 | 
			
		||||
      'my-bucket' => { :provider => 'env' },
 | 
			
		||||
    }
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
    Time.stub :now, Time.at(1561353581) do
 | 
			
		||||
| 
						 | 
				
			
			@ -800,7 +800,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
    ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
 | 
			
		||||
    ENV['AWS_SESSION_TOKEN'] = nil
 | 
			
		||||
    Gem.configuration[:s3_source] = {
 | 
			
		||||
      'my-bucket' => {:provider => 'env', :region => 'us-west-2'},
 | 
			
		||||
      'my-bucket' => { :provider => 'env', :region => 'us-west-2' },
 | 
			
		||||
    }
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
    Time.stub :now, Time.at(1561353581) do
 | 
			
		||||
| 
						 | 
				
			
			@ -816,7 +816,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
    ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
 | 
			
		||||
    ENV['AWS_SESSION_TOKEN'] = 'testtoken'
 | 
			
		||||
    Gem.configuration[:s3_source] = {
 | 
			
		||||
      'my-bucket' => {:provider => 'env'},
 | 
			
		||||
      'my-bucket' => { :provider => 'env' },
 | 
			
		||||
    }
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
    Time.stub :now, Time.at(1561353581) do
 | 
			
		||||
| 
						 | 
				
			
			@ -836,7 +836,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
 | 
			
		||||
  def test_fetch_s3_instance_profile_creds
 | 
			
		||||
    Gem.configuration[:s3_source] = {
 | 
			
		||||
      'my-bucket' => {:provider => 'instance_profile'},
 | 
			
		||||
      'my-bucket' => { :provider => 'instance_profile' },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
| 
						 | 
				
			
			@ -850,7 +850,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
 | 
			
		||||
  def test_fetch_s3_instance_profile_creds_with_region
 | 
			
		||||
    Gem.configuration[:s3_source] = {
 | 
			
		||||
      'my-bucket' => {:provider => 'instance_profile', :region => 'us-west-2'},
 | 
			
		||||
      'my-bucket' => { :provider => 'instance_profile', :region => 'us-west-2' },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
| 
						 | 
				
			
			@ -864,7 +864,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
 | 
			
		||||
  def test_fetch_s3_instance_profile_creds_with_token
 | 
			
		||||
    Gem.configuration[:s3_source] = {
 | 
			
		||||
      'my-bucket' => {:provider => 'instance_profile'},
 | 
			
		||||
      'my-bucket' => { :provider => 'instance_profile' },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
| 
						 | 
				
			
			@ -894,7 +894,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
 | 
			
		||||
  def test_fetch_s3_no_host
 | 
			
		||||
    Gem.configuration[:s3_source] = {
 | 
			
		||||
      'my-bucket' => {:id => 'testuser', :secret => 'testpass'},
 | 
			
		||||
      'my-bucket' => { :id => 'testuser', :secret => 'testpass' },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    url = 's3://other-bucket/gems/specs.4.8.gz'
 | 
			
		||||
| 
						 | 
				
			
			@ -904,7 +904,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_fetch_s3_no_id
 | 
			
		||||
    Gem.configuration[:s3_source] = { 'my-bucket' => {:secret => 'testpass'} }
 | 
			
		||||
    Gem.configuration[:s3_source] = { 'my-bucket' => { :secret => 'testpass' } }
 | 
			
		||||
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
    refute_fetch_s3 url, 's3_source for my-bucket missing id or secret'
 | 
			
		||||
| 
						 | 
				
			
			@ -913,7 +913,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_fetch_s3_no_secret
 | 
			
		||||
    Gem.configuration[:s3_source] = { 'my-bucket' => {:id => 'testuser'} }
 | 
			
		||||
    Gem.configuration[:s3_source] = { 'my-bucket' => { :id => 'testuser' } }
 | 
			
		||||
 | 
			
		||||
    url = 's3://my-bucket/gems/specs.4.8.gz'
 | 
			
		||||
    refute_fetch_s3 url, 's3_source for my-bucket missing id or secret'
 | 
			
		||||
| 
						 | 
				
			
			@ -973,7 +973,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
  def test_ssl_client_cert_auth_connection
 | 
			
		||||
    ssl_server = start_ssl_server({
 | 
			
		||||
      :SSLVerifyClient =>
 | 
			
		||||
        OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
 | 
			
		||||
        OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT })
 | 
			
		||||
 | 
			
		||||
    temp_ca_cert = File.join(__dir__, 'ca_cert.pem')
 | 
			
		||||
    temp_client_cert = File.join(__dir__, 'client.pem')
 | 
			
		||||
| 
						 | 
				
			
			@ -988,7 +988,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
 | 
			
		|||
  def test_do_not_allow_invalid_client_cert_auth_connection
 | 
			
		||||
    ssl_server = start_ssl_server({
 | 
			
		||||
      :SSLVerifyClient =>
 | 
			
		||||
        OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
 | 
			
		||||
        OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT })
 | 
			
		||||
 | 
			
		||||
    temp_ca_cert = File.join(__dir__, 'ca_cert.pem')
 | 
			
		||||
    temp_client_cert = File.join(__dir__, 'invalid_client.pem')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -248,7 +248,7 @@ DEPENDENCIES
 | 
			
		|||
    assert_equal %w[a-2], lockfile_set.specs.map {|s| s.full_name }
 | 
			
		||||
 | 
			
		||||
    assert_equal %w[https://gems.example/ https://other.example/],
 | 
			
		||||
                 lockfile_set.specs.flat_map {|s| s.sources.map{|src| src.uri.to_s } }
 | 
			
		||||
                 lockfile_set.specs.flat_map {|s| s.sources.map {|src| src.uri.to_s } }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_parse_GIT
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -191,7 +191,7 @@ class TestGemResolver < Gem::TestCase
 | 
			
		|||
 | 
			
		||||
    # With the following gems already installed:
 | 
			
		||||
    # a-1, b-1, c-1, e-1
 | 
			
		||||
    res.skip_gems = {'a' => [a1_spec], 'b' => [b1_spec], 'c' => [c1_spec], 'e' => [e1_spec]}
 | 
			
		||||
    res.skip_gems = { 'a' => [a1_spec], 'b' => [b1_spec], 'c' => [c1_spec], 'e' => [e1_spec] }
 | 
			
		||||
 | 
			
		||||
    # Make sure the following gems end up getting used/installed/upgraded:
 | 
			
		||||
    # a-2 (upgraded)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -210,7 +210,7 @@ class TestGemResolverInstallerSet < Gem::TestCase
 | 
			
		|||
    def (set.remote_set).prefetch(_)
 | 
			
		||||
      raise "called"
 | 
			
		||||
    end
 | 
			
		||||
    assert_raise(RuntimeError){ set.prefetch(nil) }
 | 
			
		||||
    assert_raise(RuntimeError) { set.prefetch(nil) }
 | 
			
		||||
 | 
			
		||||
    set = Gem::Resolver::InstallerSet.new :local
 | 
			
		||||
    def (set.remote_set).prefetch(_)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -158,7 +158,7 @@ end
 | 
			
		|||
        util_spec "pkg#{pkgi}", pkg_version.to_s, deps
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    base = util_spec "pkg_base", "1", {"pkg0" => ">= 0"}
 | 
			
		||||
    base = util_spec "pkg_base", "1", { "pkg0" => ">= 0" }
 | 
			
		||||
 | 
			
		||||
    Gem::Specification.reset
 | 
			
		||||
    install_specs(*packages.flatten.reverse)
 | 
			
		||||
| 
						 | 
				
			
			@ -305,10 +305,10 @@ end
 | 
			
		|||
 | 
			
		||||
  def test_require_should_not_conflict
 | 
			
		||||
    base = util_spec "0", "1", "A" => ">= 1"
 | 
			
		||||
    a1 = util_spec "A", "1", {"c" => ">= 2", "b" => "> 0"}, "lib/a.rb"
 | 
			
		||||
    a2 = util_spec "A", "2", {"c" => ">= 2", "b" => "> 0"}, "lib/a.rb"
 | 
			
		||||
    b1 = util_spec "b", "1", {"c" => "= 1"}, "lib/d#{$$}.rb"
 | 
			
		||||
    b2 = util_spec "b", "2", {"c" => "= 2"}, "lib/d#{$$}.rb"
 | 
			
		||||
    a1 = util_spec "A", "1", { "c" => ">= 2", "b" => "> 0" }, "lib/a.rb"
 | 
			
		||||
    a2 = util_spec "A", "2", { "c" => ">= 2", "b" => "> 0" }, "lib/a.rb"
 | 
			
		||||
    b1 = util_spec "b", "1", { "c" => "= 1" }, "lib/d#{$$}.rb"
 | 
			
		||||
    b2 = util_spec "b", "2", { "c" => "= 2" }, "lib/d#{$$}.rb"
 | 
			
		||||
    c1 = util_spec "c", "1", {}, "lib/c.rb"
 | 
			
		||||
    c2 = util_spec "c", "2", {}, "lib/c.rb"
 | 
			
		||||
    c3 = util_spec "c", "3", {}, "lib/c.rb"
 | 
			
		||||
| 
						 | 
				
			
			@ -992,8 +992,8 @@ dependencies: []
 | 
			
		|||
 | 
			
		||||
    dir_standard_specs = File.join Gem.dir, 'specifications'
 | 
			
		||||
 | 
			
		||||
    save_gemspec('a-1', '1', dir_standard_specs){|s| s.name = 'a' }
 | 
			
		||||
    save_gemspec('b-1', '1', dir_standard_specs){|s| s.name = 'b' }
 | 
			
		||||
    save_gemspec('a-1', '1', dir_standard_specs) {|s| s.name = 'a' }
 | 
			
		||||
    save_gemspec('b-1', '1', dir_standard_specs) {|s| s.name = 'b' }
 | 
			
		||||
 | 
			
		||||
    assert_equal ['a-1'], Gem::Specification.stubs_for('a').map {|s| s.full_name }
 | 
			
		||||
    assert_equal 1, Gem::Specification.class_variable_get(:@@stubs_by_name).length
 | 
			
		||||
| 
						 | 
				
			
			@ -1013,7 +1013,7 @@ dependencies: []
 | 
			
		|||
  def test_self_stubs_for_no_lazy_loading_after_all_specs_setup
 | 
			
		||||
    Gem::Specification.all = [util_spec('a', '1')]
 | 
			
		||||
 | 
			
		||||
    save_gemspec('b-1', '1', File.join(Gem.dir, 'specifications')){|s| s.name = 'b' }
 | 
			
		||||
    save_gemspec('b-1', '1', File.join(Gem.dir, 'specifications')) {|s| s.name = 'b' }
 | 
			
		||||
 | 
			
		||||
    assert_equal [], Gem::Specification.stubs_for('b').map {|s| s.full_name }
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -1060,9 +1060,9 @@ dependencies: []
 | 
			
		|||
  def test_self_stubs_returns_only_specified_named_specs
 | 
			
		||||
    dir_standard_specs = File.join Gem.dir, 'specifications'
 | 
			
		||||
 | 
			
		||||
    save_gemspec('a-1', '1', dir_standard_specs){|s| s.name = 'a' }
 | 
			
		||||
    save_gemspec('a-2', '2', dir_standard_specs){|s| s.name = 'a' }
 | 
			
		||||
    save_gemspec('a-a', '3', dir_standard_specs){|s| s.name = 'a-a' }
 | 
			
		||||
    save_gemspec('a-1', '1', dir_standard_specs) {|s| s.name = 'a' }
 | 
			
		||||
    save_gemspec('a-2', '2', dir_standard_specs) {|s| s.name = 'a' }
 | 
			
		||||
    save_gemspec('a-a', '3', dir_standard_specs) {|s| s.name = 'a-a' }
 | 
			
		||||
 | 
			
		||||
    assert_equal ['a-1', 'a-2'], Gem::Specification.stubs_for('a').map(&:full_name).sort
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -63,8 +63,8 @@ class TestGemRequire < Gem::TestCase
 | 
			
		|||
 | 
			
		||||
  # Providing -I on the commandline should always beat gems
 | 
			
		||||
  def test_dash_i_beats_gems
 | 
			
		||||
    a1 = util_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
 | 
			
		||||
    b1 = util_spec "b", "1", {"c" => "> 0"}, "lib/b/c.rb"
 | 
			
		||||
    a1 = util_spec "a", "1", { "b" => "= 1" }, "lib/test_gem_require_a.rb"
 | 
			
		||||
    b1 = util_spec "b", "1", { "c" => "> 0" }, "lib/b/c.rb"
 | 
			
		||||
    c1 = util_spec "c", "1", nil, "lib/c/c.rb"
 | 
			
		||||
    c2 = util_spec "c", "2", nil, "lib/c/c.rb"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -102,8 +102,8 @@ class TestGemRequire < Gem::TestCase
 | 
			
		|||
 | 
			
		||||
  # Providing -I on the commandline should always beat gems
 | 
			
		||||
  def test_dash_i_beats_default_gems
 | 
			
		||||
    a1 = new_default_spec "a", "1", {"b" => "= 1"}, "test_gem_require_a.rb"
 | 
			
		||||
    b1 = new_default_spec "b", "1", {"c" => "> 0"}, "b/c.rb"
 | 
			
		||||
    a1 = new_default_spec "a", "1", { "b" => "= 1" }, "test_gem_require_a.rb"
 | 
			
		||||
    b1 = new_default_spec "b", "1", { "c" => "> 0" }, "b/c.rb"
 | 
			
		||||
    c1 = new_default_spec "c", "1", nil, "c/c.rb"
 | 
			
		||||
    c2 = new_default_spec "c", "2", nil, "c/c.rb"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -152,8 +152,8 @@ class TestGemRequire < Gem::TestCase
 | 
			
		|||
 | 
			
		||||
    install_specs a1, b1
 | 
			
		||||
 | 
			
		||||
    t1 = create_sync_thread{ assert_require "a#{$$}" }
 | 
			
		||||
    t2 = create_sync_thread{ assert_require "b#{$$}" }
 | 
			
		||||
    t1 = create_sync_thread { assert_require "a#{$$}" }
 | 
			
		||||
    t2 = create_sync_thread { assert_require "b#{$$}" }
 | 
			
		||||
 | 
			
		||||
    # wait until both files are waiting on the exit latch
 | 
			
		||||
    FILE_ENTERED_LATCH.await
 | 
			
		||||
| 
						 | 
				
			
			@ -169,7 +169,7 @@ class TestGemRequire < Gem::TestCase
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_require_is_not_lazy_with_exact_req
 | 
			
		||||
    a1 = util_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
 | 
			
		||||
    a1 = util_spec "a", "1", { "b" => "= 1" }, "lib/test_gem_require_a.rb"
 | 
			
		||||
    b1 = util_spec "b", "1", nil, "lib/b/c.rb"
 | 
			
		||||
    b2 = util_spec "b", "2", nil, "lib/b/c.rb"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -184,7 +184,7 @@ class TestGemRequire < Gem::TestCase
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_require_is_lazy_with_inexact_req
 | 
			
		||||
    a1 = util_spec "a", "1", {"b" => ">= 1"}, "lib/test_gem_require_a.rb"
 | 
			
		||||
    a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
 | 
			
		||||
    b1 = util_spec "b", "1", nil, "lib/b/c.rb"
 | 
			
		||||
    b2 = util_spec "b", "2", nil, "lib/b/c.rb"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -199,7 +199,7 @@ class TestGemRequire < Gem::TestCase
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_require_is_not_lazy_with_one_possible
 | 
			
		||||
    a1 = util_spec "a", "1", {"b" => ">= 1"}, "lib/test_gem_require_a.rb"
 | 
			
		||||
    a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
 | 
			
		||||
    b1 = util_spec "b", "1", nil, "lib/b/c.rb"
 | 
			
		||||
 | 
			
		||||
    install_specs b1, a1
 | 
			
		||||
| 
						 | 
				
			
			@ -243,7 +243,7 @@ class TestGemRequire < Gem::TestCase
 | 
			
		|||
 | 
			
		||||
    require 'benchmark' # the stdlib
 | 
			
		||||
 | 
			
		||||
    a1 = util_spec "a", "1", {"b" => ">= 1"}, "lib/test_gem_require_a.rb"
 | 
			
		||||
    a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
 | 
			
		||||
    b1 = util_spec "b", "1", nil, "lib/benchmark.rb"
 | 
			
		||||
    b2 = util_spec "b", "2", nil, "lib/benchmark.rb"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@ require_relative 'helper'
 | 
			
		|||
 | 
			
		||||
class GemTest < Gem::TestCase
 | 
			
		||||
  def test_rubygems_normal_behaviour
 | 
			
		||||
    _ = Gem::Util.popen(*ruby_with_rubygems_in_load_path, '-e', "'require \"rubygems\"'", {:err => [:child, :out]}).strip
 | 
			
		||||
    _ = Gem::Util.popen(*ruby_with_rubygems_in_load_path, '-e', "'require \"rubygems\"'", { :err => [:child, :out] }).strip
 | 
			
		||||
    assert $?.success?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ class GemTest < Gem::TestCase
 | 
			
		|||
      intentionally_not_implemented_method
 | 
			
		||||
    RUBY
 | 
			
		||||
 | 
			
		||||
    output = Gem::Util.popen(*ruby_with_rubygems_and_fake_operating_system_in_load_path(path), '-e', "'require \"rubygems\"'", {:err => [:child, :out]}).strip
 | 
			
		||||
    output = Gem::Util.popen(*ruby_with_rubygems_and_fake_operating_system_in_load_path(path), '-e', "'require \"rubygems\"'", { :err => [:child, :out] }).strip
 | 
			
		||||
    assert !$?.success?
 | 
			
		||||
    assert_includes output, "undefined local variable or method `intentionally_not_implemented_method'"
 | 
			
		||||
    assert_includes output, "Loading the rubygems/defaults/operating_system.rb file caused an error. " \
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ class GemTest < Gem::TestCase
 | 
			
		|||
      *ruby_with_rubygems_and_fake_operating_system_in_load_path(path),
 | 
			
		||||
      '-e',
 | 
			
		||||
      "require \"rubygems\"; puts Gem::Specification.stubs.map(&:full_name)",
 | 
			
		||||
      {:err => [:child, :out]}
 | 
			
		||||
      { :err => [:child, :out] }
 | 
			
		||||
    ).strip
 | 
			
		||||
    begin
 | 
			
		||||
      assert_empty output
 | 
			
		||||
| 
						 | 
				
			
			@ -66,6 +66,6 @@ class GemTest < Gem::TestCase
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def ruby_with_rubygems_and_fake_operating_system_in_load_path(operating_system_path)
 | 
			
		||||
    [Gem.ruby, "-I", operating_system_path, "-I" , $LOAD_PATH.find{|p| p == File.dirname($LOADED_FEATURES.find{|f| f.end_with?("/rubygems.rb") }) }]
 | 
			
		||||
    [Gem.ruby, "-I", operating_system_path, "-I" , $LOAD_PATH.find {|p| p == File.dirname($LOADED_FEATURES.find {|f| f.end_with?("/rubygems.rb") }) }]
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue