* lib/rubygems: Update to RubyGems master 0a3814b. Changes:

Fixed extension directory in Gem::Specification#require_paths.

  Allow installation of gems when $HOME is nonexistent or unwritable.

  Use proper API in InstallCommand.

  Improve support for path option in gem dependency files.

  Remove warnings.

* test/rubygems:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-10-18 21:56:18 +00:00
Родитель 9f9b476710
Коммит 08aa6d59a2
17 изменённых файлов: 165 добавлений и 116 удалений

Просмотреть файл

@ -1,3 +1,19 @@
Sat Oct 19 06:55:52 2013 Eric Hodel <drbrain@segment7.net>
* lib/rubygems: Update to RubyGems master 0a3814b. Changes:
Fixed extension directory in Gem::Specification#require_paths.
Allow installation of gems when $HOME is nonexistent or unwritable.
Use proper API in InstallCommand.
Improve support for path option in gem dependency files.
Remove warnings.
* test/rubygems: ditto.
Fri Oct 18 15:23:34 2013 Koichi Sasada <ko1@atdot.net>
* gc.c: change terminology of heap.

Просмотреть файл

@ -176,7 +176,7 @@ class Gem::BasicSpecification
return @require_paths if @extensions.empty?
relative_extension_install_dir =
File.join '..', '..', '..', 'extensions', Gem::Platform.local.to_s,
File.join '..', '..', 'extensions', Gem::Platform.local.to_s,
Gem.extension_api_version, full_name
@require_paths + [relative_extension_install_dir]

Просмотреть файл

@ -135,7 +135,7 @@ to write the specification by hand. For example:
def execute
if gf = options[:gemdeps] then
install_from_gemdeps gf
return
return # not reached
end
@installed_specs = []
@ -151,7 +151,7 @@ to write the specification by hand. For example:
show_installed
raise Gem::SystemExitException, exit_code
terminate_interaction exit_code
end
def install_from_gemdeps gf # :nodoc:
@ -173,7 +173,7 @@ to write the specification by hand. For example:
@installed_specs = specs
raise Gem::SystemExitException, 0
terminate_interaction
end
def install_gem name, version # :nodoc:

Просмотреть файл

@ -159,7 +159,15 @@ class Gem::RequestSet
# Resolve the requested dependencies and return an Array of Specification
# objects to be activated.
def resolve set = nil
def resolve set = Gem::DependencyResolver::IndexSet.new
sets = [set, @vendor_set].compact
set = if sets.size == 1 then
sets.first
else
Gem::DependencyResolver.compose_sets(*sets)
end
resolver = Gem::DependencyResolver.new @dependencies, set
resolver.development = @development
resolver.soft_missing = @soft_missing

Просмотреть файл

@ -51,8 +51,8 @@ class Gem::RequestSet::GemDependencyAPI
@vendor_set.add_vendor_gem name, directory
end
group = options.delete :group
all_groups = group ? Array(group) : []
g = options.delete :group
all_groups = g ? Array(g) : []
groups = options.delete :groups
all_groups |= groups if groups

Просмотреть файл

@ -47,12 +47,7 @@ class Gem::Source
include Comparable
def ==(other)
case other
when self.class
@uri == other.uri
else
false
end
self.class === other and @uri == other.uri
end
alias_method :eql?, :==
@ -71,7 +66,12 @@ class Gem::Source
end
def update_cache?
@update_cache ||= File.stat(Gem.user_home).uid == Process.uid
@update_cache ||=
begin
File.stat(Gem.user_home).uid == Process.uid
rescue Errno::ENOENT
false
end
end
def fetch_spec(name)

Просмотреть файл

@ -1,6 +1,7 @@
class Gem::Source::Installed < Gem::Source
def initialize
@uri = nil
end
##

Просмотреть файл

@ -38,7 +38,12 @@ class Gem::SpecFetcher
end
def initialize
@update_cache = File.stat(Gem.user_home).uid == Process.uid
@update_cache =
begin
File.stat(Gem.user_home).uid == Process.uid
rescue Errno::EACCES, Errno::ENOENT
false
end
@specs = {}
@latest_specs = {}

Просмотреть файл

@ -165,5 +165,12 @@ class Gem::StubSpecification < Gem::BasicSpecification
@version ||= data.version
end
##
# Is there a stub line present for this StubSpecification?
def stubbed?
data.is_a? StubLine
end
end

Просмотреть файл

@ -1098,11 +1098,15 @@ Also, a list:
##
# A vendor_gem is used with a gem dependencies file. The gem created here
# has no files, just a gem specification for the given +name+ and +version+.
#
# Yields the +specification+ to the block, if given
def vendor_gem name = 'a', version = 1
directory = File.join 'vendor', name
vendor_spec = Gem::Specification.new name, version
vendor_spec = Gem::Specification.new name, version do |specification|
yield specification if block_given?
end
FileUtils.mkdir_p directory

Просмотреть файл

