Merge RubyGems and Bundler HEAD

125415593e
This commit is contained in:
Hiroshi SHIBATA 2022-05-20 17:15:15 +09:00
parent bd8df25cdc
commit aeea88174d
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2
43 changed files with 121 additions and 95 deletions

View File

@ -40,7 +40,7 @@ module Bundler
end end
def self.verbalize_groups(groups) def self.verbalize_groups(groups)
groups.map!{|g| "'#{g}'" } groups.map! {|g| "'#{g}'" }
group_list = [groups[0...-1].join(", "), groups[-1..-1]]. group_list = [groups[0...-1].join(", "), groups[-1..-1]].
reject {|s| s.to_s.empty? }.join(" and ") reject {|s| s.to_s.empty? }.join(" and ")
group_str = groups.size == 1 ? "group" : "groups" group_str = groups.size == 1 ? "group" : "groups"

View File

@ -261,7 +261,7 @@ module Bundler
@locked_specs @locked_specs
elsif !unlocking? && nothing_changed? elsif !unlocking? && nothing_changed?
Bundler.ui.debug("Found no changes, using resolution from the lockfile") 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 else
last_resolve = converge_locked_specs last_resolve = converge_locked_specs
# Run a resolve against the locally available gems # Run a resolve against the locally available gems
@ -731,7 +731,7 @@ module Bundler
end end
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 end
def metadata_dependencies def metadata_dependencies

View File

@ -46,7 +46,7 @@ module Bundler
@gemfile = expanded_gemfile_path @gemfile = expanded_gemfile_path
@gemfiles << expanded_gemfile_path @gemfiles << expanded_gemfile_path
contents ||= Bundler.read_file(@gemfile.to_s) 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 rescue Exception => e # rubocop:disable Lint/RescueException
message = "There was an error " \ message = "There was an error " \
"#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \ "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \

View File

@ -48,7 +48,7 @@ module Bundler
sorted_matching = matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) } sorted_matching = matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) }
exemplary_spec = sorted_matching.first 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 end
module_function :select_best_platform_match module_function :select_best_platform_match

View File

@ -21,7 +21,7 @@ module Bundler
base = SpecSet.new(base) unless base.is_a?(SpecSet) base = SpecSet.new(base) unless base.is_a?(SpecSet)
resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms) resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
result = resolver.start(requirements) 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 end
def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms) def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)

View File

@ -34,7 +34,7 @@ module Gem
def full_gem_path def full_gem_path
if source.respond_to?(:root) 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 else
rg_full_gem_path rg_full_gem_path
end end

View File

@ -13,13 +13,13 @@ module Bundler
def root def root
gemfile = find_gemfile gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless 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 end
def default_gemfile def default_gemfile
gemfile = find_gemfile gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless 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 end
def default_lockfile def default_lockfile
@ -28,7 +28,7 @@ module Bundler
case gemfile.basename.to_s case gemfile.basename.to_s
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked")) when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
else Pathname.new("#{gemfile}.lock") 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 end
def default_bundle_dir def default_bundle_dir
@ -100,7 +100,7 @@ module Bundler
# #
# @see {Bundler::PermissionError} # @see {Bundler::PermissionError}
def filesystem_access(path, action = :write, &block) 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 rescue Errno::EACCES
raise PermissionError.new(path, action) raise PermissionError.new(path, action)
rescue Errno::EAGAIN rescue Errno::EAGAIN
@ -236,7 +236,7 @@ module Bundler
def search_up(*names) def search_up(*names)
previous = nil 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 until !File.directory?(current) || current == previous
if ENV["BUNDLER_SPEC_RUN"] if ENV["BUNDLER_SPEC_RUN"]

View File

@ -336,7 +336,7 @@ module Bundler
def load_gemspec(file) def load_gemspec(file)
stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent) 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) StubSpecification.from_stub(stub)
end end

View File

@ -18,7 +18,7 @@ module Bundler
loop do loop do
break unless dep = deps.shift 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 handled << dep
@ -174,7 +174,7 @@ module Bundler
def spec_for_dependency(dep, match_current_platform) def spec_for_dependency(dep, match_current_platform)
specs_for_platforms = lookup[dep.name] specs_for_platforms = lookup[dep.name]
if match_current_platform 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 else
GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform) GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform)
end end

