* lib/rubygems: Update to RubyGems master 612f85a. Notable changes:

Fixed installation and activation of git: and path: gems via
  Gem.use_gemdeps

  Improved documentation coverage

* test/rubygems:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-11-25 19:14:49 +00:00
Родитель c107372597
Коммит 04817ae6d3
38 изменённых файлов: 587 добавлений и 88 удалений

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

@ -1,3 +1,14 @@
Tue Nov 26 04:12:10 2013 Eric Hodel <drbrain@segment7.net>
* lib/rubygems: Update to RubyGems master 612f85a. Notable changes:
Fixed installation and activation of git: and path: gems via
Gem.use_gemdeps
Improved documentation coverage
* test/rubygems: ditto.
Mon Nov 25 22:23:03 2013 Zachary Scott <e@zzak.io>
* lib/xmlrpc.rb: [DOC] Fix link to xmlrpc4r site [Bug #9148]

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

@ -1005,30 +1005,18 @@ module Gem
def self.use_gemdeps
return unless path = ENV['RUBYGEMS_GEMDEPS']
path = path.dup.untaint
path = path.dup
if path == "-"
here = Dir.pwd.untaint
start = here
if path == "-" then
require 'rubygems/util'
begin
while true
path = GEM_DEP_FILES.find { |f| File.file?(f) }
Gem::Util.traverse_parents Dir.pwd do |directory|
dep_file = GEM_DEP_FILES.find { |f| File.file?(f) }
if path
path = File.join here, path
break
end
next unless dep_file
Dir.chdir ".."
# If we're at a toplevel, stop.
return if Dir.pwd == here
here = Dir.pwd
end
ensure
Dir.chdir start
path = File.join directory, dep_file
break
end
end
@ -1047,6 +1035,9 @@ module Gem
end
class << self
##
# TODO remove with RubyGems 3.0
alias detect_gemdeps use_gemdeps # :nodoc:
end
@ -1218,4 +1209,5 @@ Gem::Specification.load_defaults
require 'rubygems/core_ext/kernel_gem'
require 'rubygems/core_ext/kernel_require'
Gem.detect_gemdeps
Gem.use_gemdeps

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

@ -127,7 +127,7 @@ class Gem::AvailableSet
end
match.map do |t|
Gem::Resolver::InstalledSpecification.new(self, t.spec, t.source)
Gem::Resolver::LocalSpecification.new(self, t.spec, t.source)
end
end

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

@ -9,6 +9,11 @@ class Gem::BasicSpecification
attr_reader :loaded_from
##
# Allows correct activation of git: and path: gems.
attr_writer :full_gem_path # :nodoc:
def self.default_specifications_dir
File.join(Gem.default_dir, "specifications", "default")
end

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

@ -57,6 +57,11 @@ class Gem::Installer
attr_reader :options
##
# Sets the specification for .gem-less installs.
attr_writer :spec
@path_warning = false
class << self

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

@ -56,11 +56,6 @@ class Gem::Installer
##
# Available through requiring rubygems/installer_test_case
attr_writer :spec
##
# Available through requiring rubygems/installer_test_case
attr_writer :wrappers
end

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

@ -166,29 +166,22 @@ class Gem::RequestSet
installed = []
sorted_requests.each do |req|
if existing.find { |s| s.full_name == req.spec.full_name }
yield req, nil if block_given?
options[:install_dir] = dir
options[:only_install_dir] = true
sorted_requests.each do |request|
spec = request.spec
if existing.find { |s| s.full_name == spec.full_name } then
yield request, nil if block_given?
next
end
path = req.download(dir)
unless path then # already installed
yield req, nil if block_given?
next
spec.install options do |installer|
yield request, installer if block_given?
end
options[:install_dir] = dir
options[:only_install_dir] = true
inst = Gem::Installer.new path, options
yield req, inst if block_given?
inst.install
installed << req
installed << request
end
installed

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

@ -14,13 +14,26 @@ require 'net/http'
class Gem::Resolver
##
# If the DEBUG_RESOLVER environment variable is set then debugging mode is
# enabled for the resolver. This will display information about the state
# of the resolver while a set of dependencies is being resolved.
DEBUG_RESOLVER = !ENV['DEBUG_RESOLVER'].nil?
##
# Contains all the conflicts encountered while doing resolution
attr_reader :conflicts
##
# Set to true if development dependencies should be considered.
attr_accessor :development
##
# List of dependencies that could not be found in the configured sources.
attr_reader :missing
##
@ -57,8 +70,8 @@ class Gem::Resolver
end
##
# Provide a Resolver that queries only against the already
# installed gems.
# Creates a Resolver that queries only against the already installed gems
# for the +needed+ dependencies.
def self.for_current_gems needed
new needed, Gem::Resolver::CurrentSet.new
@ -82,16 +95,14 @@ class Gem::Resolver
@soft_missing = false
end
DEBUG_RESOLVER = !ENV['DEBUG_RESOLVER'].nil?
def explain(stage, *data)
def explain stage, *data # :nodoc:
if DEBUG_RESOLVER
d = data.map { |x| x.inspect }.join(", ")
STDOUT.printf "%20s %s\n", stage.to_s.upcase, d
end
end
def explain_list(stage, data)
def explain_list stage, data # :nodoc:
if DEBUG_RESOLVER
STDOUT.printf "%20s (%d entries)\n", stage.to_s.upcase, data.size
data.each do |d|
@ -117,7 +128,7 @@ class Gem::Resolver
return spec, activation_request
end
def requests s, act, reqs=nil
def requests s, act, reqs=nil # :nodoc:
s.dependencies.reverse_each do |d|
next if d.type == :development and not @development
reqs.add Gem::Resolver::DependencyRequest.new(d, act)
@ -182,7 +193,7 @@ class Gem::Resolver
return matching_platform, all
end
def handle_conflict(dep, existing)
def handle_conflict(dep, existing) # :nodoc:
# There is a conflict! We return the conflict object which will be seen by
# the caller and be handled at the right level.
@ -252,7 +263,7 @@ class Gem::Resolver
# +specs+ being a list to ActivationRequest, calculate a new list of
# ActivationRequest objects.
def resolve_for needed, specs
def resolve_for needed, specs # :nodoc:
# The State objects that are used to attempt the activation tree.
states = []
@ -411,5 +422,6 @@ require 'rubygems/resolver/api_specification'
require 'rubygems/resolver/git_specification'
require 'rubygems/resolver/index_specification'
require 'rubygems/resolver/installed_specification'
require 'rubygems/resolver/local_specification'
require 'rubygems/resolver/vendor_specification'

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

@ -1,21 +1,33 @@
##
# Specifies a Specification object that should be activated.
# Also contains a dependency that was used to introduce this
# activation.
# Specifies a Specification object that should be activated. Also contains a
# dependency that was used to introduce this activation.
class Gem::Resolver::ActivationRequest
##
# The parent request for this activation request.
attr_reader :request
##
# The specification to be activated.
attr_reader :spec
def initialize spec, req, others_possible = true
##
# Creates a new ActivationRequest that will activate +spec+. The parent
# +request+ is used to provide diagnostics in case of conflicts.
#
# +others_possible+ indicates that other specifications may also match this
# activation request.
def initialize spec, request, others_possible = true
@spec = spec
@request = req
@request = request
@others_possible = others_possible
end
def == other
def == other # :nodoc:
case other
when Gem::Specification
@spec == other
@ -26,6 +38,9 @@ class Gem::Resolver::ActivationRequest
end
end
##
# Downloads a gem at +path+ and returns the file path.
def download path
if @spec.respond_to? :source
source = @spec.source
@ -38,10 +53,16 @@ class Gem::Resolver::ActivationRequest
source.download full_spec, path
end
##
# The full name of the specification to be activated.
def full_name
@spec.full_name
end
##
# The Gem::Specification for this activation request.
def full_spec
Gem::Specification === @spec ? @spec : @spec.spec
end
@ -66,7 +87,7 @@ class Gem::Resolver::ActivationRequest
end
##
# Indicates if the requested gem has already been installed.
# True if the requested gem has already been installed.
def installed?
case @spec
@ -81,6 +102,9 @@ class Gem::Resolver::ActivationRequest
end
end
##
# The name of this activation request's specification
def name
@spec.name
end
@ -130,6 +154,9 @@ class Gem::Resolver::ActivationRequest
end
end
##
# The version of this activation request's specification
def version
@spec.version
end

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

@ -34,6 +34,10 @@ class Gem::Resolver::APISpecification < Gem::Resolver::Specification
@dependencies == other.dependencies
end
def installable_platform? # :nodoc:
Gem::Platform.match @platform
end
def pretty_print q # :nodoc:
q.group 2, '[APISpecification', ']' do
q.breakable

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

@ -95,7 +95,6 @@ class Gem::Resolver::Conflict
path = []
while current do
spec_name = current.spec.full_name
requirement = current.request.dependency.requirement
path << "#{current.spec.full_name} (#{requirement})"

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

@ -4,16 +4,26 @@
class Gem::Resolver::DependencyRequest
##
# The wrapped Gem::Dependency
attr_reader :dependency
##
# The request for this dependency.
attr_reader :requester
def initialize(dep, act)
@dependency = dep
@requester = act
##
# Creates a new DependencyRequest for +dependency+ from +requester+.
# +requester may be nil if the request came from a user.
def initialize dependency, requester
@dependency = dependency
@requester = requester
end
def ==(other)
def == other # :nodoc:
case other
when Gem::Dependency
@dependency == other
@ -24,26 +34,39 @@ class Gem::Resolver::DependencyRequest
end
end
##
# Does this dependency request match +spec+
def matches_spec?(spec)
@dependency.matches_spec? spec
end
##
# The name of the gem this dependency request is requesting.
def name
@dependency.name
end
##
# Indicate that the request is for a gem explicitly requested by the user
def explicit?
@requester.nil?
end
# Indicate that the requset is for a gem requested as a dependency of another gem
##
# Indicate that the request is for a gem requested as a dependency of
# another gem
def implicit?
!explicit?
end
##
# Return a String indicating who caused this request to be added (only
# valid for implicit requests)
def request_context
@requester ? @requester.request : "(unknown)"
end
@ -59,6 +82,9 @@ class Gem::Resolver::DependencyRequest
end
end
##
# The version requirement for this dependency request
def requirement
@dependency.requirement
end

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

@ -12,5 +12,24 @@ class Gem::Resolver::GitSpecification < Gem::Resolver::SpecSpecification
@source == other.source
end
##
# Installing a git gem only involves building the extensions and generating
# the executables.
def install options
require 'rubygems/installer'
installer = Gem::Installer.new '', options
installer.spec = spec
yield installer if block_given?
installer.run_pre_install_hooks
installer.build_extensions
installer.run_post_build_hooks
installer.generate_bin
installer.run_post_install_hooks
end
end

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

@ -10,17 +10,23 @@ class Gem::Resolver::InstalledSpecification < Gem::Resolver::SpecSpecification
@spec == other.spec
end
##
# This is a null install as this specification is already installed.
# +options+ are ignored.
def install options
yield nil
end
##
# Returns +true+ if this gem is installable for the current platform.
def installable_platform?
# BACKCOMPAT If the file is coming out of a specified file, then we
# ignore the platform. This code can be removed in RG 3.0.
if @source.kind_of? Gem::Source::SpecificFile
return true
else
Gem::Platform.match @spec.platform
end
return true if @source.kind_of? Gem::Source::SpecificFile
super
end
##

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

@ -20,6 +20,9 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set
attr_accessor :ignore_installed # :nodoc:
##
# Creates a new InstallerSet that will look for gems in +domain+.
def initialize domain
@domain = domain

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

@ -0,0 +1,16 @@
##
# A LocalSpecification comes from a .gem file on the local filesystem.
class Gem::Resolver::LocalSpecification < Gem::Resolver::SpecSpecification
##
# Returns +true+ if this gem is installable for the current platform.
def installable_platform?
return true if @source.kind_of? Gem::Source::SpecificFile
super
end
end

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

@ -1,19 +1,28 @@
##
# Used internally to hold the requirements being considered
# while attempting to find a proper activation set.
# The RequirementList is used to hold the requirements being considered
# while resolving a set of gems.
#
# The RequirementList acts like a queue where the oldest items are removed
# first.
class Gem::Resolver::RequirementList
include Enumerable
##
# Creates a new RequirementList.
def initialize
@list = []
end
def initialize_copy(other)
def initialize_copy other # :nodoc:
@list = @list.dup
end
##
# Adds Resolver::DependencyRequest +req+ to this requirements list.
def add(req)
@list.push req
req
@ -30,14 +39,23 @@ class Gem::Resolver::RequirementList
end
end
##
# Is the list empty?
def empty?
@list.empty?
end
##
# Remove the oldest DependencyRequest from the list.
def remove
@list.shift
end
##
# Returns the oldest five entries from the list.
def next5
@list[0,5]
end

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

@ -56,5 +56,34 @@ class Gem::Resolver::Specification
"#{@name}-#{@version}"
end
##
# Installs this specification using the Gem::Installer +options+. The
# install method yields a Gem::Installer instance, which indicates the
# gem will be installed, or +nil+, which indicates the gem is already
# installed.
def install options
require 'rubygems/installer'
destination = options[:install_dir] || Gem.dir
Gem.ensure_gem_subdirectories destination
gem = source.download spec, destination
installer = Gem::Installer.new gem, options
yield installer if block_given?
installer.install
end
##
# Returns true if this specification is installable on this platform.
def installable_platform?
Gem::Platform.match spec.platform
end
end

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

@ -32,6 +32,8 @@ class Gem::Resolver::VendorSet < Gem::Resolver::Set
raise Gem::GemNotFoundException,
"unable to find #{gemspec} for gem #{name}" unless spec
spec.full_gem_path = File.expand_path directory
key = "#{spec.name}-#{spec.version}-#{spec.platform}"
@specs[key] = spec

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

@ -12,5 +12,13 @@ class Gem::Resolver::VendorSpecification < Gem::Resolver::SpecSpecification
@source == other.source
end
##
# This is a null install as this gem was unpacked into a directory.
# +options+ are ignored.
def install options
yield nil
end
end

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

@ -1,10 +1,26 @@
##
# The TrustDir manages the trusted certificates for gem signature
# verification.
class Gem::Security::TrustDir
##
# Default permissions for the trust directory and its contents
DEFAULT_PERMISSIONS = {
:trust_dir => 0700,
:trusted_cert => 0600,
}
##
# The directory where trusted certificates will be stored.
attr_reader :dir
##
# Creates a new TrustDir using +dir+ where the directory and file
# permissions will be checked according to +permissions+
def initialize dir, permissions = DEFAULT_PERMISSIONS
@dir = dir
@permissions = permissions
@ -12,8 +28,6 @@ class Gem::Security::TrustDir
@digester = Gem::Security::DIGEST_ALGORITHM
end
attr_reader :dir
##
# Returns the path to the trusted +certificate+

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

@ -91,8 +91,8 @@ class Gem::Source::Git < Gem::Source
success = system @git, 'reset', '--quiet', '--hard', @reference
success &&=
system @git, 'submodule', 'update',
'--quiet', '--init', '--recursive', out: IO::NULL if @need_submodules
Gem::Util.silent_system @git, 'submodule', 'update',
'--quiet', '--init', '--recursive' if @need_submodules
success
end
@ -161,7 +161,9 @@ class Gem::Source::Git < Gem::Source
file = File.basename spec_file
Dir.chdir directory do
Gem::Specification.load file
spec = Gem::Specification.load file
spec.full_gem_path = File.expand_path '.' if spec
spec
end
end.compact
end

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

@ -205,6 +205,10 @@ class Gem::TestCase::SpecFetcherSetup
@operations << [:clear]
end
##
# Returns a Hash of created Specification full names and the corresponding
# Specification.
def created_specs
created = {}
@ -271,7 +275,7 @@ class Gem::TestCase::SpecFetcherSetup
end
end
def setup_fetcher # :nodoc;
def setup_fetcher # :nodoc:
require 'zlib'
require 'socket'
require 'rubygems/remote_fetcher'

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

@ -666,6 +666,11 @@ end
# STDOUT, and STDERR.
class Gem::ConsoleUI < Gem::StreamUI
##
# The Console UI has no arguments as it defaults to reading input from
# stdin, output to stdout and warnings or errors to stderr.
def initialize
super STDIN, STDOUT, STDERR, true
end
@ -675,6 +680,10 @@ end
# SilentUI is a UI choice that is absolutely silent.
class Gem::SilentUI < Gem::StreamUI
##
# The SilentUI has no arguments as it does not use any stream.
def initialize
reader, writer = nil, nil
@ -689,11 +698,11 @@ class Gem::SilentUI < Gem::StreamUI
super reader, writer, writer, false
end
def download_reporter(*args)
def download_reporter(*args) # :nodoc:
SilentDownloadReporter.new(@outs, *args)
end
def progress_reporter(*args)
def progress_reporter(*args) # :nodoc:
SilentProgressReporter.new(@outs, *args)
end
end

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

@ -1,4 +1,10 @@
##
# This module contains various utility methods as module methods.
module Gem::Util
@silent_mutex = nil
##
# Zlib::GzipReader wrapper that unzips +data+.
@ -60,4 +66,56 @@ module Gem::Util
end
end
##
# Invokes system, but silences all output.
def self.silent_system *command
require 'thread'
@silent_mutex ||= Mutex.new
null_device = Gem.win_platform? ? 'NUL' : '/dev/null'
@silent_mutex.synchronize do
begin
stdout = STDOUT.dup
stderr = STDERR.dup
STDOUT.reopen null_device, 'w'
STDERR.reopen null_device, 'w'
return system(*command)
ensure
STDOUT.reopen stdout
STDERR.reopen stderr
end
end
end
##
# Enumerates the parents of +directory+.
def self.traverse_parents directory
return enum_for __method__, directory unless block_given?
here = File.expand_path directory
start = here
Dir.chdir start
begin
loop do
yield here
Dir.chdir '..'
return if Dir.pwd == here # toplevel
here = Dir.pwd
end
ensure
Dir.chdir start
end
end
end

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

@ -22,6 +22,25 @@ class TestGemAvailableSet < Gem::TestCase
assert_equal [a1], set.all_specs
end
def test_find_all
a1, a1_gem = util_gem 'a', 1
source = Gem::Source::SpecificFile.new a1_gem
set = Gem::AvailableSet.new
set.add a1, source
dep = Gem::Resolver::DependencyRequest.new dep('a'), nil
specs = set.find_all dep
spec = specs.first
assert_kind_of Gem::Resolver::LocalSpecification, spec
assert_equal 'a-1', spec.full_name
end
def test_match_platform
a1, _ = util_gem 'a', '1' do |g|
g.platform = "something-weird-yep"

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

@ -719,6 +719,9 @@ class TestGemDependencyInstaller < Gem::TestCase
inst.install 'a'
end
assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name },
'sanity check'
ENV['GEM_HOME'] = @gemhome
ENV['GEM_PATH'] = [@gemhome, gemhome2].join File::PATH_SEPARATOR
Gem.clear_paths

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