@ -38,10 +38,9 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:args] = [@a2.name]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code, @ui.error
end
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@ -62,10 +61,9 @@ class TestGemCommandsInstallCommand < Gem::TestCase
assert @cmd.options[:version].satisfied_by?(@a2_pre.version)
use_ui @ui do
e = assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code, @ui.error
end
assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
@ -83,10 +81,9 @@ class TestGemCommandsInstallCommand < Gem::TestCase
orig_dir = Dir.pwd
begin
Dir.chdir @tempdir
e = assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
ensure
Dir.chdir orig_dir
end
@ -131,7 +128,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:args] = %w[no_such_gem]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
assert_equal 2, e.exit_code
@ -156,7 +153,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:args] = %w[nonexistent]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
assert_equal 2, e.exit_code
@ -184,7 +181,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:args] = %w[nonexistent]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
assert_equal 2, e.exit_code
@ -206,7 +203,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
@cmd.options[:args] = [misspelled]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
@ -230,7 +227,7 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [misspelled]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
@ -273,10 +270,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [@a2_pre.name]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code, @ui.error
end
assert_equal %w[a-1], @cmd.installed_specs.map { |spec| spec.full_name }
@ -296,10 +292,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [@a2_pre.name]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code, @ui.error
end
assert_equal %w[a-2.a], @cmd.installed_specs.map { |spec| spec.full_name }
@ -319,10 +314,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [@a2_pre.name]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code, @ui.error
end
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@ -347,14 +341,12 @@ ERROR: Possible alternatives: non_existent_with_hint
begin
Dir.chdir @tempdir
e = assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
ensure
Dir.chdir old
end
assert_equal 0, e.exit_code
end
wait_for_child_process_to_exit
@ -383,14 +375,12 @@ ERROR: Possible alternatives: non_existent_with_hint
begin
Dir.chdir @tempdir
e = assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
ensure
Dir.chdir old
end
assert_equal 0, e.exit_code
end
path = @a2.build_info_file
@ -410,12 +400,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [@a2.name]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
capture_io do
@cmd.execute
end
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
end
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@ -448,10 +435,9 @@ ERROR: Possible alternatives: non_existent_with_hint
use_ui @ui do
Dir.chdir @tempdir do
e = assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
end
end
@ -478,10 +464,9 @@ ERROR: Possible alternatives: non_existent_with_hint
orig_dir = Dir.pwd
begin
Dir.chdir @tempdir
e = assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
ensure
Dir.chdir orig_dir
end
@ -529,7 +514,7 @@ ERROR: Possible alternatives: non_existent_with_hint
orig_dir = Dir.pwd
begin
Dir.chdir @tempdir
assert_raises Gem::SystemExitException do
assert_raises Gem::MockGemUi::SystemExitException do
@cmd.execute
end
ensure
@ -560,7 +545,7 @@ ERROR: Possible alternatives: non_existent_with_hint
orig_dir = Dir.pwd
begin
Dir.chdir @tempdir
e = assert_raises Gem::SystemExitException do
e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
ensure
@ -582,7 +567,7 @@ ERROR: Possible alternatives: non_existent_with_hint
orig_dir = Dir.pwd
begin
Dir.chdir @tempdir
e = assert_raises Gem::SystemExitException do
e = assert_raises Gem::MockGemUi::TermError do
@cmd.execute
end
ensure
@ -607,12 +592,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:args] = [@a2.name]
use_ui @ui do
e = assert_raises Gem::SystemExitException do
capture_io do
@cmd.execute
end
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
end
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@ -639,12 +621,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
e = assert_raises Gem::SystemExitException do
capture_io do
@cmd.execute
end
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
end
assert_equal %w[], @cmd.installed_specs.map { |spec| spec.full_name }
@ -667,12 +646,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
e = assert_raises Gem::SystemExitException do
capture_io do
@cmd.execute
end
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
end
assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
@ -698,12 +674,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
e = assert_raises Gem::SystemExitException do
capture_io do
@cmd.execute
end
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
end
names = @cmd.installed_specs.map { |spec| spec.full_name }
@ -733,12 +706,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
e = assert_raises Gem::SystemExitException do
capture_io do
@cmd.execute
end
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
end
names = @cmd.installed_specs.map { |spec| spec.full_name }
@ -768,12 +738,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
e = assert_raises Gem::SystemExitException do
capture_io do
@cmd.execute
end
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
end
names = @cmd.installed_specs.map { |spec| spec.full_name }
@ -808,12 +775,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
e = assert_raises Gem::SystemExitException do
capture_io do
@cmd.execute
end
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
end
names = @cmd.installed_specs.map { |spec| spec.full_name }
@ -850,12 +814,9 @@ ERROR: Possible alternatives: non_existent_with_hint
@cmd.options[:gemdeps] = @gemdeps
use_ui @ui do
e = assert_raises Gem::SystemExitException do
capture_io do
@cmd.execute
end
assert_raises Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
assert_equal 0, e.exit_code
end
names = @cmd.installed_specs.map { |spec| spec.full_name }

Просмотреть файл

