2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2021-06-01 23:32:47 -04:00
|
|
|
require_relative 'helper'
|
2012-11-29 01:52:18 -05:00
|
|
|
require 'rubygems/request_set'
|
|
|
|
|
|
|
|
class TestGemRequestSet < Gem::TestCase
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
Gem::RemoteFetcher.fetcher = @fetcher = Gem::FakeFetcher.new
|
2013-11-10 12:51:40 -05:00
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
@DR = Gem::Resolver
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem
|
|
|
|
util_spec "a", "2"
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
rs.gem "a", "= 2"
|
|
|
|
|
|
|
|
assert_equal [Gem::Dependency.new("a", "=2")], rs.dependencies
|
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def test_gem_duplicate
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
|
|
|
|
rs.gem 'a', '1'
|
|
|
|
rs.gem 'a', '2'
|
|
|
|
|
|
|
|
assert_equal [dep('a', '= 1', '= 2')], rs.dependencies
|
|
|
|
end
|
|
|
|
|
2013-10-17 20:41:36 -04:00
|
|
|
def test_import
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
rs.gem 'a'
|
|
|
|
|
|
|
|
rs.import [dep('b')]
|
|
|
|
|
|
|
|
assert_equal [dep('a'), dep('b')], rs.dependencies
|
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def test_install_from_gemdeps
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.gem 'a', 2
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
done_installing_ran = false
|
|
|
|
|
|
|
|
Gem.done_installing do |installer, specs|
|
|
|
|
done_installing_ran = true
|
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
installed = []
|
|
|
|
|
2018-02-05 21:58:35 -05:00
|
|
|
File.open 'gem.deps.rb', 'w' do |io|
|
2013-11-30 18:27:52 -05:00
|
|
|
io.puts 'gem "a"'
|
|
|
|
io.flush
|
|
|
|
|
|
|
|
result = rs.install_from_gemdeps :gemdeps => io.path do |req, installer|
|
|
|
|
installed << req.full_name
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_kind_of Array, result # what is supposed to be in here?
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_includes installed, 'a-2'
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_exist File.join @gemhome, 'gems', 'a-2'
|
|
|
|
assert_path_exist 'gem.deps.rb.lock'
|
2014-02-03 19:48:31 -05:00
|
|
|
|
|
|
|
assert rs.remote
|
2014-09-13 23:30:02 -04:00
|
|
|
refute done_installing_ran
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_install_from_gemdeps_explain
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.gem 'a', 2
|
|
|
|
end
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
|
2018-02-05 21:58:35 -05:00
|
|
|
File.open 'gem.deps.rb', 'w' do |io|
|
2014-09-13 23:30:02 -04:00
|
|
|
io.puts 'gem "a"'
|
|
|
|
io.flush
|
|
|
|
|
|
|
|
expected = <<-EXPECTED
|
|
|
|
Gems to install:
|
|
|
|
a-2
|
|
|
|
EXPECTED
|
|
|
|
|
2021-05-11 03:45:31 -04:00
|
|
|
actual, _ = capture_output do
|
2014-09-13 23:30:02 -04:00
|
|
|
rs.install_from_gemdeps :gemdeps => io.path, :explain => true
|
|
|
|
end
|
2020-03-18 04:56:41 -04:00
|
|
|
assert_equal(expected, actual)
|
2014-09-13 23:30:02 -04:00
|
|
|
end
|
2013-11-30 18:27:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_install_from_gemdeps_install_dir
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.gem 'a', 2
|
|
|
|
end
|
|
|
|
|
|
|
|
util_clear_gems
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_not_exist File.join Gem.dir, 'gems', 'a-2'
|
2013-11-30 18:27:52 -05:00
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
installed = []
|
|
|
|
|
2018-02-05 21:58:35 -05:00
|
|
|
File.open 'gem.deps.rb', 'w' do |io|
|
2013-11-10 12:51:40 -05:00
|
|
|
io.puts 'gem "a"'
|
2013-12-10 14:54:19 -05:00
|
|
|
end
|
2013-11-10 12:51:40 -05:00
|
|
|
|
2013-12-10 14:54:19 -05:00
|
|
|
options = {
|
|
|
|
:gemdeps => 'gem.deps.rb',
|
|
|
|
:install_dir => "#{@gemhome}2",
|
|
|
|
}
|
2013-11-30 18:27:52 -05:00
|
|
|
|
2013-12-10 14:54:19 -05:00
|
|
|
rs.install_from_gemdeps options do |req, installer|
|
|
|
|
installed << req.full_name
|
2013-11-10 12:51:40 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_includes installed, 'a-2'
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_not_exist File.join Gem.dir, 'gems', 'a-2'
|
2013-11-30 18:27:52 -05:00
|
|
|
end
|
|
|
|
|
2014-02-03 19:48:31 -05:00
|
|
|
def test_install_from_gemdeps_local
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.gem 'a', 2
|
|
|
|
end
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
|
2018-02-05 21:58:35 -05:00
|
|
|
File.open 'gem.deps.rb', 'w' do |io|
|
2014-02-03 19:48:31 -05:00
|
|
|
io.puts 'gem "a"'
|
|
|
|
io.flush
|
|
|
|
|
2021-05-10 23:25:46 -04:00
|
|
|
assert_raise Gem::UnsatisfiableDependencyError do
|
2014-02-03 19:48:31 -05:00
|
|
|
rs.install_from_gemdeps :gemdeps => io.path, :domain => :local
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
refute rs.remote
|
|
|
|
end
|
|
|
|
|
2013-11-30 18:27:52 -05:00
|
|
|
def test_install_from_gemdeps_lockfile
|
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download 'a', 1
|
|
|
|
fetcher.download 'a', 2
|
|
|
|
fetcher.download 'b', 1, 'a' => '>= 0'
|
2013-11-30 18:27:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
installed = []
|
|
|
|
|
2018-02-05 21:58:35 -05:00
|
|
|
File.open 'gem.deps.rb.lock', 'w' do |io|
|
2013-11-30 18:27:52 -05:00
|
|
|
io.puts <<-LOCKFILE
|
|
|
|
GEM
|
|
|
|
remote: #{@gem_repo}
|
|
|
|
specs:
|
|
|
|
a (1)
|
|
|
|
b (1)
|
2013-12-07 20:22:39 -05:00
|
|
|
a (~> 1.0)
|
2013-11-30 18:27:52 -05:00
|
|
|
|
|
|
|
PLATFORMS
|
|
|
|
#{Gem::Platform::RUBY}
|
|
|
|
|
|
|
|
DEPENDENCIES
|
|
|
|
b
|
|
|
|
LOCKFILE
|
|
|
|
end
|
|
|
|
|
2018-02-05 21:58:35 -05:00
|
|
|
File.open 'gem.deps.rb', 'w' do |io|
|
2013-11-30 18:27:52 -05:00
|
|
|
io.puts 'gem "b"'
|
|
|
|
end
|
|
|
|
|
|
|
|
rs.install_from_gemdeps :gemdeps => 'gem.deps.rb' do |req, installer|
|
|
|
|
installed << req.full_name
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_includes installed, 'b-1'
|
|
|
|
assert_includes installed, 'a-1'
|
2013-12-07 20:22:39 -05:00
|
|
|
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_exist File.join @gemhome, 'specifications', 'a-1.gemspec'
|
|
|
|
assert_path_exist File.join @gemhome, 'specifications', 'b-1.gemspec'
|
2013-11-10 12:51:40 -05:00
|
|
|
end
|
|
|
|
|
2020-01-31 21:14:04 -05:00
|
|
|
def test_install_from_gemdeps_complex_dependencies
|
|
|
|
quick_gem("z", 1)
|
|
|
|
quick_gem("z", "1.0.1")
|
|
|
|
quick_gem("z", "1.0.2")
|
|
|
|
quick_gem("z", "1.0.3")
|
|
|
|
quick_gem("z", 2)
|
|
|
|
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.download "z", 1
|
|
|
|
end
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
installed = []
|
|
|
|
|
|
|
|
File.open 'Gemfile.lock', 'w' do |io|
|
|
|
|
io.puts <<-LOCKFILE
|
|
|
|
GEM
|
|
|
|
remote: #{@gem_repo}
|
|
|
|
specs:
|
|
|
|
z (1)
|
|
|
|
|
|
|
|
PLATFORMS
|
|
|
|
#{Gem::Platform::RUBY}
|
|
|
|
|
|
|
|
DEPENDENCIES
|
|
|
|
z (~> 1.0, >= 1.0.1)
|
|
|
|
LOCKFILE
|
|
|
|
end
|
|
|
|
|
|
|
|
File.open 'testo.gemspec', 'w' do |io|
|
|
|
|
io.puts <<-LOCKFILE
|
|
|
|
Gem::Specification.new do |spec|
|
|
|
|
spec.name = 'testo'
|
|
|
|
spec.version = '1.0.0'
|
|
|
|
spec.add_dependency('z', '~> 1.0', '>= 1.0.1')
|
|
|
|
end
|
|
|
|
LOCKFILE
|
|
|
|
end
|
|
|
|
|
|
|
|
File.open 'Gemfile', 'w' do |io|
|
|
|
|
io.puts("gemspec")
|
|
|
|
end
|
|
|
|
|
|
|
|
rs.install_from_gemdeps :gemdeps => 'Gemfile' do |req, installer|
|
|
|
|
installed << req.full_name
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_includes installed, 'z-1.0.3'
|
|
|
|
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_exist File.join @gemhome, 'specifications', 'z-1.0.3.gemspec'
|
2020-01-31 21:14:04 -05:00
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def test_install_from_gemdeps_version_mismatch
|
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.gem 'a', 2
|
|
|
|
end
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
installed = []
|
|
|
|
|
2018-02-05 21:58:35 -05:00
|
|
|
File.open 'gem.deps.rb', 'w' do |io|
|
2014-09-13 23:30:02 -04:00
|
|
|
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
|
|
|
|
|
2013-10-17 20:41:36 -04:00
|
|
|
def test_load_gemdeps
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
|
2020-08-29 06:49:20 -04:00
|
|
|
tf = Tempfile.open 'gem.deps.rb' do |io|
|
2013-10-17 20:41:36 -04:00
|
|
|
io.puts 'gem "a"'
|
|
|
|
io.flush
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
gem_deps = rs.load_gemdeps io.path
|
|
|
|
|
|
|
|
assert_kind_of Gem::RequestSet::GemDependencyAPI, gem_deps
|
2020-08-29 06:49:20 -04:00
|
|
|
io
|
2013-10-17 20:41:36 -04:00
|
|
|
end
|
2020-08-29 06:49:20 -04:00
|
|
|
tf.close!
|
2013-10-17 20:41:36 -04:00
|
|
|
|
|
|
|
assert_equal [dep('a')], rs.dependencies
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
assert rs.git_set
|
2013-10-17 20:41:36 -04:00
|
|
|
assert rs.vendor_set
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def test_load_gemdeps_installing
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
|
2020-08-29 06:49:20 -04:00
|
|
|
tf = Tempfile.open 'gem.deps.rb' do |io|
|
2014-09-13 23:30:02 -04:00
|
|
|
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
|
2020-08-29 06:49:20 -04:00
|
|
|
io
|
2014-09-13 23:30:02 -04:00
|
|
|
end
|
2020-08-29 06:49:20 -04:00
|
|
|
tf.close!
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
assert_equal [dep('a')], rs.dependencies
|
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def test_load_gemdeps_without_groups
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
|
2020-08-29 06:49:20 -04:00
|
|
|
tf = Tempfile.open 'gem.deps.rb' do |io|
|
2013-11-10 12:51:40 -05:00
|
|
|
io.puts 'gem "a", :group => :test'
|
|
|
|
io.flush
|
|
|
|
|
|
|
|
rs.load_gemdeps io.path, [:test]
|
2020-08-29 06:49:20 -04:00
|
|
|
io
|
2013-11-10 12:51:40 -05:00
|
|
|
end
|
2020-08-29 06:49:20 -04:00
|
|
|
tf.close!
|
2013-11-10 12:51:40 -05:00
|
|
|
|
|
|
|
assert_empty rs.dependencies
|
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_resolve
|
|
|
|
a = util_spec "a", "2", "b" => ">= 2"
|
|
|
|
b = util_spec "b", "2"
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
rs.gem "a"
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
orig_errors = rs.errors
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
res = rs.resolve StaticSet.new([a, b])
|
|
|
|
assert_equal 2, res.size
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
names = res.map {|s| s.full_name }.sort
|
2012-11-29 01:52:18 -05:00
|
|
|
|
|
|
|
assert_equal ["a-2", "b-2"], names
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
names = res.map {|s| s.full_name }.sort
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
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
|
2019-02-14 07:59:03 -05:00
|
|
|
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
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
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
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
def test_resolve_git
|
|
|
|
name, _, repository, = git_gem
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
|
2020-08-29 06:49:20 -04:00
|
|
|
tf = Tempfile.open 'gem.deps.rb' do |io|
|
2020-04-20 12:32:51 -04:00
|
|
|
io.puts <<-GEMS_DEPS_RB
|
2013-11-18 19:34:13 -05:00
|
|
|
gem "#{name}", :git => "#{repository}"
|
2020-04-20 12:32:51 -04:00
|
|
|
GEMS_DEPS_RB
|
2013-11-18 19:34:13 -05:00
|
|
|
|
|
|
|
io.flush
|
|
|
|
|
|
|
|
rs.load_gemdeps io.path
|
2020-08-29 06:49:20 -04:00
|
|
|
io
|
2013-11-18 19:34:13 -05:00
|
|
|
end
|
2020-08-29 06:49:20 -04:00
|
|
|
tf.close!
|
2013-11-18 19:34:13 -05:00
|
|
|
|
|
|
|
res = rs.resolve
|
|
|
|
assert_equal 1, res.size
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
names = res.map {|s| s.full_name }.sort
|
2013-11-18 19:34:13 -05:00
|
|
|
|
|
|
|
assert_equal %w[a-1], names
|
|
|
|
|
2016-02-01 07:43:26 -05:00
|
|
|
assert_equal [@DR::BestSet, @DR::GitSet, @DR::VendorSet, @DR::SourceSet],
|
2020-06-10 13:46:05 -04:00
|
|
|
rs.sets.map {|set| set.class }
|
2013-11-18 19:34:13 -05:00
|
|
|
end
|
|
|
|
|
2013-12-17 20:02:58 -05:00
|
|
|
def test_resolve_ignore_dependencies
|
|
|
|
a = util_spec "a", "2", "b" => ">= 2"
|
|
|
|
b = util_spec "b", "2"
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
rs.gem "a"
|
|
|
|
rs.ignore_dependencies = true
|
|
|
|
|
|
|
|
res = rs.resolve StaticSet.new([a, b])
|
|
|
|
assert_equal 1, res.size
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
names = res.map {|s| s.full_name }.sort
|
2013-12-17 20:02:58 -05:00
|
|
|
|
|
|
|
assert_equal %w[a-2], names
|
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def test_resolve_incompatible
|
|
|
|
a1 = util_spec 'a', 1
|
|
|
|
a2 = util_spec 'a', 2
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
rs.gem 'a', '= 1'
|
|
|
|
rs.gem 'a', '= 2'
|
|
|
|
|
|
|
|
set = StaticSet.new [a1, a2]
|
|
|
|
|
2021-05-10 23:25:46 -04:00
|
|
|
assert_raise Gem::UnsatisfiableDependencyError do
|
2013-11-10 12:51:40 -05:00
|
|
|
rs.resolve set
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-10-18 17:56:18 -04:00
|
|
|
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
|
|
|
|
|
2020-08-29 06:49:20 -04:00
|
|
|
tf = Tempfile.open 'gem.deps.rb' do |io|
|
2020-04-20 12:32:51 -04:00
|
|
|
io.puts <<-GEMS_DEPS_RB
|
2013-10-18 17:56:18 -04:00
|
|
|
gem "#{a_name}", :path => "#{a_directory}"
|
|
|
|
gem "#{b_name}", :path => "#{b_directory}"
|
2020-04-20 12:32:51 -04:00
|
|
|
GEMS_DEPS_RB
|
2013-10-18 17:56:18 -04:00
|
|
|
|
|
|
|
io.flush
|
|
|
|
|
|
|
|
rs.load_gemdeps io.path
|
2020-08-29 06:49:20 -04:00
|
|
|
io
|
2013-10-18 17:56:18 -04:00
|
|
|
end
|
2020-08-29 06:49:20 -04:00
|
|
|
tf.close!
|
2013-10-18 17:56:18 -04:00
|
|
|
|
|
|
|
res = rs.resolve
|
|
|
|
assert_equal 2, res.size
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
names = res.map {|s| s.full_name }.sort
|
2013-10-18 17:56:18 -04:00
|
|
|
|
|
|
|
assert_equal ["a-1", "b-2"], names
|
2013-11-10 12:51:40 -05:00
|
|
|
|
2016-02-01 07:43:26 -05:00
|
|
|
assert_equal [@DR::BestSet, @DR::GitSet, @DR::VendorSet, @DR::SourceSet],
|
2020-06-10 13:46:05 -04:00
|
|
|
rs.sets.map {|set| set.class }
|
2013-10-18 17:56:18 -04:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_sorted_requests
|
|
|
|
a = util_spec "a", "2", "b" => ">= 2"
|
|
|
|
b = util_spec "b", "2", "c" => ">= 2"
|
|
|
|
c = util_spec "c", "2"
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
rs.gem "a"
|
|
|
|
|
|
|
|
rs.resolve StaticSet.new([a, b, c])
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
names = rs.sorted_requests.map {|s| s.full_name }
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[c-2 b-2 a-2], names
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
def test_install
|
2014-09-13 23:30:02 -04:00
|
|
|
done_installing_ran = false
|
|
|
|
|
|
|
|
Gem.done_installing do
|
|
|
|
done_installing_ran = true
|
|
|
|
end
|
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
spec_fetcher do |fetcher|
|
2015-07-01 17:50:14 -04:00
|
|
|
fetcher.download "a", "1", "b" => "= 1"
|
|
|
|
fetcher.download "b", "1"
|
2013-11-11 19:16:41 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
rs.gem 'a'
|
|
|
|
|
|
|
|
rs.resolve
|
|
|
|
|
|
|
|
reqs = []
|
|
|
|
installers = []
|
|
|
|
|
|
|
|
installed = rs.install({}) do |req, installer|
|
|
|
|
reqs << req
|
|
|
|
installers << installer
|
|
|
|
end
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
assert_equal %w[b-1 a-1], reqs.map {|req| req.full_name }
|
2013-11-11 19:16:41 -05:00
|
|
|
assert_equal %w[b-1 a-1],
|
2020-06-10 13:46:05 -04:00
|
|
|
installers.map {|installer| installer.spec.full_name }
|
2013-11-11 19:16:41 -05:00
|
|
|
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_exist File.join @gemhome, 'specifications', 'a-1.gemspec'
|
|
|
|
assert_path_exist File.join @gemhome, 'specifications', 'b-1.gemspec'
|
2013-11-11 19:16:41 -05:00
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
assert_equal %w[b-1 a-1], installed.map {|s| s.full_name }
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
assert done_installing_ran
|
2013-11-11 19:16:41 -05:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_install_into
|
2013-11-10 12:51:40 -05:00
|
|
|
spec_fetcher do |fetcher|
|
|
|
|
fetcher.gem "a", "1", "b" => "= 1"
|
|
|
|
fetcher.gem "b", "1"
|
|
|
|
end
|
2012-11-29 01:52:18 -05:00
|
|
|
|
|
|
|
rs = Gem::RequestSet.new
|
|
|
|
rs.gem "a"
|
|
|
|
|
|
|
|
rs.resolve
|
|
|
|
|
2013-12-07 20:22:39 -05:00
|
|
|
installed = rs.install_into @tempdir do
|
|
|
|
assert_equal @tempdir, ENV['GEM_HOME']
|
|
|
|
end
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_exist File.join @tempdir, 'specifications', 'a-1.gemspec'
|
|
|
|
assert_path_exist File.join @tempdir, 'specifications', 'b-1.gemspec'
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
assert_equal %w[b-1 a-1], installed.map {|s| s.full_name }
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
assert_equal %w[a-1 b-1], installed.map {|s| s.full_name }.sort
|
2014-09-13 23:30:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_sorted_requests_development_shallow
|
2019-02-14 07:59:03 -05:00
|
|
|
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
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
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]
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
assert_equal %w[b-1 a-1], rs.sorted_requests.map {|req| req.full_name }
|
2014-09-13 23:30:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_tsort_each_child_development
|
2019-02-14 07:59:03 -05:00
|
|
|
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
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
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
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
assert_equal %w[b], deps.map {|dep| dep.name }
|
2014-09-13 23:30:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_tsort_each_child_development_shallow
|
2019-02-14 07:59:03 -05:00
|
|
|
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
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
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
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|