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

* lib/rubygems: Update to RubyGems master cee6788. Changes:

Fix test failure on vc10-x64 Server on rubyci.org due to attempting
  to File.chmod where it is not supported.

  Continuing work on improved gem dependencies file (Gemfile) support.

* test:  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2013-10-18 00:41:36 +00:00
parent 4fa08bbaf8
commit 05ca2faba2
11 changed files with 128 additions and 21 deletions

View file

@ -1,3 +1,14 @@
Fri Oct 18 09:40:43 2013 Eric Hodel <drbrain@segment7.net>
* lib/rubygems: Update to RubyGems master cee6788. Changes:
Fix test failure on vc10-x64 Server on rubyci.org due to attempting
to File.chmod where it is not supported.
Continuing work on improved gem dependencies file (Gemfile) support.
* test: ditto.
Fri Oct 18 06:02:49 2013 Eric Hodel <drbrain@segment7.net> Fri Oct 18 06:02:49 2013 Eric Hodel <drbrain@segment7.net>
* lib/rubygems: Update to RubyGems master f738c67. Changes: * lib/rubygems: Update to RubyGems master f738c67. Changes:

View file

@ -278,7 +278,7 @@ class Gem::DependencyInstaller
# Gathers all dependencies necessary for the installation from local and # Gathers all dependencies necessary for the installation from local and
# remote sources unless the ignore_dependencies was given. # remote sources unless the ignore_dependencies was given.
#-- #--
# TODO remove, no longer used # TODO remove at RubyGems 3
def gather_dependencies # :nodoc: def gather_dependencies # :nodoc:
specs = @available.all_specs specs = @available.all_specs

View file

@ -43,10 +43,10 @@ class Gem::DependencyResolver
## ##
# Create DependencyResolver object which will resolve the tree starting # Create DependencyResolver object which will resolve the tree starting
# with +needed+ Depedency objects. # with +needed+ Dependency objects.
# #
# +set+ is an object that provides where to look for specifications to # +set+ is an object that provides where to look for specifications to
# satisify the Dependencies. This defaults to IndexSet, which will query # satisfy the Dependencies. This defaults to IndexSet, which will query
# rubygems.org. # rubygems.org.
def initialize needed, set = nil def initialize needed, set = nil
@ -119,15 +119,12 @@ class Gem::DependencyResolver
end end
def handle_conflict(dep, existing) def handle_conflict(dep, existing)
# There is a conflict! We return the conflict # There is a conflict! We return the conflict object which will be seen by
# object which will be seen by the caller and be # the caller and be handled at the right level.
# handled at the right level.
# If the existing activation indicates that there # If the existing activation indicates that there are other possibles for
# are other possibles for it, then issue the conflict # it, then issue the conflict on the dependency for the activation itself.
# on the dep for the activation itself. Otherwise, issue # Otherwise, issue it on the requester's request itself.
# it on the requester's request itself.
#
if existing.others_possible? if existing.others_possible?
conflict = conflict =
Gem::DependencyResolver::DependencyConflict.new dep, existing Gem::DependencyResolver::DependencyConflict.new dep, existing
@ -146,7 +143,7 @@ class Gem::DependencyResolver
# +needed+ is a Gem::List of DependencyRequest objects that, well, need # +needed+ is a Gem::List of DependencyRequest objects that, well, need
# to be satisfied. # to be satisfied.
# +specs+ is the List of ActivationRequest that are being tested. # +specs+ is the List of ActivationRequest that are being tested.
# +dep+ is the DepedencyRequest that was used to generate this state. # +dep+ is the DependencyRequest that was used to generate this state.
# +spec+ is the Specification for this state. # +spec+ is the Specification for this state.
# +possible+ is List of DependencyRequest objects that can be tried to # +possible+ is List of DependencyRequest objects that can be tried to
# find a complete set. # find a complete set.
@ -307,4 +304,6 @@ require 'rubygems/dependency_resolver/index_set'
require 'rubygems/dependency_resolver/index_specification' require 'rubygems/dependency_resolver/index_specification'
require 'rubygems/dependency_resolver/installed_specification' require 'rubygems/dependency_resolver/installed_specification'
require 'rubygems/dependency_resolver/installer_set' require 'rubygems/dependency_resolver/installer_set'
require 'rubygems/dependency_resolver/vendor_set'
require 'rubygems/dependency_resolver/vendor_specification'