View File

@ -117,7 +117,7 @@ module Gem
# Taint support is deprecated in Ruby 2.7. # Taint support is deprecated in Ruby 2.7.
# This allows switching ".untaint" to ".tap(&Gem::UNTAINT)", # This allows switching ".untaint" to ".tap(&Gem::UNTAINT)",
# to avoid deprecation warnings in Ruby 2.7. # 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 # 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" || KERNEL_WARN_IGNORES_INTERNAL_ENTRIES = RUBY_ENGINE == "truffleruby" ||

View File

@ -113,7 +113,7 @@ extensions will be restored.
end.flatten end.flatten
end 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? if specs.to_a.empty?
raise Gem::Exception, raise Gem::Exception,

View File

@ -475,7 +475,7 @@ By default, this RubyGems will install gem as:
def files_in(dir) def files_in(dir)
Dir.chdir dir do Dir.chdir dir do
Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH). Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH).
select{|f| !File.directory?(f) } select {|f| !File.directory?(f) }
end end
end end

View File

@ -129,7 +129,7 @@ Specific fields in the specification can be extracted in YAML format:
platform = get_platform_from_requirements(options) platform = get_platform_from_requirements(options)
if platform if platform
specs = specs.select{|s| s.platform.to_s == platform } specs = specs.select {|s| s.platform.to_s == platform }
end end
unless options[:all] unless options[:all]

View File

@ -63,7 +63,7 @@ class Gem::Ext::Builder
require "open3" require "open3"
# Set $SOURCE_DATE_EPOCH for the subprocess. # 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 output, status = begin
Open3.capture2e(env, *command, :chdir => dir) Open3.capture2e(env, *command, :chdir => dir)
rescue => error rescue => error

View File

@ -135,7 +135,7 @@ module Gem::GemcutterUtilities
sign_in_host, scope: scope) do |request| sign_in_host, scope: scope) do |request|
request.basic_auth email, password request.basic_auth email, password
request["OTP"] = otp if otp 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 end
with_response response do |resp| with_response response do |resp|

View File

@ -725,11 +725,11 @@ class Gem::Installer
raise Gem::InstallError, "#{spec} has an invalid name" raise Gem::InstallError, "#{spec} has an invalid name"
end 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" raise Gem::InstallError, "#{spec} has an invalid require_paths"
end end
if spec.extensions.any?{|ext| ext =~ /\R/ } if spec.extensions.any? {|ext| ext =~ /\R/ }
raise Gem::InstallError, "#{spec} has an invalid extensions" raise Gem::InstallError, "#{spec} has an invalid extensions"
end end

View File

@ -26,7 +26,7 @@ module Gem::LocalRemoteOptions
valid_uri_schemes = ["http", "https", "file", "s3"] valid_uri_schemes = ["http", "https", "file", "s3"]
unless valid_uri_schemes.include?(uri.scheme) 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 raise ArgumentError, msg
end end

View File

@ -61,7 +61,7 @@ module Gem::QueryUtils
gem_names = if args.empty? gem_names = if args.empty?
[options[:name]] [options[:name]]
else 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 end
terminate_interaction(check_installed_gems(gem_names)) if check_installed_gems? terminate_interaction(check_installed_gems(gem_names)) if check_installed_gems?

View File

@ -91,8 +91,8 @@ class Gem::SpecFetcher
list.each do |source, specs| list.each do |source, specs|
if dependency.name.is_a?(String) && specs.respond_to?(:bsearch) if dependency.name.is_a?(String) && specs.respond_to?(:bsearch)
start_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 } end_index = (0 ... specs.length).bsearch {|i| specs[i].name > dependency.name }
specs = specs[start_index ... end_index] if start_index && end_index specs = specs[start_index ... end_index] if start_index && end_index
end end

View File

