aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_request_set.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-14 03:30:02 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-14 03:30:02 +0000
commit4de117a61517e839f2c45eaf45d56fc243d6d5b2 (patch)
tree7cb5af7a7eb513e5dddf5e343746b1611e628387 /test/rubygems/test_gem_request_set.rb
parente548c09d429a5136285ea81aed418685359ed124 (diff)
downloadruby-4de117a61517e839f2c45eaf45d56fc243d6d5b2.tar.gz
* lib/rubygems: Update to RubyGems 2.4.1 master(713ab65)
Complete history at: https://github.com/rubygems/rubygems/blob/master/History.txt#L3-L216 * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_request_set.rb')
-rw-r--r--test/rubygems/test_gem_request_set.rb246
1 files changed, 241 insertions, 5 deletions
diff --git a/test/rubygems/test_gem_request_set.rb b/test/rubygems/test_gem_request_set.rb
index 130728e249..3c1d5ac1d1 100644
--- a/test/rubygems/test_gem_request_set.rb
+++ b/test/rubygems/test_gem_request_set.rb
@@ -42,6 +42,12 @@ class TestGemRequestSet < Gem::TestCase
fetcher.gem 'a', 2
end
+ done_installing_ran = false
+
+ Gem.done_installing do |installer, specs|
+ done_installing_ran = true
+ end
+
rs = Gem::RequestSet.new
installed = []
@@ -61,6 +67,29 @@ class TestGemRequestSet < Gem::TestCase
assert_path_exists 'gem.deps.rb.lock'
assert rs.remote
+ refute done_installing_ran
+ end
+
+ def test_install_from_gemdeps_explain
+ spec_fetcher do |fetcher|
+ fetcher.gem 'a', 2
+ end
+
+ rs = Gem::RequestSet.new
+
+ open 'gem.deps.rb', 'w' do |io|
+ io.puts 'gem "a"'
+ io.flush
+
+ expected = <<-EXPECTED
+Gems to install:
+ a-2
+ EXPECTED
+
+ assert_output expected do
+ rs.install_from_gemdeps :gemdeps => io.path, :explain => true
+ end
+ end
end
def test_install_from_gemdeps_install_dir
@@ -153,6 +182,30 @@ DEPENDENCIES
assert_path_exists File.join @gemhome, 'specifications', 'b-1.gemspec'
end
+ def test_install_from_gemdeps_version_mismatch
+ spec_fetcher do |fetcher|
+ fetcher.gem 'a', 2
+ end
+
+ rs = Gem::RequestSet.new
+ installed = []
+
+ open 'gem.deps.rb', 'w' do |io|
+ io.puts <<-GEM_DEPS
+gem "a"
+ruby "0"
+ GEM_DEPS
+
+ io.flush
+
+ rs.install_from_gemdeps :gemdeps => io.path do |req, installer|
+ installed << req.full_name
+ end
+ end
+
+ assert_includes installed, 'a-2'
+ end
+
def test_load_gemdeps
rs = Gem::RequestSet.new
@@ -160,10 +213,12 @@ DEPENDENCIES
io.puts 'gem "a"'
io.flush
- rs.load_gemdeps io.path
+ gem_deps = rs.load_gemdeps io.path
+
+ assert_kind_of Gem::RequestSet::GemDependencyAPI, gem_deps
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
assert_equal [dep('a')], rs.dependencies
@@ -171,6 +226,24 @@ DEPENDENCIES
assert rs.vendor_set
end
+ def test_load_gemdeps_installing
+ rs = Gem::RequestSet.new
+
+ tf = Tempfile.open 'gem.deps.rb' do |io|
+ io.puts 'ruby "0"'
+ io.puts 'gem "a"'
+ io.flush
+
+ gem_deps = rs.load_gemdeps io.path, [], true
+
+ assert_kind_of Gem::RequestSet::GemDependencyAPI, gem_deps
+ io
+ end
+ tf.close! if tf.respond_to? :close!
+
+ assert_equal [dep('a')], rs.dependencies
+ end
+
def test_load_gemdeps_without_groups
rs = Gem::RequestSet.new
@@ -181,7 +254,7 @@ DEPENDENCIES
rs.load_gemdeps io.path, [:test]
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
assert_empty rs.dependencies
end
@@ -193,12 +266,69 @@ DEPENDENCIES
rs = Gem::RequestSet.new
rs.gem "a"
+ orig_errors = rs.errors
+
res = rs.resolve StaticSet.new([a, b])
assert_equal 2, res.size
names = res.map { |s| s.full_name }.sort
assert_equal ["a-2", "b-2"], names
+
+ refute_same orig_errors, rs.errors
+ end
+
+ def test_bug_bug_990
+ a = util_spec 'a', '1.b', 'b' => '~> 1.a'
+ b = util_spec 'b', '1.b', 'c' => '>= 1'
+ c = util_spec 'c', '1.1.b'
+
+ rs = Gem::RequestSet.new
+ rs.gem 'a'
+ rs.prerelease = true
+
+ res = rs.resolve StaticSet.new([a, b, c])
+ assert_equal 3, res.size
+
+ names = res.map { |s| s.full_name }.sort
+
+ assert_equal %w[a-1.b b-1.b c-1.1.b], names
+ end
+
+ def test_resolve_development
+ a = util_spec 'a', 1
+ spec = Gem::Resolver::SpecSpecification.new nil, a
+
+ rs = Gem::RequestSet.new
+ rs.gem 'a'
+ rs.development = true
+
+ res = rs.resolve StaticSet.new [spec]
+ assert_equal 1, res.size
+
+ assert rs.resolver.development
+ refute rs.resolver.development_shallow
+ end
+
+ def test_resolve_development_shallow
+ a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
+ b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
+ c = util_spec 'c', 1
+
+ a_spec = Gem::Resolver::SpecSpecification.new nil, a
+ b_spec = Gem::Resolver::SpecSpecification.new nil, b
+ c_spec = Gem::Resolver::SpecSpecification.new nil, c
+
+ rs = Gem::RequestSet.new
+ rs.gem 'a'
+ rs.development = true
+ rs.development_shallow = true
+
+ res = rs.resolve StaticSet.new [a_spec, b_spec, c_spec]
+ assert_equal 2, res.size
+
+ assert rs.resolver.development
+ assert rs.resolver.development_shallow
end
def test_resolve_git
@@ -216,7 +346,7 @@ DEPENDENCIES
rs.load_gemdeps io.path
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
res = rs.resolve
assert_equal 1, res.size
@@ -280,7 +410,7 @@ DEPENDENCIES
rs.load_gemdeps io.path
io
end
- tf.close!
+ tf.close! if tf.respond_to? :close!
res = rs.resolve
assert_equal 2, res.size
@@ -308,6 +438,12 @@ DEPENDENCIES
end
def test_install
+ done_installing_ran = false
+
+ Gem.done_installing do
+ done_installing_ran = true
+ end
+
spec_fetcher do |fetcher|
fetcher.gem "a", "1", "b" => "= 1"
fetcher.gem "b", "1"
@@ -336,6 +472,8 @@ DEPENDENCIES
assert_path_exists File.join @gemhome, 'specifications', 'b-1.gemspec'
assert_equal %w[b-1 a-1], installed.map { |s| s.full_name }
+
+ assert done_installing_ran
end
def test_install_into
@@ -358,4 +496,102 @@ DEPENDENCIES
assert_equal %w!b-1 a-1!, installed.map { |s| s.full_name }
end
+
+ def test_install_into_development_shallow
+ spec_fetcher do |fetcher|
+ fetcher.gem 'a', '1' do |s|
+ s.add_development_dependency 'b', '= 1'
+ end
+
+ fetcher.gem 'b', '1' do |s|
+ s.add_development_dependency 'c', '= 1'
+ end
+
+ fetcher.spec 'c', '1'
+ end
+
+ rs = Gem::RequestSet.new
+ rs.development = true
+ rs.development_shallow = true
+ rs.gem 'a'
+
+ rs.resolve
+
+ options = {
+ :development => true,
+ :development_shallow => true,
+ }
+
+ installed = rs.install_into @tempdir, true, options do
+ assert_equal @tempdir, ENV['GEM_HOME']
+ end
+
+ assert_equal %w[a-1 b-1], installed.map { |s| s.full_name }.sort
+ end
+
+ def test_sorted_requests_development_shallow
+ a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
+ b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
+ c = util_spec 'c', 1
+
+ rs = Gem::RequestSet.new
+ rs.gem 'a'
+ rs.development = true
+ rs.development_shallow = true
+
+ a_spec = Gem::Resolver::SpecSpecification.new nil, a
+ b_spec = Gem::Resolver::SpecSpecification.new nil, b
+ c_spec = Gem::Resolver::SpecSpecification.new nil, c
+
+ rs.resolve StaticSet.new [a_spec, b_spec, c_spec]
+
+ assert_equal %w[b-1 a-1], rs.sorted_requests.map { |req| req.full_name }
+ end
+
+ def test_tsort_each_child_development
+ a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
+ b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
+ c = util_spec 'c', 1
+
+ rs = Gem::RequestSet.new
+ rs.gem 'a'
+ rs.development = true
+ rs.development_shallow = true
+
+ a_spec = Gem::Resolver::SpecSpecification.new nil, a
+ b_spec = Gem::Resolver::SpecSpecification.new nil, b
+ c_spec = Gem::Resolver::SpecSpecification.new nil, c
+
+ rs.resolve StaticSet.new [a_spec, b_spec, c_spec]
+
+ a_req = Gem::Resolver::ActivationRequest.new a_spec, nil
+
+ deps = rs.enum_for(:tsort_each_child, a_req).to_a
+
+ assert_equal %w[b], deps.map { |dep| dep.name }
+ end
+
+ def test_tsort_each_child_development_shallow
+ a = util_spec 'a', 1 do |s| s.add_development_dependency 'b' end
+ b = util_spec 'b', 1 do |s| s.add_development_dependency 'c' end
+ c = util_spec 'c', 1
+
+ rs = Gem::RequestSet.new
+ rs.gem 'a'
+ rs.development = true
+ rs.development_shallow = true
+
+ a_spec = Gem::Resolver::SpecSpecification.new nil, a
+ b_spec = Gem::Resolver::SpecSpecification.new nil, b
+ c_spec = Gem::Resolver::SpecSpecification.new nil, c
+
+ rs.resolve StaticSet.new [a_spec, b_spec, c_spec]
+
+ b_req = Gem::Resolver::ActivationRequest.new b_spec, nil
+
+ deps = rs.enum_for(:tsort_each_child, b_req).to_a
+
+ assert_empty deps
+ end
+
end