From 05ca2faba2e0851f2b8c659974b1742458e2cf8e Mon Sep 17 00:00:00 2001 From: drbrain Date: Fri, 18 Oct 2013 00:41:36 +0000 Subject: [PATCH] * 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 --- ChangeLog | 11 ++++++++ lib/rubygems/dependency_installer.rb | 2 +- lib/rubygems/dependency_resolver.rb | 21 +++++++-------- .../dependency_resolver/installer_set.rb | 4 +++ lib/rubygems/request_set.rb | 10 ++++++- .../request_set/gem_dependency_api.rb | 25 +++++++++++++----- lib/rubygems/source.rb | 2 ++ lib/rubygems/test_case.rb | 18 +++++++++++++ test/rubygems/test_gem_request_set.rb | 24 +++++++++++++++++ ...test_gem_request_set_gem_dependency_api.rb | 26 +++++++++++++++++++ test/rubygems/test_gem_specification.rb | 6 +++-- 11 files changed, 128 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5900512d6a..c7bb6775aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Fri Oct 18 09:40:43 2013 Eric Hodel + + * 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 * lib/rubygems: Update to RubyGems master f738c67. Changes: diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb index 8947e81d57..c6985b27c0 100644 --- a/lib/rubygems/dependency_installer.rb +++ b/lib/rubygems/dependency_installer.rb @@ -278,7 +278,7 @@ class Gem::DependencyInstaller # Gathers all dependencies necessary for the installation from local and # remote sources unless the ignore_dependencies was given. #-- - # TODO remove, no longer used + # TODO remove at RubyGems 3 def gather_dependencies # :nodoc: specs = @available.all_specs diff --git a/lib/rubygems/dependency_resolver.rb b/lib/rubygems/dependency_resolver.rb index bbb5408a55..2b3cc1aa34 100644 --- a/lib/rubygems/dependency_resolver.rb +++ b/lib/rubygems/dependency_resolver.rb @@ -43,10 +43,10 @@ class Gem::DependencyResolver ## # 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 - # satisify the Dependencies. This defaults to IndexSet, which will query + # satisfy the Dependencies. This defaults to IndexSet, which will query # rubygems.org. def initialize needed, set = nil @@ -119,15 +119,12 @@ class Gem::DependencyResolver end def handle_conflict(dep, existing) - # There is a conflict! We return the conflict - # object which will be seen by the caller and be - # handled at the right level. + # There is a conflict! We return the conflict object which will be seen by + # the caller and be handled at the right level. - # If the existing activation indicates that there - # are other possibles for it, then issue the conflict - # on the dep for the activation itself. Otherwise, issue - # it on the requester's request itself. - # + # If the existing activation indicates that there are other possibles for + # it, then issue the conflict on the dependency for the activation itself. + # Otherwise, issue it on the requester's request itself. if existing.others_possible? conflict = Gem::DependencyResolver::DependencyConflict.new dep, existing @@ -146,7 +143,7 @@ class Gem::DependencyResolver # +needed+ is a Gem::List of DependencyRequest objects that, well, need # to be satisfied. # +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. # +possible+ is List of DependencyRequest objects that can be tried to # find a complete set. @@ -307,4 +304,6 @@ require 'rubygems/dependency_resolver/index_set' require 'rubygems/dependency_resolver/index_specification' require 'rubygems/dependency_resolver/installed_specification' require 'rubygems/dependency_resolver/installer_set' +require 'rubygems/dependency_resolver/vendor_set' +require 'rubygems/dependency_resolver/vendor_specification' diff --git a/lib/rubygems/dependency_resolver/installer_set.rb b/lib/rubygems/dependency_resolver/installer_set.rb index e19fcd76e4..2993766d3a 100644 --- a/lib/rubygems/dependency_resolver/installer_set.rb +++ b/lib/rubygems/dependency_resolver/installer_set.rb @@ -1,3 +1,7 @@ +## +# A set of gems for installation sourced from remote sources and local .gem +# files + class Gem::DependencyResolver::InstallerSet ## diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb index 0d52423f8f..eb45516cfb 100644 --- a/lib/rubygems/request_set.rb +++ b/lib/rubygems/request_set.rb @@ -36,6 +36,11 @@ class Gem::RequestSet 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 # can then #resolve and #install the resolved list of dependencies. @@ -54,6 +59,7 @@ class Gem::RequestSet @soft_missing = false @sorted = nil @specs = nil + @vendor_set = nil yield self if block_given? end @@ -69,7 +75,7 @@ class Gem::RequestSet # Add +deps+ Gem::Dependency objects to the set. def import deps - @dependencies += deps + @dependencies.concat deps end def install options, &block @@ -143,6 +149,8 @@ class Gem::RequestSet # Load a dependency management file. def load_gemdeps path + @vendor_set = Gem::DependencyResolver::VendorSet.new + gf = Gem::RequestSet::GemDependencyAPI.new self, path gf.load end diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb index 435e157861..40dccb6433 100644 --- a/lib/rubygems/request_set/gem_dependency_api.rb +++ b/lib/rubygems/request_set/gem_dependency_api.rb @@ -8,6 +8,11 @@ class Gem::RequestSet::GemDependencyAPI 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 # Gem::RequestSet +set+ based on the dependency API description in +path+. @@ -18,6 +23,7 @@ class Gem::RequestSet::GemDependencyAPI @current_groups = nil @dependency_groups = Hash.new { |h, group| h[group] = [] } + @vendor_set = @set.vendor_set end ## @@ -41,13 +47,20 @@ class Gem::RequestSet::GemDependencyAPI options = requirements.pop if requirements.last.kind_of?(Hash) options ||= {} - groups = - (group = options.delete(:group) and Array(group)) || - options.delete(:groups) || - @current_groups + if directory = options.delete(:path) then + @vendor_set.add_vendor_gem name, directory + end - if groups then - groups.each do |group| + group = options.delete :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 << options unless options.empty? @dependency_groups[group] << gem_arguments diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb index f0e2a597b9..ecfb6c8897 100644 --- a/lib/rubygems/source.rb +++ b/lib/rubygems/source.rb @@ -162,3 +162,5 @@ end require 'rubygems/source/installed' require 'rubygems/source/specific_file' require 'rubygems/source/local' +require 'rubygems/source/vendor' + diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index d6c1a36ad1..a5a81d72a2 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -1095,6 +1095,24 @@ Also, a list: Gem::Version.create string 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 def initialize(specs) @specs = specs diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb index df26784b2f..5076072791 100644 --- a/test/rubygems/test_gem_request_set.rb +++ b/test/rubygems/test_gem_request_set.rb @@ -17,6 +17,30 @@ class TestGemRequestSet < Gem::TestCase assert_equal [Gem::Dependency.new("a", "=2")], rs.dependencies 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 a = util_spec "a", "2", "b" => ">= 2" b = util_spec "b", "2" diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb index 4747250f60..5c35484421 100644 --- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb +++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb @@ -10,7 +10,10 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase @set = Gem::RequestSet.new + @vendor_set = Gem::DependencyResolver::VendorSet.new + @gda = @GDA.new @set, 'gem.deps.rb' + @gda.instance_variable_set :@vendor_set, @vendor_set end def test_gem @@ -44,6 +47,18 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase assert_empty @set.dependencies 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 @gda.gem 'a', '~> 1.0' @@ -80,6 +95,17 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase assert_empty @set.dependencies 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 Tempfile.open 'gem.deps.rb' do |io| io.write <<-GEM_DEPS diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 5f7c64dd9d..0fd4a2e224 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -1175,8 +1175,10 @@ dependencies: [] @ext.build_extensions end ensure - FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions') - FileUtils.chmod 0755, @ext.base_dir + unless Gem.win_platform? then + FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions') + FileUtils.chmod 0755, @ext.base_dir + end end def test_build_extensions_no_extensions_dir_unwritable