@ -157,7 +157,7 @@ class Gem::Specification < Gem::BasicSpecification
}.freeze }.freeze
# rubocop:disable Style/MutableConstant # rubocop:disable Style/MutableConstant
INITIALIZE_CODE_FOR_DEFAULTS = { } # :nodoc: INITIALIZE_CODE_FOR_DEFAULTS = {} # :nodoc:
# rubocop:enable Style/MutableConstant # rubocop:enable Style/MutableConstant
@@default_value.each do |k,v| @@default_value.each do |k,v|
@ -1110,7 +1110,7 @@ class Gem::Specification < Gem::BasicSpecification
result[spec.name] = spec result[spec.name] = spec
end end
result.map(&:last).flatten.sort_by{|tup| tup.name } result.map(&:last).flatten.sort_by {|tup| tup.name }
end end
## ##

View File

@ -154,7 +154,7 @@ class Gem::SpecificationPolicy
def validate_duplicate_dependencies # :nodoc: def validate_duplicate_dependencies # :nodoc:
# NOTE: see REFACTOR note in Gem::Dependency about types - this might be brittle # 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 = [] error_messages = []
@specification.dependencies.each do |dep| @specification.dependencies.each do |dep|

View File

@ -60,7 +60,7 @@ module Gem::Util
# Invokes system, but silences all output. # Invokes system, but silences all output.
def self.silent_system(*command) def self.silent_system(*command)
opt = {:out => IO::NULL, :err => [:child, :out]} opt = { :out => IO::NULL, :err => [:child, :out] }
if Hash === command.last if Hash === command.last
opt.update(command.last) opt.update(command.last)
cmds = command[0...-1] cmds = command[0...-1]

View File

@ -89,7 +89,7 @@ RSpec.describe "bundler/inline#gemfile" do
expect(out).to include("Installing activesupport") expect(out).to include("Installing activesupport")
err_lines = err.split("\n") 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 expect(err_lines).to be_empty
end end

View File

@ -113,6 +113,10 @@ RSpec.configure do |config|
end end
end end
config.before :each, :sudo => true do
Spec::Sudo.write_safe_config
end
config.after :suite do config.after :suite do
FileUtils.rm_r Spec::Path.pristine_system_gem_path FileUtils.rm_r Spec::Path.pristine_system_gem_path
end end

View File

@ -258,6 +258,10 @@ module Spec
end end
end end
def git_root
ruby_core? ? source_root : source_root.parent
end
private private
def git_ls_files(glob) 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" ruby_core? ? "man/bundle* man/gemfile*" : "lib/bundler/man/bundle*.1 lib/bundler/man/gemfile*.5"
end end
def git_root
ruby_core? ? source_root : source_root.parent
end
def ruby_core_tarball? def ruby_core_tarball?
!git_root.join(".git").directory? !git_root.join(".git").directory?
end end

View File

@ -18,6 +18,12 @@ module Spec
gem_load_and_activate(gem_name, bin_container) gem_load_and_activate(gem_name, bin_container)
end 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) def gem_require(gem_name)
gem_activate(gem_name) gem_activate(gem_name)
require 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}'`" abort "We couldn't activate #{gem_name} (#{e.requirement}). Run `gem install #{gem_name}:'#{e.requirement}'`"
end 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) def gem_activate(gem_name)
require "bundler" 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 gem gem_name, gem_requirement
end end

View File

@ -6,6 +6,10 @@ module Spec
@which_sudo ||= Bundler.which("sudo") @which_sudo ||= Bundler.which("sudo")
end end
def self.write_safe_config
File.write(Spec::Path.tmp("gitconfig"), "[safe]\n\tdirectory = #{Spec::Path.git_root}")
end
def sudo(cmd) def sudo(cmd)
raise "sudo not present" unless Sudo.present? raise "sudo not present" unless Sudo.present?
sys_exec("sudo #{cmd}") sys_exec("sudo #{cmd}")

View File

@ -618,7 +618,7 @@ class Gem::TestCase < Test::Unit::TestCase
gem = File.join(@tempdir, File.basename(gem)).tap(&Gem::UNTAINT) gem = File.join(@tempdir, File.basename(gem)).tap(&Gem::UNTAINT)
end end
Gem::Installer.at(gem, options.merge({:wrappers => true})).install Gem::Installer.at(gem, options.merge({ :wrappers => true })).install
end end
## ##
@ -1294,7 +1294,7 @@ Also, a list:
end end
def rubygems_path 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 end
def with_clean_path_to_ruby def with_clean_path_to_ruby

View File