@ -151,6 +151,7 @@ class TestGemResolver < Gem::TestCase
a2_p1 = a3_p2 = nil
spec_fetcher do |fetcher|
fetcher.spec 'a', 2
a2_p1 = fetcher.spec 'a', 2 do |s| s.platform = Gem::Platform.local end
a3_p2 = fetcher.spec 'a', 3 do |s| s.platform = unknown end
end

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

@ -28,6 +28,42 @@ class TestGemResolverAPISpecification < Gem::TestCase
assert_equal expected, spec.dependencies
end
def test_installable_platform_eh
set = Gem::Resolver::APISet.new
data = {
:name => 'a',
:number => '1',
:platform => 'ruby',
:dependencies => [],
}
a_spec = Gem::Resolver::APISpecification.new set, data
assert a_spec.installable_platform?
data = {
:name => 'b',
:number => '1',
:platform => 'cpu-other_platform-1',
:dependencies => [],
}
b_spec = Gem::Resolver::APISpecification.new set, data
refute b_spec.installable_platform?
data = {
:name => 'c',
:number => '1',
:platform => Gem::Platform.local.to_s,
:dependencies => [],
}
c_spec = Gem::Resolver::APISpecification.new set, data
assert c_spec.installable_platform?
end
def test_source
set = Gem::Resolver::APISet.new
data = {

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

@ -32,5 +32,19 @@ class TestGemResolverGitSpecification < Gem::TestCase
refute_equal g_spec_a, i_spec
end
def test_install
git_gem 'a', 1
git_spec = Gem::Resolver::GitSpecification.new @set, @spec
called = false
git_spec.install({}) do |installer|
called = installer
end
assert called
end
end

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

@ -29,6 +29,28 @@ class TestGemResolverIndexSpecification < Gem::TestCase
assert_equal Gem::Platform.local.to_s, spec.platform
end
def test_install
spec_fetcher do |fetcher|
fetcher.gem 'a', 2
end
set = Gem::Resolver::IndexSet.new
source = Gem::Source.new @gem_repo
spec = Gem::Resolver::IndexSpecification.new(
set, 'a', v(2), source, Gem::Platform::RUBY)
called = false
spec.install({}) do |installer|
called = installer
end
assert_path_exists File.join @gemhome, 'specifications', 'a-2.gemspec'
assert_kind_of Gem::Installer, called
end
def test_spec
specs = spec_fetcher do |fetcher|
fetcher.spec 'a', 2

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

@ -2,17 +2,48 @@ require 'rubygems/test_case'
class TestGemResolverInstalledSpecification < Gem::TestCase
def test_initialize
set = Gem::Resolver::CurrentSet.new
def setup
super
@set = Gem::Resolver::CurrentSet.new
end
def test_initialize
source_spec = util_spec 'a'
spec = Gem::Resolver::InstalledSpecification.new set, source_spec
spec = Gem::Resolver::InstalledSpecification.new @set, source_spec
assert_equal 'a', spec.name
assert_equal Gem::Version.new(2), spec.version
assert_equal Gem::Platform::RUBY, spec.platform
end
def test_install
a = util_spec 'a'
spec = Gem::Resolver::InstalledSpecification.new @set, a
called = :junk
spec.install({}) do |installer|
called = installer
end
assert_nil called
end
def test_installable_platform_eh
b, b_gem = util_gem 'a', 1 do |s|
s.platform = Gem::Platform.new %w[cpu other_platform 1]
end
source = Gem::Source::SpecificFile.new b_gem
b_spec = Gem::Resolver::InstalledSpecification.new @set, b, source
assert b_spec.installable_platform?
end
end

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

@ -0,0 +1,45 @@
require 'rubygems/test_case'
require 'rubygems/available_set'
class TestGemResolverLocalSpecification < Gem::TestCase
def setup
super
@set = Gem::AvailableSet.new
end
def test_install
specs = spec_fetcher do |fetcher|
fetcher.gem 'a', 2
end
source = Gem::Source::SpecificFile.new 'gems/a-2.gem'
spec = Gem::Resolver::LocalSpecification.new @set, specs['a-2'], source
called = false
spec.install({}) do |installer|
called = installer
end
assert_path_exists File.join @gemhome, 'specifications', 'a-2.gemspec'
assert_kind_of Gem::Installer, called
end
def test_installable_platform_eh
b, b_gem = util_gem 'a', 1 do |s|
s.platform = Gem::Platform.new %w[cpu other_platform 1]
end
source = Gem::Source::SpecificFile.new b_gem
b_spec = Gem::Resolver::InstalledSpecification.new @set, b, source
assert b_spec.installable_platform?
end
end

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

@ -0,0 +1,32 @@
require 'rubygems/test_case'
class TestGemResolverSpecification < Gem::TestCase
class TestSpec < Gem::Resolver::Specification
attr_reader :spec
def initialize spec
super()
@spec = spec
end
end
def test_installable_platform_eh
a = util_spec 'a', 1
a_spec = TestSpec.new a
assert a_spec.installable_platform?
b = util_spec 'a', 1 do |s|
s.platform = Gem::Platform.new %w[cpu other_platform 1]
end
b_spec = TestSpec.new b
refute b_spec.installable_platform?
end
end

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

@ -16,6 +16,8 @@ class TestGemResolverVendorSet < Gem::TestCase
spec = @set.load_spec name, version, Gem::Platform::RUBY, nil
assert_equal "#{name}-#{version}", spec.full_name
assert_equal File.expand_path(directory), spec.full_gem_path
end
def test_add_vendor_gem_missing

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

@ -47,6 +47,18 @@ class TestGemResolverVendorSpecification < Gem::TestCase
assert_equal 'a-1', v_spec.full_name
end
def test_install
spec = Gem::Resolver::VendorSpecification.new @set, @spec
called = :junk
spec.install({}) do |installer|
called = installer
end
assert_nil called
end
def test_name
v_spec = Gem::Resolver::VendorSpecification.new @set, @spec

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

@ -25,7 +25,8 @@ class TestGemSourceGit < Gem::TestCase
git_gem 'b'
Dir.chdir 'git/a' do
system @git, 'submodule', '--quiet', 'add', File.expand_path('../b'), 'b', out: IO::NULL
Gem::Util.silent_system @git, 'submodule', '--quiet',
'add', File.expand_path('../b'), 'b'
system @git, 'commit', '--quiet', '-m', 'add submodule b'
end
@ -161,6 +162,14 @@ class TestGemSourceGit < Gem::TestCase
end
assert_equal %w[a-1 b-1], specs.map { |spec| spec.full_name }
a_spec = specs.shift
assert_equal source.install_dir, a_spec.full_gem_path
b_spec = specs.shift
assert_equal File.join(source.install_dir, 'b'), b_spec.full_gem_path
end
def test_uri_hash

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

@ -7,9 +7,25 @@ class TestGemUtil < Gem::TestCase
assert_equal "0\n", Gem::Util.popen(Gem.ruby, '-e', 'p 0')
assert_raises Errno::ECHILD do
Process.wait -1
Process.wait(-1)
end
end
def test_silent_system
assert_silent do
Gem::Util.silent_system Gem.ruby, '-e', 'puts "hello"; warn "hello"'
end
end
def test_traverse_parents
FileUtils.mkdir_p 'a/b/c'
enum = Gem::Util.traverse_parents 'a/b/c'
assert_equal File.join(@tempdir, 'a/b/c'), enum.next
assert_equal File.join(@tempdir, 'a/b'), enum.next
assert_equal File.join(@tempdir, 'a'), enum.next
end
end