1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Merge rubygems/rubygems from upstream.

The current master branch is
  97b264f0fa

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2019-04-02 11:48:18 +00:00
parent 5370244337
commit f28be7e02d
34 changed files with 264 additions and 184 deletions

View file

@ -112,7 +112,6 @@ require 'rubygems/errors'
#
# -The RubyGems Team
module Gem
RUBYGEMS_DIR = File.dirname File.expand_path(__FILE__)

View file

@ -71,7 +71,7 @@ class Gem::BasicSpecification
elsif missing_extensions?
@ignored = true
if platform == RUBY_ENGINE
if RUBY_ENGINE == platform || Gem::Platform.local === platform
warn "Ignoring #{full_name} because its extensions are not built. " +
"Try: gem pristine #{name} --version #{version}"
end

View file

@ -593,7 +593,6 @@ class Gem::Command
'Avoid loading any .gemrc file') do
end
# :stopdoc:
HELP = <<-HELP.freeze

View file

@ -319,5 +319,4 @@ For further reading on signing gems see `ri Gem::Security`.
email =~ /\A.+@.+\z/
end
end if defined?(OpenSSL::SSL)

View file

@ -104,7 +104,7 @@ extensions will be restored.
end.flatten
end
specs = specs.select{|spec| spec.platform == RUBY_ENGINE }
specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform }
if specs.to_a.empty?
raise Gem::Exception,

View file

@ -165,7 +165,7 @@ By default, this RubyGems will install gem as:
remove_old_lib_files lib_dir
install_default_bundler_gem
install_default_bundler_gem bin_dir
if mode = options[:dir_mode]
@mkdirs.uniq!
@ -234,21 +234,19 @@ By default, this RubyGems will install gem as:
end
end
def install_executables(bin_dir)
@bin_file_names = []
prog_mode = options[:prog_mode] || 0755
executables = { 'gem' => 'bin' }
executables['bundler'] = 'bundler/exe' if Gem::USE_BUNDLER_FOR_GEMDEPS
executables.each do |tool, path|
say "Installing #{tool} executable" if @verbose
Dir.chdir path do
bin_files = Dir['*']
bin_files -= %w[update_rubygems bundler bundle_ruby]
bin_files -= %w[update_rubygems]
bin_files.each do |bin_file|
bin_file_formatted = if options[:format_executable]
@ -383,7 +381,7 @@ By default, this RubyGems will install gem as:
return false
end
def install_default_bundler_gem
def install_default_bundler_gem(bin_dir)
return unless Gem::USE_BUNDLER_FOR_GEMDEPS
specs_dir = Gem::Specification.default_specifications_dir
@ -428,13 +426,12 @@ By default, this RubyGems will install gem as:
cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
end
if Gem.win_platform?
require 'rubygems/installer'
require 'rubygems/installer'
installer = Gem::Installer.for_spec bundler_spec
bundler_spec.executables.each do |e|
installer.generate_windows_script e, bundler_spec.bin_dir
end
Dir.chdir("bundler") do
built_gem = Gem::Package.build(bundler_spec)
installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], install_as_default: true, bin_dir: bin_dir, wrappers: true)
installer.install
end
say "Bundler #{bundler_spec.version} installed"

View file