@ -67,7 +67,7 @@ class Gem::Package::TarTestCase < Gem::TestCase
end end
def calc_checksum(header) 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))) SP(Z(to_oct(sum, 6)))
end end

View File

@ -1061,7 +1061,7 @@ class TestGem < Gem::TestCase
Gem.refresh 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.loaded_specs.delete(s)
Gem.refresh Gem.refresh
@ -1430,7 +1430,7 @@ class TestGem < Gem::TestCase
a = util_spec "a", "1" a = util_spec "a", "1"
b = util_spec "b", "1", "c" => nil b = util_spec "b", "1", "c" => nil
c = util_spec "c", "2" 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" e = util_spec "e", "1"
install_specs a, c, b, e, d install_specs a, c, b, e, d

View File

@ -239,7 +239,7 @@ lib/foo.rb
[RbConfig::CONFIG['bindir'], 'default_command'], [RbConfig::CONFIG['bindir'], 'default_command'],
[RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'], [RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'],
[RbConfig::CONFIG['archdir'], 'default_gem.so'], [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 expected, @ui.output.chomp
assert_equal "", @ui.error assert_equal "", @ui.error

View File

@ -521,7 +521,7 @@ ERROR: Possible alternatives: non_existent_with_hint
end end
def test_execute_required_ruby_version 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 local = Gem::Platform.local
spec_fetcher do |fetcher| spec_fetcher do |fetcher|
@ -610,7 +610,7 @@ ERROR: Possible alternatives: non_existent_with_hint
end end
def test_execute_required_ruby_version_specific_prerelease_not_met 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| spec_fetcher do |fetcher|
fetcher.gem 'a', '1.0' do |s| fetcher.gem 'a', '1.0' do |s|

View File

@ -190,7 +190,7 @@ class TestGemConfigFile < Gem::TestCase
util_config_file util_config_file
assert_equal({:rubygems => '701229f217cdf23b1344c7b4b54ca97'}, assert_equal({ :rubygems => '701229f217cdf23b1344c7b4b54ca97' },
@cfg.api_keys) @cfg.api_keys)
end end
@ -317,8 +317,8 @@ if you believe they were disclosed to a third party.
util_config_file util_config_file
assert_equal({:rubygems => '701229f217cdf23b1344c7b4b54ca97', assert_equal({ :rubygems => '701229f217cdf23b1344c7b4b54ca97',
:other => 'a5fdbb6ba150cbb83aad2bb2fede64c'}, @cfg.api_keys) :other => 'a5fdbb6ba150cbb83aad2bb2fede64c' }, @cfg.api_keys)
end end
def test_load_api_keys_bad_permission def test_load_api_keys_bad_permission

View File

@ -15,7 +15,7 @@ gemspec = File.expand_path('custom_name.gemspec', __dir__)
Dir.mktmpdir("custom_name") do |dir| Dir.mktmpdir("custom_name") do |dir|
built_gem = File.expand_path(File.join(dir, "custom_name.gem")) built_gem = File.expand_path(File.join(dir, "custom_name.gem"))
system(*gem, "build", gemspec, "--output", built_gem) system *gem, "build", gemspec, "--output", built_gem
system(*gem, "install", "--verbose", "--local", built_gem, *ARGV) system *gem, "install", "--verbose", "--local", built_gem, *ARGV
system %q(ruby -rcustom_name -e "puts 'Result: ' + CustomName.say_hello") system %q(ruby -rcustom_name -e "puts 'Result: ' + CustomName.say_hello")
end end

View File

@ -254,7 +254,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end end
def test_verify_api_key def test_verify_api_key
keys = {:other => 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'} keys = { :other => 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' }
File.open Gem.configuration.credentials_path, 'w' do |f| File.open Gem.configuration.credentials_path, 'w' do |f|
f.write keys.to_yaml f.write keys.to_yaml
end end

View File

@ -218,7 +218,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end end
assert_equal %w[lib/code.rb], files 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 end
def test_build def test_build

View File

@ -705,7 +705,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_http_with_additional_headers def test_fetch_http_with_additional_headers
ENV["http_proxy"] = @proxy_uri ENV["http_proxy"] = @proxy_uri
ENV["no_proxy"] = URI::parse(@server_uri).host 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 @fetcher = fetcher
assert_equal "murphy", fetcher.fetch_path(@server_uri) assert_equal "murphy", fetcher.fetch_path(@server_uri)
end end
@ -745,7 +745,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_config_creds def test_fetch_s3_config_creds
Gem.configuration[:s3_source] = { 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' url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do Time.stub :now, Time.at(1561353581) do
@ -757,7 +757,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_config_creds_with_region def test_fetch_s3_config_creds_with_region
Gem.configuration[:s3_source] = { 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' url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do Time.stub :now, Time.at(1561353581) do
@ -769,7 +769,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_config_creds_with_token def test_fetch_s3_config_creds_with_token
Gem.configuration[:s3_source] = { 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' url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do Time.stub :now, Time.at(1561353581) do
@ -784,7 +784,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass' ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
ENV['AWS_SESSION_TOKEN'] = nil ENV['AWS_SESSION_TOKEN'] = nil
Gem.configuration[:s3_source] = { Gem.configuration[:s3_source] = {
'my-bucket' => {:provider => 'env'}, 'my-bucket' => { :provider => 'env' },
} }
url = 's3://my-bucket/gems/specs.4.8.gz' url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do Time.stub :now, Time.at(1561353581) do
@ -800,7 +800,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass' ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
ENV['AWS_SESSION_TOKEN'] = nil ENV['AWS_SESSION_TOKEN'] = nil
Gem.configuration[:s3_source] = { 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' url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do Time.stub :now, Time.at(1561353581) do
@ -816,7 +816,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass' ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
ENV['AWS_SESSION_TOKEN'] = 'testtoken' ENV['AWS_SESSION_TOKEN'] = 'testtoken'
Gem.configuration[:s3_source] = { Gem.configuration[:s3_source] = {
'my-bucket' => {:provider => 'env'}, 'my-bucket' => { :provider => 'env' },
} }
url = 's3://my-bucket/gems/specs.4.8.gz' url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do Time.stub :now, Time.at(1561353581) do
@ -836,7 +836,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_instance_profile_creds def test_fetch_s3_instance_profile_creds
Gem.configuration[:s3_source] = { Gem.configuration[:s3_source] = {
'my-bucket' => {:provider => 'instance_profile'}, 'my-bucket' => { :provider => 'instance_profile' },
} }
url = 's3://my-bucket/gems/specs.4.8.gz' url = 's3://my-bucket/gems/specs.4.8.gz'
@ -850,7 +850,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_instance_profile_creds_with_region def test_fetch_s3_instance_profile_creds_with_region
Gem.configuration[:s3_source] = { 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' url = 's3://my-bucket/gems/specs.4.8.gz'
@ -864,7 +864,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_instance_profile_creds_with_token def test_fetch_s3_instance_profile_creds_with_token
Gem.configuration[:s3_source] = { Gem.configuration[:s3_source] = {
'my-bucket' => {:provider => 'instance_profile'}, 'my-bucket' => { :provider => 'instance_profile' },
} }
url = 's3://my-bucket/gems/specs.4.8.gz' url = 's3://my-bucket/gems/specs.4.8.gz'
@ -894,7 +894,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_no_host def test_fetch_s3_no_host
Gem.configuration[:s3_source] = { 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' url = 's3://other-bucket/gems/specs.4.8.gz'
@ -904,7 +904,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end end
def test_fetch_s3_no_id 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' url = 's3://my-bucket/gems/specs.4.8.gz'
refute_fetch_s3 url, 's3_source for my-bucket missing id or secret' refute_fetch_s3 url, 's3_source for my-bucket missing id or secret'
@ -913,7 +913,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end end
def test_fetch_s3_no_secret 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' url = 's3://my-bucket/gems/specs.4.8.gz'
refute_fetch_s3 url, 's3_source for my-bucket missing id or secret' 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 def test_ssl_client_cert_auth_connection
ssl_server = start_ssl_server({ ssl_server = start_ssl_server({
:SSLVerifyClient => :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_ca_cert = File.join(__dir__, 'ca_cert.pem')
temp_client_cert = File.join(__dir__, 'client.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 def test_do_not_allow_invalid_client_cert_auth_connection
ssl_server = start_ssl_server({ ssl_server = start_ssl_server({
:SSLVerifyClient => :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_ca_cert = File.join(__dir__, 'ca_cert.pem')
temp_client_cert = File.join(__dir__, 'invalid_client.pem') temp_client_cert = File.join(__dir__, 'invalid_client.pem')

View File

@ -248,7 +248,7 @@ DEPENDENCIES
assert_equal %w[a-2], lockfile_set.specs.map {|s| s.full_name } assert_equal %w[a-2], lockfile_set.specs.map {|s| s.full_name }
assert_equal %w[https://gems.example/ https://other.example/], 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 end
def test_parse_GIT def test_parse_GIT

View File

@ -191,7 +191,7 @@ class TestGemResolver < Gem::TestCase
# With the following gems already installed: # With the following gems already installed:
# a-1, b-1, c-1, e-1 # 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: # Make sure the following gems end up getting used/installed/upgraded:
# a-2 (upgraded) # a-2 (upgraded)

View File

@ -210,7 +210,7 @@ class TestGemResolverInstallerSet < Gem::TestCase
def (set.remote_set).prefetch(_) def (set.remote_set).prefetch(_)
raise "called" raise "called"
end end
assert_raise(RuntimeError){ set.prefetch(nil) } assert_raise(RuntimeError) { set.prefetch(nil) }
set = Gem::Resolver::InstallerSet.new :local set = Gem::Resolver::InstallerSet.new :local
def (set.remote_set).prefetch(_) def (set.remote_set).prefetch(_)

View File

@ -158,7 +158,7 @@ end
util_spec "pkg#{pkgi}", pkg_version.to_s, deps util_spec "pkg#{pkgi}", pkg_version.to_s, deps
end end
end end
base = util_spec "pkg_base", "1", {"pkg0" => ">= 0"} base = util_spec "pkg_base", "1", { "pkg0" => ">= 0" }
Gem::Specification.reset Gem::Specification.reset
install_specs(*packages.flatten.reverse) install_specs(*packages.flatten.reverse)
@ -305,10 +305,10 @@ end
def test_require_should_not_conflict def test_require_should_not_conflict
base = util_spec "0", "1", "A" => ">= 1" base = util_spec "0", "1", "A" => ">= 1"
a1 = util_spec "A", "1", {"c" => ">= 2", "b" => "> 0"}, "lib/a.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" a2 = util_spec "A", "2", { "c" => ">= 2", "b" => "> 0" }, "lib/a.rb"
b1 = util_spec "b", "1", {"c" => "= 1"}, "lib/d#{$$}.rb" b1 = util_spec "b", "1", { "c" => "= 1" }, "lib/d#{$$}.rb"
b2 = util_spec "b", "2", {"c" => "= 2"}, "lib/d#{$$}.rb" b2 = util_spec "b", "2", { "c" => "= 2" }, "lib/d#{$$}.rb"
c1 = util_spec "c", "1", {}, "lib/c.rb" c1 = util_spec "c", "1", {}, "lib/c.rb"
c2 = util_spec "c", "2", {}, "lib/c.rb" c2 = util_spec "c", "2", {}, "lib/c.rb"
c3 = util_spec "c", "3", {}, "lib/c.rb" c3 = util_spec "c", "3", {}, "lib/c.rb"
@ -992,8 +992,8 @@ dependencies: []
dir_standard_specs = File.join Gem.dir, 'specifications' dir_standard_specs = File.join Gem.dir, 'specifications'
save_gemspec('a-1', '1', dir_standard_specs){|s| s.name = 'a' } 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('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 ['a-1'], Gem::Specification.stubs_for('a').map {|s| s.full_name }
assert_equal 1, Gem::Specification.class_variable_get(:@@stubs_by_name).length 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 def test_self_stubs_for_no_lazy_loading_after_all_specs_setup
Gem::Specification.all = [util_spec('a', '1')] 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 } assert_equal [], Gem::Specification.stubs_for('b').map {|s| s.full_name }
end end
@ -1060,9 +1060,9 @@ dependencies: []
def test_self_stubs_returns_only_specified_named_specs def test_self_stubs_returns_only_specified_named_specs
dir_standard_specs = File.join Gem.dir, 'specifications' dir_standard_specs = File.join Gem.dir, 'specifications'
save_gemspec('a-1', '1', dir_standard_specs){|s| s.name = '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-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-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 assert_equal ['a-1', 'a-2'], Gem::Specification.stubs_for('a').map(&:full_name).sort
end end

View File

@ -63,8 +63,8 @@ class TestGemRequire < Gem::TestCase
# Providing -I on the commandline should always beat gems # Providing -I on the commandline should always beat gems
def test_dash_i_beats_gems def test_dash_i_beats_gems
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", {"c" => "> 0"}, "lib/b/c.rb" b1 = util_spec "b", "1", { "c" => "> 0" }, "lib/b/c.rb"
c1 = util_spec "c", "1", nil, "lib/c/c.rb" c1 = util_spec "c", "1", nil, "lib/c/c.rb"
c2 = util_spec "c", "2", 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 # Providing -I on the commandline should always beat gems
def test_dash_i_beats_default_gems def test_dash_i_beats_default_gems
a1 = new_default_spec "a", "1", {"b" => "= 1"}, "test_gem_require_a.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" b1 = new_default_spec "b", "1", { "c" => "> 0" }, "b/c.rb"
c1 = new_default_spec "c", "1", nil, "c/c.rb" c1 = new_default_spec "c", "1", nil, "c/c.rb"
c2 = new_default_spec "c", "2", 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 install_specs a1, b1
t1 = create_sync_thread{ assert_require "a#{$$}" } t1 = create_sync_thread { assert_require "a#{$$}" }
t2 = create_sync_thread{ assert_require "b#{$$}" } t2 = create_sync_thread { assert_require "b#{$$}" }
# wait until both files are waiting on the exit latch # wait until both files are waiting on the exit latch
FILE_ENTERED_LATCH.await FILE_ENTERED_LATCH.await
@ -169,7 +169,7 @@ class TestGemRequire < Gem::TestCase
end end
def test_require_is_not_lazy_with_exact_req 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" b1 = util_spec "b", "1", nil, "lib/b/c.rb"
b2 = util_spec "b", "2", nil, "lib/b/c.rb" b2 = util_spec "b", "2", nil, "lib/b/c.rb"
@ -184,7 +184,7 @@ class TestGemRequire < Gem::TestCase
end end
def test_require_is_lazy_with_inexact_req 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" b1 = util_spec "b", "1", nil, "lib/b/c.rb"
b2 = util_spec "b", "2", nil, "lib/b/c.rb" b2 = util_spec "b", "2", nil, "lib/b/c.rb"
@ -199,7 +199,7 @@ class TestGemRequire < Gem::TestCase
end end
def test_require_is_not_lazy_with_one_possible 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" b1 = util_spec "b", "1", nil, "lib/b/c.rb"
install_specs b1, a1 install_specs b1, a1
@ -243,7 +243,7 @@ class TestGemRequire < Gem::TestCase
require 'benchmark' # the stdlib 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" b1 = util_spec "b", "1", nil, "lib/benchmark.rb"
b2 = util_spec "b", "2", nil, "lib/benchmark.rb" b2 = util_spec "b", "2", nil, "lib/benchmark.rb"

View File

@ -2,7 +2,7 @@ require_relative 'helper'
class GemTest < Gem::TestCase class GemTest < Gem::TestCase
def test_rubygems_normal_behaviour 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? assert $?.success?
end end
@ -13,7 +13,7 @@ class GemTest < Gem::TestCase
intentionally_not_implemented_method intentionally_not_implemented_method
RUBY 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 !$?.success?
assert_includes output, "undefined local variable or method `intentionally_not_implemented_method'" 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. " \ 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), *ruby_with_rubygems_and_fake_operating_system_in_load_path(path),
'-e', '-e',
"require \"rubygems\"; puts Gem::Specification.stubs.map(&:full_name)", "require \"rubygems\"; puts Gem::Specification.stubs.map(&:full_name)",
{:err => [:child, :out]} { :err => [:child, :out] }
).strip ).strip
begin begin
assert_empty output assert_empty output
@ -66,6 +66,6 @@ class GemTest < Gem::TestCase
end end
def ruby_with_rubygems_and_fake_operating_system_in_load_path(operating_system_path) 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
end end