@ -10,15 +10,6 @@ class TestGemDependencyResolverVendorSpecification < Gem::TestCase
@spec = Gem::Specification.new 'a', 1
end
def test_initialize
v_spec = Gem::DependencyResolver::VendorSpecification.new @set, @spec
assert_equal 'a', v_spec.name
assert_equal v(1), v_spec.version
assert_equal Gem::Platform::RUBY, v_spec.platform
assert_equal Gem::Source::Vendor.new, v_spec.source
end
def test_equals2
v_spec_a = Gem::DependencyResolver::VendorSpecification.new @set, @spec
@ -80,7 +71,7 @@ class TestGemDependencyResolverVendorSpecification < Gem::TestCase
v_spec = Gem::DependencyResolver::VendorSpecification.new @set, spec
assert_equal v(1), spec.version
assert_equal v(1), v_spec.version
end
end

Просмотреть файл

@ -56,6 +56,34 @@ class TestGemRequestSet < Gem::TestCase
assert_equal ["a-2", "b-2"], names
end
def test_resolve_vendor
a_name, _, a_directory = vendor_gem 'a', 1 do |s|
s.add_dependency 'b', '~> 2.0'
end
b_name, _, b_directory = vendor_gem 'b', 2
rs = Gem::RequestSet.new
Tempfile.open 'gem.deps.rb' do |io|
io.puts <<-gems_deps_rb
gem "#{a_name}", :path => "#{a_directory}"
gem "#{b_name}", :path => "#{b_directory}"
gems_deps_rb
io.flush
rs.load_gemdeps io.path
end
res = rs.resolve
assert_equal 2, res.size
names = res.map { |s| s.full_name }.sort
assert_equal ["a-1", "b-2"], names
end
def test_sorted_requests
a = util_spec "a", "2", "b" => ">= 2"
b = util_spec "b", "2", "c" => ">= 2"

Просмотреть файл

@ -207,5 +207,15 @@ class TestGemSource < Gem::TestCase
assert_equal(-1, remote. <=>(no_uri), 'remote <=> no_uri')
end
def test_update_cache_eh
assert @source.update_cache?
end
def test_update_cache_eh_home_nonexistent
FileUtils.rmdir Gem.user_home
refute @source.update_cache?
end
end

Просмотреть файл

@ -52,6 +52,24 @@ class TestGemSpecFetcher < Gem::TestCase
['x', Gem::Version.new(1), 'ruby']]
end
def test_initialize_unwritable_home_dir
FileUtils.rmdir Gem.user_home
assert Gem::SpecFetcher.new
end
def test_initialize_unwritable_home_dir
skip 'chmod not supported' if Gem.win_platform?
FileUtils.chmod 0000, Gem.user_home
begin
assert Gem::SpecFetcher.new
ensure
FileUtils.chmod 0755, Gem.user_home
end
end
def test_spec_for_dependency_all
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))

Просмотреть файл

@ -1659,12 +1659,11 @@ dependencies: []
@ext.require_path = 'lib'
lib = Pathname File.join @ext.gem_dir, 'lib'
ext_install_dir = Pathname(@ext.extension_install_dir)
full_gem_path = Pathname(@ext.full_gem_path)
relative_install_dir = ext_install_dir.relative_path_from full_gem_path
ext_install_dir =
Pathname(@ext.extension_install_dir).relative_path_from lib
assert_equal ['lib', ext_install_dir.to_s], @ext.require_paths
assert_equal ['lib', relative_install_dir.to_s], @ext.require_paths
ensure
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
end

Просмотреть файл

@ -17,6 +17,7 @@ class TestStubSpecification < Gem::TestCase
assert_equal Gem::Version.new("0.0.1"), @foo.version
assert_equal Gem::Platform.new("mswin32"), @foo.platform
assert_equal ["lib", "lib/f oo/ext"], @foo.require_paths
assert @foo.stubbed?
end
def test_initialize_extension
@ -24,17 +25,16 @@ class TestStubSpecification < Gem::TestCase
gem_dir = File.join stub.gems_dir, stub.full_name
lib = Pathname File.join gem_dir, 'lib'
ext_install_dir = Pathname(stub.extension_install_dir)
full_gem_path = Pathname(stub.full_gem_path)
relative_install_dir = ext_install_dir.relative_path_from full_gem_path
relative_install_dir = relative_install_dir.to_s
ext_install_dir =
Pathname(stub.extension_install_dir).relative_path_from lib
ext_install_dir = ext_install_dir.to_s
assert_equal 'stub_e', stub.name
assert_equal v(2), stub.version
assert_equal Gem::Platform::RUBY, stub.platform
assert_equal ['lib', ext_install_dir], stub.require_paths
assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
assert_equal 'stub_e', stub.name
assert_equal v(2), stub.version
assert_equal Gem::Platform::RUBY, stub.platform
assert_equal ['lib', relative_install_dir], stub.require_paths
assert_equal %w[ext/stub_e/extconf.rb], stub.extensions
end
def test_initialize_missing_stubline
@ -43,6 +43,7 @@ class TestStubSpecification < Gem::TestCase
assert_equal Gem::Version.new("0.0.2"), stub.version
assert_equal Gem::Platform.new("ruby"), stub.platform
assert_equal ["lib"], stub.require_paths
assert !stub.stubbed?
end
def test_contains_requirable_file_eh