View file

@ -1,3 +1,7 @@
##
# A set of gems for installation sourced from remote sources and local .gem
# files
class Gem::DependencyResolver::InstallerSet class Gem::DependencyResolver::InstallerSet
## ##

View file

@ -36,6 +36,11 @@ class Gem::RequestSet
attr_accessor :soft_missing attr_accessor :soft_missing
##
# The set of vendor gems imported via load_gemdeps.
attr_reader :vendor_set # :nodoc:
## ##
# Creates a RequestSet for a list of Gem::Dependency objects, +deps+. You # Creates a RequestSet for a list of Gem::Dependency objects, +deps+. You
# can then #resolve and #install the resolved list of dependencies. # can then #resolve and #install the resolved list of dependencies.
@ -54,6 +59,7 @@ class Gem::RequestSet
@soft_missing = false @soft_missing = false
@sorted = nil @sorted = nil
@specs = nil @specs = nil
@vendor_set = nil
yield self if block_given? yield self if block_given?
end end
@ -69,7 +75,7 @@ class Gem::RequestSet
# Add +deps+ Gem::Dependency objects to the set. # Add +deps+ Gem::Dependency objects to the set.
def import deps def import deps
@dependencies += deps @dependencies.concat deps
end end
def install options, &block def install options, &block
@ -143,6 +149,8 @@ class Gem::RequestSet
# Load a dependency management file. # Load a dependency management file.
def load_gemdeps path def load_gemdeps path
@vendor_set = Gem::DependencyResolver::VendorSet.new
gf = Gem::RequestSet::GemDependencyAPI.new self, path gf = Gem::RequestSet::GemDependencyAPI.new self, path
gf.load gf.load
end end

View file

@ -8,6 +8,11 @@ class Gem::RequestSet::GemDependencyAPI
attr_reader :dependency_groups attr_reader :dependency_groups
##
# A set of gems that are loaded via the +:path+ option to #gem
attr_reader :vendor_set # :nodoc:
## ##
# Creates a new GemDependencyAPI that will add dependencies to the # Creates a new GemDependencyAPI that will add dependencies to the
# Gem::RequestSet +set+ based on the dependency API description in +path+. # Gem::RequestSet +set+ based on the dependency API description in +path+.
@ -18,6 +23,7 @@ class Gem::RequestSet::GemDependencyAPI
@current_groups = nil @current_groups = nil
@dependency_groups = Hash.new { |h, group| h[group] = [] } @dependency_groups = Hash.new { |h, group| h[group] = [] }
@vendor_set = @set.vendor_set
end end
## ##
@ -41,13 +47,20 @@ class Gem::RequestSet::GemDependencyAPI
options = requirements.pop if requirements.last.kind_of?(Hash) options = requirements.pop if requirements.last.kind_of?(Hash)
options ||= {} options ||= {}
groups = if directory = options.delete(:path) then
(group = options.delete(:group) and Array(group)) || @vendor_set.add_vendor_gem name, directory
options.delete(:groups) || end
@current_groups
if groups then group = options.delete :group
groups.each do |group| all_groups = group ? Array(group) : []
groups = options.delete :groups
all_groups |= groups if groups
all_groups |= @current_groups if @current_groups
unless all_groups.empty? then
all_groups.each do |group|
gem_arguments = [name, *requirements] gem_arguments = [name, *requirements]
gem_arguments << options unless options.empty? gem_arguments << options unless options.empty?
@dependency_groups[group] << gem_arguments @dependency_groups[group] << gem_arguments

