aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-25 19:14:49 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-25 19:14:49 +0000
commit04817ae6d3e1d898d6fbf09ad146850d26d2b404 (patch)
tree7e5482d13830cacf363d21a087b490588a960095 /test/rubygems
parentc107372597586e1ad0fea03c00a14bdd7205b5d8 (diff)
downloadruby-04817ae6d3e1d898d6fbf09ad146850d26d2b404.tar.gz
* 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
Diffstat (limited to 'test/rubygems')
-rw-r--r--test/rubygems/test_gem_available_set.rb19
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb3
-rw-r--r--test/rubygems/test_gem_resolver.rb1
-rw-r--r--test/rubygems/test_gem_resolver_api_specification.rb36
-rw-r--r--test/rubygems/test_gem_resolver_git_specification.rb14
-rw-r--r--test/rubygems/test_gem_resolver_index_specification.rb22
-rw-r--r--test/rubygems/test_gem_resolver_installed_specification.rb37
-rw-r--r--test/rubygems/test_gem_resolver_local_specification.rb45
-rw-r--r--test/rubygems/test_gem_resolver_specification.rb32
-rw-r--r--test/rubygems/test_gem_resolver_vendor_set.rb2
-rw-r--r--test/rubygems/test_gem_resolver_vendor_specification.rb12
-rw-r--r--test/rubygems/test_gem_source_git.rb11
-rw-r--r--test/rubygems/test_gem_util.rb18
13 files changed, 247 insertions, 5 deletions
diff --git a/test/rubygems/test_gem_available_set.rb b/test/rubygems/test_gem_available_set.rb
index 47023b2b11..9c204d046b 100644
--- a/test/rubygems/test_gem_available_set.rb
+++ b/test/rubygems/test_gem_available_set.rb
@@ -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"
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
index f8c3dd493b..5b50017e84 100644
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ b/test/rubygems/test_gem_dependency_installer.rb
@@ -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
diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb
index 91cf84c5fc..7383114af4 100644
--- a/test/rubygems/test_gem_resolver.rb
+++ b/test/rubygems/test_gem_resolver.rb
@@ -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
diff --git a/test/rubygems/test_gem_resolver_api_specification.rb b/test/rubygems/test_gem_resolver_api_specification.rb
index 4a94135f06..6b21a9d4d8 100644
--- a/test/rubygems/test_gem_resolver_api_specification.rb
+++ b/test/rubygems/test_gem_resolver_api_specification.rb
@@ -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 = {
diff --git a/test/rubygems/test_gem_resolver_git_specification.rb b/test/rubygems/test_gem_resolver_git_specification.rb
index f961a7709a..d724106f08 100644
--- a/test/rubygems/test_gem_resolver_git_specification.rb
+++ b/test/rubygems/test_gem_resolver_git_specification.rb
@@ -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
diff --git a/test/rubygems/test_gem_resolver_index_specification.rb b/test/rubygems/test_gem_resolver_index_specification.rb
index ef474ab2d4..e52f9c7fc6 100644
--- a/test/rubygems/test_gem_resolver_index_specification.rb
+++ b/test/rubygems/test_gem_resolver_index_specification.rb
@@ -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
diff --git a/test/rubygems/test_gem_resolver_installed_specification.rb b/test/rubygems/test_gem_resolver_installed_specification.rb
index f9dda29a6c..d52876f030 100644
--- a/test/rubygems/test_gem_resolver_installed_specification.rb
+++ b/test/rubygems/test_gem_resolver_installed_specification.rb
@@ -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
diff --git a/test/rubygems/test_gem_resolver_local_specification.rb b/test/rubygems/test_gem_resolver_local_specification.rb
new file mode 100644
index 0000000000..fc3175a3f7
--- /dev/null
+++ b/test/rubygems/test_gem_resolver_local_specification.rb
@@ -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
+
diff --git a/test/rubygems/test_gem_resolver_specification.rb b/test/rubygems/test_gem_resolver_specification.rb
new file mode 100644
index 0000000000..2c9c143cee
--- /dev/null
+++ b/test/rubygems/test_gem_resolver_specification.rb
@@ -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
+
diff --git a/test/rubygems/test_gem_resolver_vendor_set.rb b/test/rubygems/test_gem_resolver_vendor_set.rb
index 58519fbf14..985a10723f 100644
--- a/test/rubygems/test_gem_resolver_vendor_set.rb
+++ b/test/rubygems/test_gem_resolver_vendor_set.rb
@@ -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
diff --git a/test/rubygems/test_gem_resolver_vendor_specification.rb b/test/rubygems/test_gem_resolver_vendor_specification.rb
index d7aca569e2..3d94cfed00 100644
--- a/test/rubygems/test_gem_resolver_vendor_specification.rb
+++ b/test/rubygems/test_gem_resolver_vendor_specification.rb
@@ -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
diff --git a/test/rubygems/test_gem_source_git.rb b/test/rubygems/test_gem_source_git.rb
index e32649c2b0..838ae562a7 100644
--- a/test/rubygems/test_gem_source_git.rb
+++ b/test/rubygems/test_gem_source_git.rb
@@ -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
diff --git a/test/rubygems/test_gem_util.rb b/test/rubygems/test_gem_util.rb
index 17a19dd302..414487acc0 100644
--- a/test/rubygems/test_gem_util.rb
+++ b/test/rubygems/test_gem_util.rb
@@ -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