@ -148,10 +148,13 @@ that is a dependency of an existing gem. You can use the
def uninstall_specific
deplist = Gem::DependencyList.new
original_gem_version = {}
get_all_gem_names_and_versions.each do |name, version|
requirement = Array(version || options[:version])
gem_specs = Gem::Specification.find_all_by_name(name, *requirement)
original_gem_version[name] = version || options[:version]
gem_specs = Gem::Specification.find_all_by_name(name, original_gem_version[name])
say("Gem '#{name}' is not installed") if gem_specs.empty?
gem_specs.each do |spec|
deplist.add spec
@ -160,16 +163,23 @@ that is a dependency of an existing gem. You can use the
deps = deplist.strongly_connected_components.flatten.reverse
gems_to_uninstall = {}
deps.each do |dep|
options[:version] = dep.version
uninstall_gem(dep.name)
unless gems_to_uninstall[dep.name]
gems_to_uninstall[dep.name] = true
unless original_gem_version[dep.name] == Gem::Requirement.default
options[:version] = dep.version
end
uninstall_gem(dep.name)
end
end
end
def uninstall_gem(gem_name)
uninstall(gem_name)
rescue Gem::InstallError
nil
rescue Gem::GemNotInHomeException => e
spec = e.spec
alert("In order to remove #{spec.name}, please execute:\n" +

View file

@ -143,7 +143,9 @@ class Gem::DependencyInstaller
end
end
results = find_gems_with_sources(dep)
results = Gem::Deprecate.skip_during do
find_gems_with_sources(dep)
end
results.sorted.each do |t|
to_do.push t.spec
@ -166,15 +168,20 @@ class Gem::DependencyInstaller
def available_set_for(dep_or_name, version) # :nodoc:
if String === dep_or_name
find_spec_by_name_and_version dep_or_name, version, @prerelease
Gem::Deprecate.skip_during do
find_spec_by_name_and_version dep_or_name, version, @prerelease
end
else
dep = dep_or_name.dup
dep.prerelease = @prerelease
@available = find_gems_with_sources dep
@available = Gem::Deprecate.skip_during do
find_gems_with_sources dep
end
end
@available.pick_best!
end
deprecate :available_set_for, :none, 2019, 12
##
# Indicated, based on the requested domain, if local
@ -266,6 +273,7 @@ class Gem::DependencyInstaller
set
end
deprecate :find_gems_with_sources, :none, 2019, 12
##
# Finds a spec and the source_uri it came from for gem +gem_name+ and
@ -302,7 +310,10 @@ class Gem::DependencyInstaller
dep = Gem::Dependency.new gem_name, version
dep.prerelease = true if prerelease
set = find_gems_with_sources(dep, true)
set = Gem::Deprecate.skip_during do
find_gems_with_sources(dep, true)
end
set.match_platform!
end
@ -312,6 +323,7 @@ class Gem::DependencyInstaller
@available = set
end
deprecate :find_spec_by_name_and_version, :none, 2019, 12
##
# Gathers all dependencies necessary for the installation from local and
@ -332,7 +344,10 @@ class Gem::DependencyInstaller
dependency_list = Gem::DependencyList.new @development
dependency_list.add(*specs)
to_do = specs.dup
add_found_dependencies to_do, dependency_list unless @ignore_dependencies
Gem::Deprecate.skip_during do
add_found_dependencies to_do, dependency_list unless @ignore_dependencies
end
# REFACTOR maybe abstract away using Gem::Specification.include? so
# that this isn't dependent only on the currently installed gems

View file

@ -190,10 +190,6 @@ module Gem::GemcutterUtilities
# Returns true when the user has enabled multifactor authentication from
# +response+ text and no otp provided by options.
def set_api_key(host, key)
if host == Gem::DEFAULT_HOST
Gem.configuration.rubygems_api_key = key

View file

@ -324,8 +324,11 @@ class Gem::Installer
build_extensions
write_build_info_file
run_post_build_hooks
end
generate_bin
generate_bin
unless @options[:install_as_default]
write_spec
write_cache_file
end

View file

@ -86,7 +86,6 @@ class Gem::Package
class TarInvalidError < Error; end
attr_accessor :build_time # :nodoc:
##

View file

@ -138,7 +138,6 @@ class Gem::SpecFetcher
return [tuples, errors]
end
##
# Return all gem name tuples who's names match +obj+
@ -157,7 +156,6 @@ class Gem::SpecFetcher
tuples
end
##
# Find and fetch specs that match +dependency+.
#

View file

@ -6,7 +6,6 @@
# See LICENSE.txt for permissions.
#++
require 'rubygems/version'
require 'rubygems/requirement'
require 'rubygems/platform'
@ -18,7 +17,7 @@ require 'rubygems/util/list'
require 'stringio'
##
# The Specification class contains the information for a Gem. Typically
# The Specification class contains the information for a gem. Typically
# defined in a .gemspec file or a Rakefile, and looks like this:
#
# Gem::Specification.new do |s|
@ -364,8 +363,7 @@ class Gem::Specification < Gem::BasicSpecification
##
# The metadata holds extra data for this gem that may be useful to other
# consumers and is settable by gem authors without requiring an update to
# the rubygems software.
# consumers and is settable by gem authors.
#
# Metadata items have the following restrictions:
#
@ -775,15 +773,6 @@ class Gem::Specification < Gem::BasicSpecification
end
private_class_method :gemspec_stubs_in
def self.default_stubs(pattern)
base_dir = Gem.default_dir
gems_dir = File.join base_dir, "gems"
gemspec_stubs_in(default_specifications_dir, pattern) do |path|
Gem::StubSpecification.default_gemspec_stub(path, base_dir, gems_dir)
end
end
private_class_method :default_stubs
def self.installed_stubs(dirs, pattern)
map_stubs(dirs, pattern) do |path, base_dir, gems_dir|
Gem::StubSpecification.gemspec_stub(path, base_dir, gems_dir)
@ -832,6 +821,17 @@ class Gem::Specification < Gem::BasicSpecification
end
end
##
# Returns a Gem::StubSpecification for default gems
def self.default_stubs(pattern = "*.gemspec")
base_dir = Gem.default_dir
gems_dir = File.join base_dir, "gems"
gemspec_stubs_in(default_specifications_dir, pattern) do |path|
Gem::StubSpecification.default_gemspec_stub(path, base_dir, gems_dir)
end
end
EMPTY = [].freeze # :nodoc:
##
@ -872,51 +872,6 @@ class Gem::Specification < Gem::BasicSpecification
end
end
##
# Adds +spec+ to the known specifications, keeping the collection
# properly sorted.
def self.add_spec(spec)
warn "Gem::Specification.add_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
# TODO: find all extraneous adds
# puts
# p :add_spec => [spec.full_name, caller.reject { |s| s =~ /minitest/ }]
# TODO: flush the rest of the crap from the tests
# raise "no dupes #{spec.full_name} in #{all_names.inspect}" if
# _all.include? spec
raise "nil spec!" unless spec # TODO: remove once we're happy with tests
return if _all.include? spec
_all << spec
stubs << spec
(@@stubs_by_name[spec.name] ||= []) << spec
sort_by!(@@stubs_by_name[spec.name]) { |s| s.version }
_resort!(_all)
_resort!(stubs)
end
##
# Adds multiple specs to the known specifications.
def self.add_specs(*specs)
warn "Gem::Specification.add_specs is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
# TODO: this is much more efficient, but we need the extra checks for now
# _all.concat specs
# _resort!
Gem::Deprecate.skip_during do
specs.each do |spec| # TODO: slow
add_spec spec
end
end
end
##
# Returns all specifications. This method is discouraged from use.
# You probably want to use one of the Enumerable methods instead.
@ -1244,17 +1199,6 @@ class Gem::Specification < Gem::BasicSpecification
nil
end
##
# Removes +spec+ from the known specs.
def self.remove_spec(spec)
warn "Gem::Specification.remove_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
_all.delete spec
stubs.delete_if { |s| s.full_name == spec.full_name }
(@@stubs_by_name[spec.name] || []).delete_if { |s| s.full_name == spec.full_name }
reset
end
##
# Is +name+ a required attribute?
@ -2029,8 +1973,6 @@ class Gem::Specification < Gem::BasicSpecification
yaml_initialize coder.tag, coder.map
end
eval <<-RB, binding, __FILE__, __LINE__ + 1
def set_nil_attributes_to_nil
#{@@nil_attributes.map {|key| "@#{key} = nil" }.join "; "}

View file

@ -383,8 +383,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
Gem.searcher = nil
Gem::SpecFetcher.fetcher = nil
@orig_BASERUBY = RbConfig::CONFIG['BASERUBY']
RbConfig::CONFIG['BASERUBY'] = RbConfig::CONFIG['ruby_install_name']
@orig_arch = RbConfig::CONFIG['arch']
@ -422,11 +420,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
end
end
if @orig_BASERUBY
RbConfig::CONFIG['BASERUBY'] = @orig_BASERUBY
else
RbConfig::CONFIG.delete('BASERUBY')
end
RbConfig::CONFIG['arch'] = @orig_arch
if defined? Gem::RemoteFetcher
@ -716,7 +709,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
end
deprecate :quick_spec, :util_spec, 2018, 12
##
# Builds a gem from +spec+ and places it in <tt>File.join @gemhome,
# 'cache'</tt>. Automatically creates files based on +spec.files+

View file

@ -954,37 +954,23 @@ class TestGem < Gem::TestCase
end
def test_self_ruby_escaping_spaces_in_path
orig_bindir = RbConfig::CONFIG['bindir']
orig_exe_ext = RbConfig::CONFIG['EXEEXT']
RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin"
RbConfig::CONFIG['EXEEXT'] = ".exe"
ruby_install_name "ruby" do
with_clean_path_to_ruby do
assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
with_clean_path_to_ruby do
with_bindir_and_exeext("C:/Ruby 1.8/bin", ".exe") do
ruby_install_name "ruby" do
assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
end
end
end
ensure
RbConfig::CONFIG['bindir'] = orig_bindir
RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
end
def test_self_ruby_path_without_spaces
orig_bindir = RbConfig::CONFIG['bindir']
orig_exe_ext = RbConfig::CONFIG['EXEEXT']
RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin"
RbConfig::CONFIG['EXEEXT'] = ".exe"
ruby_install_name "ruby" do
with_clean_path_to_ruby do
assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
with_clean_path_to_ruby do
with_bindir_and_exeext("C:/Ruby18/bin", ".exe") do
ruby_install_name "ruby" do
assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
end
end
end
ensure
RbConfig::CONFIG['bindir'] = orig_bindir
RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
end
def test_self_ruby_api_version
@ -1902,6 +1888,19 @@ You may need to `gem install -g` to install missing gems
end
end
def with_bindir_and_exeext(bindir, exeext)
orig_bindir = RbConfig::CONFIG['bindir']
orig_exe_ext = RbConfig::CONFIG['EXEEXT']
RbConfig::CONFIG['bindir'] = bindir
RbConfig::CONFIG['EXEEXT'] = exeext
yield
ensure
RbConfig::CONFIG['bindir'] = orig_bindir
RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
end
def with_clean_path_to_ruby
orig_ruby = Gem.ruby
@ -1909,7 +1908,7 @@ You may need to `gem install -g` to install missing gems
yield
ensure
Gem.instance_variable_set("@ruby", orig_ruby)
Gem.instance_variable_set :@ruby, orig_ruby
end
def with_plugin(path)

View file

@ -614,7 +614,6 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_equal args, a2.build_args
end
def test_execute_remote
spec_fetcher do |fetcher|
fetcher.gem 'a', 2

View file

@ -68,7 +68,6 @@ EOF
end
end
def test_show_owners_setting_up_host_through_env_var
response = "- email: user1@example.com\n"
host = "http://rubygems.example"

View file

@ -542,8 +542,10 @@ class TestGemCommandsPristineCommand < Gem::TestCase
@cmd.options[:extensions_set] = true
@cmd.options[:args] = []
use_ui @ui do
@cmd.execute
util_set_arch "x86_64-darwin" do
use_ui @ui do
@cmd.execute
end
end
out = @ui.output.split "\n"

View file

@ -250,7 +250,6 @@ class TestGemCommandsPushCommand < Gem::TestCase
spec.metadata['allowed_push_host'] = "https://privategemserver.example"
end
response = %{ERROR: "#{@host}" is not allowed by the gemspec, which only allows "https://privategemserver.example"}
assert_raises Gem::MockGemUi::TermError do

View file

@ -57,6 +57,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
FileUtils.mkdir_p 'default/gems'
gemspec = Gem::Specification.new
gemspec.author = "Us"
gemspec.name = "bundler"
gemspec.version = BUNDLER_VERS
gemspec.bindir = "exe"
@ -185,16 +186,19 @@ class TestGemCommandsSetupCommand < Gem::TestCase
def test_install_default_bundler_gem
@cmd.extend FileUtils
@cmd.install_default_bundler_gem
bin_dir = File.join(@gemhome, 'bin')
@cmd.install_default_bundler_gem bin_dir
if Gem.win_platform?
bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
default_spec_path = File.join(Gem::Specification.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
spec = Gem::Specification.load(default_spec_path)
bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
default_spec_path = File.join(Gem::Specification.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
spec = Gem::Specification.load(default_spec_path)
spec.executables.each do |e|
assert_path_exists File.join(spec.bin_dir, "#{e}.bat")
spec.executables.each do |e|
if Gem.win_platform?
assert_path_exists File.join(bin_dir, "#{e}.bat")
end
assert_path_exists File.join bin_dir, e
end
default_dir = Gem::Specification.default_specifications_dir

View file

@ -197,6 +197,62 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
assert File.exist? File.join(@gemhome, 'bin', 'executable')
end
def test_uninstall_selection
ui = Gem::MockGemUi.new "1\n"
util_make_gems
list = Gem::Specification.find_all_by_name 'a'
@cmd.options[:args] = ['a']
use_ui ui do
@cmd.execute
end
updated_list = Gem::Specification.find_all_by_name('a')
assert_equal list.length - 1, updated_list.length
assert_match ' 1. a-1', ui.output
assert_match ' 2. a-2', ui.output
assert_match ' 3. a-3.a', ui.output
assert_match ' 4. All versions', ui.output
assert_match 'uninstalled a-1', ui.output
end
def test_uninstall_selection_multiple_gems
ui = Gem::MockGemUi.new "1\n"
util_make_gems
a_list = Gem::Specification.find_all_by_name('a')
b_list = Gem::Specification.find_all_by_name('b')
list = a_list + b_list
@cmd.options[:args] = ['a', 'b']
use_ui ui do
@cmd.execute
end
updated_a_list = Gem::Specification.find_all_by_name('a')
updated_b_list = Gem::Specification.find_all_by_name('b')
updated_list = updated_a_list + updated_b_list
assert_equal list.length - 2, updated_list.length
out = ui.output.split("\n")
assert_match 'uninstalled b-2', out.shift
assert_match '', out.shift
assert_match 'Select gem to uninstall:', out.shift
assert_match ' 1. a-1', out.shift
assert_match ' 2. a-2', out.shift
assert_match ' 3. a-3.a', out.shift
assert_match ' 4. All versions', out.shift
assert_match 'uninstalled a-1', out.shift
assert_empty out
end
def test_execute_with_force_and_without_version_uninstalls_everything
ui = Gem::MockGemUi.new "y\n"
@ -251,7 +307,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
gemhome2 = "#{@gemhome}2"
a_4, = util_gem 'a', 4
install_gem a_4, :install_dir => gemhome2
install_gem a_4
Gem::Specification.dirs = [@gemhome, gemhome2]
@ -269,6 +325,29 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
assert_equal %w[default-1], Gem::Specification.all_names.sort
end
def test_execute_outside_gem_home
ui = Gem::MockGemUi.new "y\n"
gemhome2 = "#{@gemhome}2"
a_4, = util_gem 'a', 4
install_gem a_4 , :install_dir => gemhome2
Gem::Specification.dirs = [@gemhome, gemhome2]
assert_includes Gem::Specification.all_names, 'a-4'
@cmd.options[:args] = ['a:4']
e = assert_raises Gem::InstallError do
use_ui ui do
@cmd.execute
end
end
assert_includes e.message, "a is not installed in GEM_HOME"
end
def test_handle_options
@cmd.handle_options %w[]

View file

@ -49,7 +49,6 @@ class TestGemCommandsYankCommand < Gem::TestCase
assert_match %r%Yanking gem from http://example%, @ui.output
assert_match %r%Successfully yanked%, @ui.output
platform = Gem.platforms[1]
body = @fetcher.last_request.body.split('&').sort
assert_equal %W[gem_name=a platform=#{platform} version=1.0], body

View file

@ -385,5 +385,4 @@ class TestGemDependency < Gem::TestCase
assert_match "Could not find 'b' (= 2.0) among 1 total gem(s)", e.message
end
end

View file

@ -56,7 +56,9 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
available = inst.available_set_for 'a', Gem::Requirement.default
available = Gem::Deprecate.skip_during do
inst.available_set_for 'a', Gem::Requirement.default
end
assert_equal %w[a-1], available.set.map { |s| s.spec.full_name }
end
@ -68,7 +70,9 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new :prerelease => true
available = inst.available_set_for 'a', Gem::Requirement.default
available = Gem::Deprecate.skip_during do
inst.available_set_for 'a', Gem::Requirement.default
end
assert_equal %w[a-10.a],
available.sorted.map { |s| s.spec.full_name }
@ -83,7 +87,9 @@ class TestGemDependencyInstaller < Gem::TestCase
dep = Gem::Dependency.new 'a', Gem::Requirement.default
available = inst.available_set_for dep, Gem::Requirement.default
available = Gem::Deprecate.skip_during do
inst.available_set_for dep, Gem::Requirement.default
end
assert_equal %w[a-1], available.set.map { |s| s.spec.full_name }
end
@ -98,7 +104,9 @@ class TestGemDependencyInstaller < Gem::TestCase
dep = Gem::Dependency.new 'a', Gem::Requirement.default
dep.prerelease = true
available = inst.available_set_for dep, Gem::Requirement.default
available = Gem::Deprecate.skip_during do
inst.available_set_for dep, Gem::Requirement.default
end
assert_equal %w[a-10.a],
available.sorted.map { |s| s.spec.full_name }
@ -984,7 +992,9 @@ class TestGemDependencyInstaller < Gem::TestCase
Gem::Specification.reset
set = inst.find_gems_with_sources(dep)
set = Gem::Deprecate.skip_during do
inst.find_gems_with_sources(dep)
end
assert_kind_of Gem::AvailableSet, set
@ -1002,7 +1012,9 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
available = inst.find_spec_by_name_and_version('*.gem')
available = Gem::Deprecate.skip_during do
inst.find_spec_by_name_and_version('*.gem')
end
assert_equal %w[a-1], available.each_spec.map { |spec| spec.full_name }
end
@ -1013,7 +1025,9 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
assert_raises Gem::Package::FormatError do
inst.find_spec_by_name_and_version '*.gem'
Gem::Deprecate.skip_during do
inst.find_spec_by_name_and_version '*.gem'
end
end
end
@ -1023,7 +1037,9 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
e = assert_raises Gem::Package::FormatError do
inst.find_spec_by_name_and_version 'rdoc.gem'
Gem::Deprecate.skip_during do
inst.find_spec_by_name_and_version 'rdoc.gem'
end
end
full_path = File.join @tempdir, 'rdoc.gem'
@ -1036,7 +1052,9 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
e = assert_raises Gem::SpecificGemNotFoundException do
inst.find_spec_by_name_and_version 'rdoc'
Gem::Deprecate.skip_during do
inst.find_spec_by_name_and_version 'rdoc'
end
end
assert_equal "Could not find a valid gem 'rdoc' (>= 0) " +
@ -1050,7 +1068,9 @@ class TestGemDependencyInstaller < Gem::TestCase
inst = Gem::DependencyInstaller.new
e = assert_raises Gem::SpecificGemNotFoundException do
inst.find_spec_by_name_and_version 'rdoc'
Gem::Deprecate.skip_during do
inst.find_spec_by_name_and_version 'rdoc'
end
end
assert_equal "Could not find a valid gem 'rdoc' (>= 0) " +
@ -1067,7 +1087,9 @@ class TestGemDependencyInstaller < Gem::TestCase
set = nil
Dir.chdir @tempdir do
set = inst.find_gems_with_sources dep
set = Gem::Deprecate.skip_during do
inst.find_gems_with_sources dep
end
end
gems = set.sorted
@ -1091,16 +1113,22 @@ class TestGemDependencyInstaller < Gem::TestCase
dependency = Gem::Dependency.new('a', Gem::Requirement.default)
releases =
installer.find_gems_with_sources(dependency).all_specs
set = Gem::Deprecate.skip_during do
installer.find_gems_with_sources(dependency)
end
releases = set.all_specs
assert releases.any? { |s| s.name == 'a' and s.version.to_s == '1' }
refute releases.any? { |s| s.name == 'a' and s.version.to_s == '1.a' }
dependency.prerelease = true
prereleases =
installer.find_gems_with_sources(dependency).all_specs
set = Gem::Deprecate.skip_during do
installer.find_gems_with_sources(dependency)
end
prereleases = set.all_specs
assert_equal [@a1_pre, @a1], prereleases
end
@ -1117,8 +1145,11 @@ class TestGemDependencyInstaller < Gem::TestCase
dependency = Gem::Dependency.new('a', Gem::Requirement.default)
releases =
installer.find_gems_with_sources(dependency, true).all_specs
set = Gem::Deprecate.skip_during do
installer.find_gems_with_sources(dependency, true)
end
releases = set.all_specs
assert_equal [a1_x86_mingw32], releases
end
@ -1130,7 +1161,9 @@ class TestGemDependencyInstaller < Gem::TestCase
dep = Gem::Dependency.new('a')
out = installer.find_gems_with_sources(dep)
out = Gem::Deprecate.skip_during do
installer.find_gems_with_sources(dep)
end
assert out.empty?
assert_kind_of Gem::SourceFetchProblem, installer.errors.first

View file

@ -306,7 +306,6 @@ class TestGemIndexer < Gem::TestCase
util_remove_gem sys_gem
end
def test_update_index
use_ui @ui do
@indexer.generate_index

View file

@ -326,7 +326,7 @@ gem 'other', version
@installer.generate_bin
assert_directory_exists (util_inst_bindir)
assert_directory_exists util_inst_bindir
installed_exec = File.join(util_inst_bindir, 'executable')
assert_path_exists installed_exec
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
@ -1829,10 +1829,10 @@ gem 'other', version
assert_predicate spec, :default_gem?
end
def test_default_gem
def test_default_gem_without_wrappers
FileUtils.rm_f File.join(Gem.dir, 'specifications')
@installer.wrappers = true
@installer.wrappers = false
@installer.options[:install_as_default] = true
@installer.gem_dir = @spec.gem_dir
@ -1850,6 +1850,34 @@ gem 'other', version
default_spec = eval File.read File.join(Gem.default_dir, 'specifications', 'default', 'a-2.gemspec')
assert_equal Gem::Version.new("2"), default_spec.version
assert_equal ['bin/executable'], default_spec.files
assert_directory_exists util_inst_bindir
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
wrapper = File.read installed_exec
refute_match %r|generated by RubyGems|, wrapper
end
def test_default_gem_with_wrappers
FileUtils.rm_f File.join(Gem.dir, 'specifications')
@installer.wrappers = true
@installer.options[:install_as_default] = true
@installer.gem_dir = @spec.gem_dir
use_ui @ui do
@installer.install
end
assert_directory_exists util_inst_bindir
installed_exec = File.join util_inst_bindir, 'executable'
assert_path_exists installed_exec
wrapper = File.read installed_exec
assert_match %r|generated by RubyGems|, wrapper
end
def test_default_gem_with_exe_as_bindir

View file

@ -115,7 +115,6 @@ class TestGemPackage < Gem::Package::TarTestCase
spec.date = Time.at 0
spec.rubygems_version = Gem::Version.new '0'
package = Gem::Package.new spec.file_name
assert_equal Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc, package.build_time

View file

@ -125,7 +125,6 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase
assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now),
@io.string[0, 512])
assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512]
digest = signer.digest_algorithm.new

View file

@ -67,7 +67,6 @@ class TestGemRequestSetLockfileParser < Gem::TestCase
assert_equal File.expand_path("#{@gem_deps_file}.lock"), e.path
end
def test_parse
write_lockfile <<-LOCKFILE.strip
GEM

View file

@ -676,7 +676,6 @@ class TestGemResolver < Gem::TestCase
# activesupport 2.3.5, 2.3.4
# Activemerchant needs activesupport >= 2.3.2. When you require activemerchant, it will activate the latest version that meets that requirement which is 2.3.5. Actionmailer on the other hand needs activesupport = 2.3.4. When rubygems tries to activate activesupport 2.3.4, it will raise an error.
def test_simple_activesupport_problem
sup1 = util_spec "activesupport", "2.3.4"
sup2 = util_spec "activesupport", "2.3.5"

View file

@ -45,5 +45,4 @@ class TestGemResolverInstalledSpecification < Gem::TestCase
assert b_spec.installable_platform?
end
end

View file

@ -358,7 +358,6 @@ class TestGemServer < Gem::TestCase
assert_match 'z 9', @res.body
end
def test_xss_homepage_fix_289313
data = StringIO.new "GET / HTTP/1.0\r\n\r\n"
dir = "#{@gemhome}2"

View file

@ -122,7 +122,6 @@ class TestStubSpecification < Gem::TestCase
end
end
def test_missing_extensions_eh
stub = stub_with_extension do |s|
extconf_rb = File.join s.gem_dir, s.extensions.first

View file

@ -381,7 +381,6 @@ class TestGemRequire < Gem::TestCase
assert_equal %w(a-1), loaded_spec_names
end
def test_require_bundler
b1 = util_spec('bundler', '1', nil, "lib/bundler/setup.rb")
b2a = util_spec('bundler', '2.a', nil, "lib/bundler/setup.rb")