View file

@ -162,3 +162,5 @@ end
require 'rubygems/source/installed' require 'rubygems/source/installed'
require 'rubygems/source/specific_file' require 'rubygems/source/specific_file'
require 'rubygems/source/local' require 'rubygems/source/local'
require 'rubygems/source/vendor'

View file

@ -1095,6 +1095,24 @@ Also, a list:
Gem::Version.create string Gem::Version.create string
end end
##
# 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+.
def vendor_gem name = 'a', version = 1
directory = File.join 'vendor', name
vendor_spec = Gem::Specification.new name, version
FileUtils.mkdir_p directory
open File.join(directory, "#{name}.gemspec"), 'w' do |io|
io.write vendor_spec.to_ruby
end
return name, vendor_spec.version, directory
end
class StaticSet class StaticSet
def initialize(specs) def initialize(specs)
@specs = specs @specs = specs

View file

@ -17,6 +17,30 @@ class TestGemRequestSet < Gem::TestCase
assert_equal [Gem::Dependency.new("a", "=2")], rs.dependencies assert_equal [Gem::Dependency.new("a", "=2")], rs.dependencies
end end
def test_import
rs = Gem::RequestSet.new
rs.gem 'a'
rs.import [dep('b')]
assert_equal [dep('a'), dep('b')], rs.dependencies
end
def test_load_gemdeps
rs = Gem::RequestSet.new
Tempfile.open 'gem.deps.rb' do |io|
io.puts 'gem "a"'
io.flush
rs.load_gemdeps io.path
end
assert_equal [dep('a')], rs.dependencies
assert rs.vendor_set
end
def test_resolve def test_resolve
a = util_spec "a", "2", "b" => ">= 2" a = util_spec "a", "2", "b" => ">= 2"
b = util_spec "b", "2" b = util_spec "b", "2"

View file

@ -10,7 +10,10 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
@set = Gem::RequestSet.new @set = Gem::RequestSet.new
@vendor_set = Gem::DependencyResolver::VendorSet.new
@gda = @GDA.new @set, 'gem.deps.rb' @gda = @GDA.new @set, 'gem.deps.rb'
@gda.instance_variable_set :@vendor_set, @vendor_set
end end
def test_gem def test_gem
@ -44,6 +47,18 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_empty @set.dependencies assert_empty @set.dependencies
end end
def test_gem_path
name, version, directory = vendor_gem
@gda.gem name, :path => directory
assert_equal [dep(name)], @set.dependencies
loaded = @vendor_set.load_spec(name, version, Gem::Platform::RUBY, nil)
assert_equal "#{name}-#{version}", loaded.full_name
end
def test_gem_requirement def test_gem_requirement
@gda.gem 'a', '~> 1.0' @gda.gem 'a', '~> 1.0'
@ -80,6 +95,17 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_empty @set.dependencies assert_empty @set.dependencies
end end
def test_group_multiple
@gda.group :a do
@gda.gem 'a', :group => :b, :groups => [:c, :d]
end
assert_equal [['a']], @gda.dependency_groups[:a]
assert_equal [['a']], @gda.dependency_groups[:b]
assert_equal [['a']], @gda.dependency_groups[:c]
assert_equal [['a']], @gda.dependency_groups[:d]
end
def test_load def test_load
Tempfile.open 'gem.deps.rb' do |io| Tempfile.open 'gem.deps.rb' do |io|
io.write <<-GEM_DEPS io.write <<-GEM_DEPS

View file

@ -1175,8 +1175,10 @@ dependencies: []
@ext.build_extensions @ext.build_extensions
end end
ensure ensure
FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions') unless Gem.win_platform? then
FileUtils.chmod 0755, @ext.base_dir FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions')
FileUtils.chmod 0755, @ext.base_dir
end
end end
def test_build_extensions_no_extensions_dir_unwritable def test_build_extensions_no_extensions_dir_unwritable