summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-22 08:24:42 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-22 08:24:42 +0000
commit372dcece3f69989d133f720468f1e24aa1133cda (patch)
treec173ca48a23ce18afa44feb15bf68d2dd14ac619 /test
parentd0e5a34ac7c34e70c145024a0fed8f6042814f29 (diff)
Update to RubyGems 1.3.7.pre.1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/gemutilities.rb21
-rw-r--r--test/rubygems/plugin/exception/rubygems_plugin.rb2
-rw-r--r--test/rubygems/plugin/load/rubygems_plugin.rb1
-rw-r--r--test/rubygems/plugin/standarderror/rubygems_plugin.rb2
-rw-r--r--test/rubygems/rubygems/commands/crash_command.rb5
-rw-r--r--test/rubygems/rubygems_plugin.rb5
-rw-r--r--test/rubygems/test_gem.rb45
-rw-r--r--test/rubygems/test_gem_command_manager.rb14
-rw-r--r--test/rubygems/test_gem_commands_contents_command.rb12
-rw-r--r--test/rubygems/test_gem_commands_environment_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_fetch_command.rb22
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb6
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb39
-rw-r--r--test/rubygems/test_gem_commands_server_command.rb11
-rw-r--r--test/rubygems/test_gem_commands_uninstall_command.rb9
-rw-r--r--test/rubygems/test_gem_commands_unpack_command.rb48
-rw-r--r--test/rubygems/test_gem_config_file.rb2
-rw-r--r--test/rubygems/test_gem_dependency.rb11
-rw-r--r--test/rubygems/test_gem_indexer.rb3
-rw-r--r--test/rubygems/test_gem_platform.rb19
-rw-r--r--test/rubygems/test_gem_server.rb11
-rw-r--r--test/rubygems/test_gem_source_index.rb2
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb42
-rw-r--r--test/rubygems/test_gem_specification.rb51
24 files changed, 338 insertions, 49 deletions
diff --git a/test/rubygems/gemutilities.rb b/test/rubygems/gemutilities.rb
index cea1dbeb2a..f1b0f75f51 100644
--- a/test/rubygems/gemutilities.rb
+++ b/test/rubygems/gemutilities.rb
@@ -8,13 +8,17 @@ else
require 'rubygems'
end
require 'fileutils'
-require 'minitest/unit'
+require 'minitest/autorun'
require 'tmpdir'
require 'uri'
require 'rubygems/package'
require 'rubygems/test_utilities'
require 'pp'
require 'yaml'
+begin
+ YAML::ENGINE.yamler = 'psych'
+rescue LoadError
+end if YAML.const_defined? :ENGINE
begin
gem 'rdoc'
@@ -66,10 +70,10 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
Gem.ensure_gem_subdirectories @gemhome
- if ruby = ENV['RUBY']
- Gem.class_eval {ruby, @ruby = @ruby, ruby}
- @orig_ruby = ruby
- end
+ @orig_ruby = if ruby = ENV['RUBY'] then
+ Gem.class_eval { ruby, @ruby = @ruby, ruby }
+ ruby
+ end
Gem.ensure_gem_subdirectories @gemhome
@@ -131,7 +135,6 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
Gem.pre_uninstall do |uninstaller|
@pre_uninstall_hook_arg = uninstaller
end
-
end
def teardown
@@ -150,9 +153,7 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
Gem.clear_paths
- if ruby = @orig_ruby
- Gem.class_eval {@ruby = ruby}
- end
+ Gem.class_eval { @ruby = ruby } if ruby = @orig_ruby
if @orig_ENV_HOME then
ENV['HOME'] = @orig_ENV_HOME
@@ -585,5 +586,3 @@ Also, a list:
end
-MiniTest::Unit.autorun
-
diff --git a/test/rubygems/plugin/exception/rubygems_plugin.rb b/test/rubygems/plugin/exception/rubygems_plugin.rb
new file mode 100644
index 0000000000..affa72f09c
--- /dev/null
+++ b/test/rubygems/plugin/exception/rubygems_plugin.rb
@@ -0,0 +1,2 @@
+TestGem::TEST_PLUGIN_EXCEPTION = :loaded
+raise Exception.new('boom') \ No newline at end of file
diff --git a/test/rubygems/plugin/load/rubygems_plugin.rb b/test/rubygems/plugin/load/rubygems_plugin.rb
new file mode 100644
index 0000000000..bf020b0f6a
--- /dev/null
+++ b/test/rubygems/plugin/load/rubygems_plugin.rb
@@ -0,0 +1 @@
+TestGem::TEST_PLUGIN_LOAD = :loaded \ No newline at end of file
diff --git a/test/rubygems/plugin/standarderror/rubygems_plugin.rb b/test/rubygems/plugin/standarderror/rubygems_plugin.rb
new file mode 100644
index 0000000000..d36849f144
--- /dev/null
+++ b/test/rubygems/plugin/standarderror/rubygems_plugin.rb
@@ -0,0 +1,2 @@
+TestGem::TEST_PLUGIN_STANDARDERROR = :loaded
+raise StandardError.new('boom') \ No newline at end of file
diff --git a/test/rubygems/rubygems/commands/crash_command.rb b/test/rubygems/rubygems/commands/crash_command.rb
new file mode 100644
index 0000000000..e77b3fcd72
--- /dev/null
+++ b/test/rubygems/rubygems/commands/crash_command.rb
@@ -0,0 +1,5 @@
+class Gem::Commands::CrashCommand < Gem::Command
+
+ raise "crash"
+
+end \ No newline at end of file
diff --git a/test/rubygems/rubygems_plugin.rb b/test/rubygems/rubygems_plugin.rb
index 269c3f10db..6c08f97c6d 100644
--- a/test/rubygems/rubygems_plugin.rb
+++ b/test/rubygems/rubygems_plugin.rb
@@ -1,5 +1,10 @@
require 'rubygems/command_manager'
+##
+# This is an example of exactly what NOT to do.
+#
+# DO NOT include code like this in your rubygems_plugin.rb
+
class Gem::Commands::InterruptCommand < Gem::Command
def initialize
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index 72074916b2..eacb11a290 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -16,6 +16,8 @@ class TestGem < RubyGemTestCase
else
%r|/[Rr]uby/[Gg]ems/[0-9.]+|
end
+
+ util_remove_interrupt_command
end
def test_self_all_load_paths
@@ -258,8 +260,8 @@ class TestGem < RubyGemTestCase
def test_self_find_files
discover_path = File.join 'lib', 'foo', 'discover.rb'
- cwd = File.expand_path('..', __FILE__)
- $LOAD_PATH.unshift(cwd.dup)
+ cwd = File.expand_path '..', __FILE__
+ $LOAD_PATH.unshift cwd.dup
foo1 = quick_gem 'foo', '1' do |s|
s.files << discover_path
@@ -290,7 +292,7 @@ class TestGem < RubyGemTestCase
assert_equal expected, Gem.find_files('foo/discover')
ensure
- assert_equal(cwd, $LOAD_PATH.shift)
+ assert_equal cwd, $LOAD_PATH.shift
end
def test_self_latest_load_paths
@@ -617,6 +619,38 @@ class TestGem < RubyGemTestCase
ENV['USERPATH'] = orig_user_path
end if '1.9' > RUBY_VERSION
+ def test_load_plugins
+ with_plugin('load') { Gem.load_plugins }
+ assert_equal :loaded, TEST_PLUGIN_LOAD
+
+ util_remove_interrupt_command
+
+ # Should attempt to cause a StandardError
+ with_plugin('standarderror') { Gem.load_plugins }
+ assert_equal :loaded, TEST_PLUGIN_STANDARDERROR
+
+ util_remove_interrupt_command
+
+ # Should attempt to cause an Exception
+ with_plugin('exception') { Gem.load_plugins }
+ assert_equal :loaded, TEST_PLUGIN_EXCEPTION
+ end
+
+ def with_plugin(path)
+ test_plugin_path = File.expand_path "../plugin/#{path}", __FILE__
+
+ # A single test plugin should get loaded once only, in order to preserve
+ # sane test semantics.
+ refute_includes $LOAD_PATH, test_plugin_path
+ $LOAD_PATH.unshift test_plugin_path
+
+ capture_io do
+ yield
+ end
+ ensure
+ $LOAD_PATH.delete test_plugin_path
+ end
+
def util_ensure_gem_dirs
Gem.ensure_gem_subdirectories @gemhome
@additional.each do |dir|
@@ -665,5 +699,10 @@ class TestGem < RubyGemTestCase
defined?(@RUBY_REVISION)
end
+ def util_remove_interrupt_command
+ Gem::Commands.send :remove_const, :InterruptCommand if
+ Gem::Commands.const_defined? :InterruptCommand
+ end
+
end
diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb
index 143ea692bc..c81cc59abf 100644
--- a/test/rubygems/test_gem_command_manager.rb
+++ b/test/rubygems/test_gem_command_manager.rb
@@ -10,6 +10,8 @@ class TestGemCommandManager < RubyGemTestCase
end
def test_run_interrupt
+ Gem.load_plugins
+
use_ui @ui do
assert_raises MockGemUi::TermError do
@command_manager.run 'interrupt'
@@ -19,6 +21,18 @@ class TestGemCommandManager < RubyGemTestCase
end
end
+ def test_run_crash_command
+ @command_manager.register_command :crash
+ use_ui @ui do
+ assert_raises MockGemUi::TermError do
+ @command_manager.run 'crash'
+ end
+ assert_equal '', ui.output
+ err = ui.error.split("\n").first
+ assert_equal "ERROR: Loading command: crash (RuntimeError)", err
+ end
+ end
+
def test_process_args_bad_arg
use_ui @ui do
assert_raises(MockGemUi::TermError) {
diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb
index e0284c8d5c..2085947afa 100644
--- a/test/rubygems/test_gem_commands_contents_command.rb
+++ b/test/rubygems/test_gem_commands_contents_command.rb
@@ -139,13 +139,15 @@ Rakefile
end
def test_handle_options
- assert_equal false, @cmd.options[:lib_only]
- assert_equal [], @cmd.options[:specdirs]
- assert_equal nil, @cmd.options[:version]
+ refute @cmd.options[:lib_only]
+ assert @cmd.options[:prefix]
+ assert_empty @cmd.options[:specdirs]
+ assert_nil @cmd.options[:version]
- @cmd.send :handle_options, %w[-l -s foo --version 0.0.2]
+ @cmd.send :handle_options, %w[-l -s foo --version 0.0.2 --no-prefix]
- assert_equal true, @cmd.options[:lib_only]
+ assert @cmd.options[:lib_only]
+ refute @cmd.options[:prefix]
assert_equal %w[foo], @cmd.options[:specdirs]
assert_equal Gem::Requirement.new('0.0.2'), @cmd.options[:version]
end
diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb
index 21bacb11af..6d694c3372 100644
--- a/test/rubygems/test_gem_commands_environment_command.rb
+++ b/test/rubygems/test_gem_commands_environment_command.rb
@@ -12,6 +12,7 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
def test_execute
orig_sources = Gem.sources.dup
Gem.sources.replace %w[http://gems.example.com]
+ Gem.configuration['gemcutter_key'] = 'blah'
@cmd.send :handle_options, %w[]
@@ -32,6 +33,7 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
assert_match %r|GEM PATHS:|, @ui.output
assert_match %r|- #{Regexp.escape @gemhome}|, @ui.output
assert_match %r|GEM CONFIGURATION:|, @ui.output
+ assert_match %r|"gemcutter_key" => "\*\*\*\*"|, @ui.output
assert_match %r|:verbose => |, @ui.output
assert_match %r|REMOTE SOURCES:|, @ui.output
assert_equal '', @ui.error
@@ -125,7 +127,7 @@ class TestGemCommandsEnvironmentCommand < RubyGemTestCase
@cmd.execute
end
- assert_equal "#{Gem::RubyGemsVersion}\n", @ui.output
+ assert_equal "#{Gem::VERSION}\n", @ui.output
assert_equal '', @ui.error
end
diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb
index 07e38b4b99..909bcf89de 100644
--- a/test/rubygems/test_gem_commands_fetch_command.rb
+++ b/test/rubygems/test_gem_commands_fetch_command.rb
@@ -27,7 +27,7 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
end
assert File.exist?(File.join(@tempdir, @a2.file_name)),
- "#{@a2.full_name} fetched"
+ "#{@a2.full_name} not fetched"
end
def test_execute_prerelease
@@ -52,5 +52,25 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
"#{@a2_pre.full_name} not fetched"
end
+ def test_execute_version
+ util_setup_fake_fetcher
+ util_setup_spec_fetcher @a1, @a2
+
+ @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
+ File.read(File.join(@gemhome, 'cache', @a1.file_name))
+
+ @cmd.options[:args] = [@a2.name]
+ @cmd.options[:version] = Gem::Requirement.new '1'
+
+ use_ui @ui do
+ Dir.chdir @tempdir do
+ @cmd.execute
+ end
+ end
+
+ assert File.exist?(File.join(@tempdir, @a1.file_name)),
+ "#{@a1.full_name} not fetched"
+ end
+
end
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
index 0a3071b719..ccdce787af 100644
--- a/test/rubygems/test_gem_commands_install_command.rb
+++ b/test/rubygems/test_gem_commands_install_command.rb
@@ -145,8 +145,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
end
# HACK no repository was checked
- assert_equal "ERROR: could not find gem no_such_gem locally or in a repository\n",
- @ui.error
+ assert_match(/ould not find a valid gem 'no_such_gem'/, @ui.error)
end
def test_execute_no_gem
@@ -170,8 +169,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
assert_equal 2, e.exit_code
end
- assert_equal "ERROR: could not find gem nonexistent locally or in a repository\n",
- @ui.error
+ assert_match(/ould not find a valid gem 'nonexistent'/, @ui.error)
end
def test_execute_prerelease
diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb
index b56b33b639..aa54e9f545 100644
--- a/test/rubygems/test_gem_commands_query_command.rb
+++ b/test/rubygems/test_gem_commands_query_command.rb
@@ -29,7 +29,34 @@ class TestGemCommandsQueryCommand < RubyGemTestCase
*** REMOTE GEMS ***
a (2)
-pl (1)
+pl (1 i386-linux)
+ EOF
+
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
+ end
+
+ def test_execute_platform
+ @a1r = @a1.dup
+
+ @a1.platform = 'x86-linux'
+ @a2.platform = 'universal-darwin'
+
+ @si = util_setup_spec_fetcher @a1, @a1r, @a2, @b2, @pl1
+
+ @cmd.handle_options %w[-r -a]
+
+ use_ui @ui do
+ @cmd.execute
+ end
+
+ expected = <<-EOF
+
+*** REMOTE GEMS ***
+
+a (2 universal-darwin, 1 ruby x86-linux)
+b (2)
+pl (1 i386-linux)
EOF
assert_equal expected, @ui.output
@@ -51,7 +78,7 @@ pl (1)
*** REMOTE GEMS ***
a (2, 1)
-pl (1)
+pl (1 i386-linux)
EOF
assert_equal expected, @ui.output
@@ -73,7 +100,7 @@ pl (1)
*** REMOTE GEMS ***
a (3.a, 2, 1)
-pl (1)
+pl (1 i386-linux)
EOF
assert_equal expected, @ui.output
@@ -311,7 +338,7 @@ a (3.a, 2, 1)
a_evil (9)
b (2)
c (1.2)
-pl (1)
+pl (1 i386-linux)
EOF
assert_equal expected, @ui.output
@@ -348,7 +375,7 @@ pl
expected = <<-EOF
a (2)
-pl (1)
+pl (1 i386-linux)
EOF
assert_equal expected, @ui.output
@@ -388,7 +415,7 @@ a (3.a, 2, 1)
a_evil (9)
b (2)
c (1.2)
-pl (1)
+pl (1 i386-linux)
EOF
assert_equal expected, @ui.output
diff --git a/test/rubygems/test_gem_commands_server_command.rb b/test/rubygems/test_gem_commands_server_command.rb
index 5b4faae06e..780e542036 100644
--- a/test/rubygems/test_gem_commands_server_command.rb
+++ b/test/rubygems/test_gem_commands_server_command.rb
@@ -13,16 +13,23 @@ class TestGemCommandsServerCommand < RubyGemTestCase
@cmd.send :handle_options, %w[-p 8808 --no-daemon]
assert_equal false, @cmd.options[:daemon]
- assert_equal @gemhome, @cmd.options[:gemdir]
+ assert_equal [], @cmd.options[:gemdir]
assert_equal 8808, @cmd.options[:port]
@cmd.send :handle_options, %w[-p 9999 -d /nonexistent --daemon]
assert_equal true, @cmd.options[:daemon]
- assert_equal File.expand_path('/nonexistent'), @cmd.options[:gemdir]
+ assert_equal [File.expand_path('/nonexistent')], @cmd.options[:gemdir]
assert_equal 9999, @cmd.options[:port]
end
+ def test_handle_options_gemdir
+ @cmd.send :handle_options, %w[--dir a --dir b]
+
+ assert_equal [File.expand_path('a'), File.expand_path('b')],
+ @cmd.options[:gemdir]
+ end
+
def test_handle_options_port
@cmd.send :handle_options, %w[-p 0]
assert_equal 0, @cmd.options[:port]
diff --git a/test/rubygems/test_gem_commands_uninstall_command.rb b/test/rubygems/test_gem_commands_uninstall_command.rb
index c9feb31ccb..6113ed61b2 100644
--- a/test/rubygems/test_gem_commands_uninstall_command.rb
+++ b/test/rubygems/test_gem_commands_uninstall_command.rb
@@ -64,11 +64,10 @@ class TestGemCommandsUninstallCommand < GemInstallerTestCase
util_setup_gem
- use_ui @ui do
- tmp_rake = ENV['rake']
- ENV['rake'] = @@rake
- @installer.install
- ENV['rake'] = tmp_rake
+ build_rake_in do
+ use_ui @ui do
+ @installer.install
+ end
end
@cmd.options[:args] = ["pre"]
diff --git a/test/rubygems/test_gem_commands_unpack_command.rb b/test/rubygems/test_gem_commands_unpack_command.rb
index 821ff576ba..f81a84e3ac 100644
--- a/test/rubygems/test_gem_commands_unpack_command.rb
+++ b/test/rubygems/test_gem_commands_unpack_command.rb
@@ -22,8 +22,8 @@ class TestGemCommandsUnpackCommand < RubyGemTestCase
end
end
- assert File.exist?(File.join(@tempdir, 'a-3.a')), 'a should be installed'
- assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be installed'
+ assert File.exist?(File.join(@tempdir, 'a-3.a')), 'a should be unpacked'
+ assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked'
end
def test_execute_gem_path
@@ -49,6 +49,7 @@ class TestGemCommandsUnpackCommand < RubyGemTestCase
def test_execute_gem_path_missing
util_make_gems
+ util_setup_spec_fetcher
Gem.clear_paths
@@ -68,6 +69,49 @@ class TestGemCommandsUnpackCommand < RubyGemTestCase
assert_equal '', @ui.output
end
+ def test_execute_remote
+ util_setup_fake_fetcher
+ util_setup_spec_fetcher @a1, @a2
+ util_clear_gems
+
+ a2_data = nil
+ open File.join(@gemhome, 'cache', @a2.file_name), 'rb' do |fp|
+ a2_data = fp.read
+ end
+
+ Gem::RemoteFetcher.fetcher.data['http://gems.example.com/gems/a-2.gem'] =
+ a2_data
+
+ Gem.configuration.verbose = :really
+ @cmd.options[:args] = %w[a]
+
+ use_ui @ui do
+ Dir.chdir @tempdir do
+ @cmd.execute
+ end
+ end
+
+ assert File.exist?(File.join(@tempdir, 'a-2')), 'a should be unpacked'
+ end
+
+ def test_execute_sudo
+ util_make_gems
+
+ File.chmod 0555, @gemhome
+
+ @cmd.options[:args] = %w[b]
+
+ use_ui @ui do
+ Dir.chdir @tempdir do
+ @cmd.execute
+ end
+ end
+
+ assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked'
+ ensure
+ File.chmod 0755, @gemhome
+ end
+
def test_execute_with_target_option
util_make_gems
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
index 4cd0790b92..b76ff7b180 100644
--- a/test/rubygems/test_gem_config_file.rb
+++ b/test/rubygems/test_gem_config_file.rb
@@ -46,6 +46,7 @@ class TestGemConfigFile < RubyGemTestCase
fp.puts ":benchmark: true"
fp.puts ":bulk_threshold: 10"
fp.puts ":verbose: false"
+ fp.puts ":rubygems_api_key: 701229f217cdf23b1344c7b4b54ca97"
fp.puts ":sources:"
fp.puts " - http://more-gems.example.com"
fp.puts "install: --wrappers"
@@ -61,6 +62,7 @@ class TestGemConfigFile < RubyGemTestCase
assert_equal 10, @cfg.bulk_threshold
assert_equal false, @cfg.verbose
assert_equal false, @cfg.update_sources
+ assert_equal "701229f217cdf23b1344c7b4b54ca97", @cfg.rubygems_api_key
assert_equal %w[http://more-gems.example.com], Gem.sources
assert_equal '--wrappers', @cfg[:install]
assert_equal(['/usr/ruby/1.8/lib/ruby/gems/1.8', '/var/ruby/1.8/gem_home'],
diff --git a/test/rubygems/test_gem_dependency.rb b/test/rubygems/test_gem_dependency.rb
index 1f361229a4..fb88735a03 100644
--- a/test/rubygems/test_gem_dependency.rb
+++ b/test/rubygems/test_gem_dependency.rb
@@ -134,5 +134,16 @@ class TestGemDependency < RubyGemTestCase
assert d.prerelease?
end
+ def test_version_requirements_equals_deprecated
+ d = dep "pkg", "1.0"
+
+ out, err = capture_io do
+ d.version_requirements = '2.0'
+ assert_equal Gem::Requirement.new(%w[2.0]), d.requirement
+ end
+
+ assert_match %r%deprecated%, err
+ end
+
end
diff --git a/test/rubygems/test_gem_indexer.rb b/test/rubygems/test_gem_indexer.rb
index 7bc4862d7b..9474f3fd36 100644
--- a/test/rubygems/test_gem_indexer.rb
+++ b/test/rubygems/test_gem_indexer.rb
@@ -1,5 +1,4 @@
require_relative 'gemutilities'
-
require 'rubygems/indexer'
unless ''.respond_to? :to_xs then
@@ -166,7 +165,7 @@ pl-1-i386-linux
<title>ExampleForge gems</title>
<link>http://example.com</link>
<description>Recently released gems from http://example.com</description>
- <generator>RubyGems v#{Gem::RubyGemsVersion}</generator>
+ <generator>RubyGems v#{Gem::VERSION}</generator>
<docs>http://cyber.law.harvard.edu/rss/rss.html</docs>
<item>
<title>a-2</title>
diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb
index 60ceb3141b..686493511f 100644
--- a/test/rubygems/test_gem_platform.rb
+++ b/test/rubygems/test_gem_platform.rb
@@ -30,6 +30,9 @@ class TestGemPlatform < RubyGemTestCase
'hppa2.0w-hpux11.31' => ['hppa2.0w', 'hpux', '11'],
'java' => [nil, 'java', nil],
'jruby' => [nil, 'java', nil],
+ 'universal-dotnet' => ['universal', 'dotnet', nil],
+ 'universal-dotnet2.0' => ['universal', 'dotnet', '2.0'],
+ 'universal-dotnet4.0' => ['universal', 'dotnet', '4.0'],
'powerpc-aix5.3.0.0' => ['powerpc', 'aix', '5'],
'powerpc-darwin7' => ['powerpc', 'darwin', '7'],
'powerpc-darwin8' => ['powerpc', 'darwin', '8'],
@@ -227,6 +230,22 @@ class TestGemPlatform < RubyGemTestCase
util_set_arch 'java'
assert_match 'java', Gem::Platform.local
assert_match 'jruby', Gem::Platform.local
+
+ util_set_arch 'universal-dotnet2.0'
+ assert_match 'universal-dotnet', Gem::Platform.local
+ assert_match 'universal-dotnet-2.0', Gem::Platform.local
+ refute_match 'universal-dotnet-4.0', Gem::Platform.local
+ assert_match 'dotnet', Gem::Platform.local
+ assert_match 'dotnet-2.0', Gem::Platform.local
+ refute_match 'dotnet-4.0', Gem::Platform.local
+
+ util_set_arch 'universal-dotnet4.0'
+ assert_match 'universal-dotnet', Gem::Platform.local
+ refute_match 'universal-dotnet-2.0', Gem::Platform.local
+ assert_match 'universal-dotnet-4.0', Gem::Platform.local
+ assert_match 'dotnet', Gem::Platform.local
+ refute_match 'dotnet-2.0', Gem::Platform.local
+ assert_match 'dotnet-4.0', Gem::Platform.local
util_set_arch 'powerpc-darwin'
assert_match 'powerpc-darwin', Gem::Platform.local
diff --git a/test/rubygems/test_gem_server.rb b/test/rubygems/test_gem_server.rb
index 41c25fe7d9..8f8a9cae05 100644
--- a/test/rubygems/test_gem_server.rb
+++ b/test/rubygems/test_gem_server.rb
@@ -20,6 +20,17 @@ class TestGemServer < RubyGemTestCase
@res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
end
+ def test_spec_dirs
+ s = Gem::Server.new Gem.dir, process_based_port, false
+
+ assert_equal [File.join(Gem.dir, 'specifications')], s.spec_dirs
+
+ s = Gem::Server.new [Gem.dir, Gem.dir], process_based_port, false
+
+ assert_equal [File.join(Gem.dir, 'specifications'),
+ File.join(Gem.dir, 'specifications')], s.spec_dirs
+ end
+
def test_Marshal
data = StringIO.new "GET /Marshal.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
@req.parse data
diff --git a/test/rubygems/test_gem_source_index.rb b/test/rubygems/test_gem_source_index.rb
index acace09da9..40dfeb95c1 100644
--- a/test/rubygems/test_gem_source_index.rb
+++ b/test/rubygems/test_gem_source_index.rb
@@ -85,7 +85,7 @@ Gem::Specification.new do |s|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
else
end
else
diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb
index 6864fd3beb..95b74d9bfe 100644
--- a/test/rubygems/test_gem_spec_fetcher.rb
+++ b/test/rubygems/test_gem_spec_fetcher.rb
@@ -115,6 +115,21 @@ class TestGemSpecFetcher < RubyGemTestCase
assert_equal [[@pl1.full_name, @gem_repo]], spec_names
end
+ def test_fetch_with_errors_mismatched_platform
+ util_set_arch 'hrpa-989'
+
+ @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] =
+ util_zip(Marshal.dump(@pl1))
+
+ dep = Gem::Dependency.new 'pl', 1
+ specs_and_sources, errors = @sf.fetch_with_errors dep
+
+ assert_equal 0, specs_and_sources.size
+ assert_equal 1, errors.size
+
+ assert_equal "i386-linux", errors[0].platforms.first
+ end
+
def test_fetch_spec
spec_uri = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}"
@fetcher.data["#{spec_uri}.rz"] = util_zip(Marshal.dump(@a1))
@@ -220,6 +235,33 @@ class TestGemSpecFetcher < RubyGemTestCase
assert_equal [], specs
end
+ def test_find_matching_with_errors_matched_platform
+ util_set_arch 'i386-linux'
+
+ dep = Gem::Dependency.new 'pl', 1
+ specs, errors = @sf.find_matching_with_errors dep
+
+ expected = [
+ [['pl', Gem::Version.new(1), 'i386-linux'], @gem_repo],
+ ]
+
+ assert_equal expected, specs
+ assert_equal 0, errors.size
+ end
+
+ def test_find_matching_with_errors_invalid_platform
+ util_set_arch 'hrpa-899'
+
+ dep = Gem::Dependency.new 'pl', 1
+ specs, errors = @sf.find_matching_with_errors dep
+
+ assert_equal 0, specs.size
+
+ assert_equal 1, errors.size
+
+ assert_equal "i386-linux", errors[0].platforms.first
+ end
+
def test_find_all_platforms
util_set_arch 'i386-freebsd6'
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 5979890aeb..97e2615fe2 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -473,6 +473,31 @@ end
assert_equal expected, @a1.files.sort
end
+ def test_files_append
+ @a1.files = %w(files bin/common)
+ @a1.test_files = %w(test_files bin/common)
+ @a1.executables = %w(executables common)
+ @a1.extra_rdoc_files = %w(extra_rdoc_files bin/common)
+ @a1.extensions = %w(extensions bin/common)
+
+ expected = %w[
+ bin/common
+ bin/executables
+ extensions
+ extra_rdoc_files
+ files
+ test_files
+ ]
+ assert_equal expected, @a1.files.sort
+
+ @a1.files << "generated_file.c"
+
+ expected << "generated_file.c"
+ expected.sort!
+
+ assert_equal expected, @a1.files.sort
+ end
+
def test_files_duplicate
@a2.files = %w[a b c d b]
@a2.extra_rdoc_files = %w[x y z x]
@@ -748,14 +773,14 @@ Gem::Specification.new do |s|
s.files = [\"lib/code.rb\"]
s.homepage = %q{http://example.com}
s.require_paths = [\"lib\"]
- s.rubygems_version = %q{#{Gem::RubyGemsVersion}}
+ s.rubygems_version = %q{#{Gem::VERSION}}
s.summary = %q{this is a summary}
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION}
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<b>, [\"= 1\"])
else
s.add_dependency(%q<b>, [\"= 1\"])
@@ -802,7 +827,7 @@ Gem::Specification.new do |s|
s.require_paths = [\"lib\"]
s.requirements = [\"A working computer\"]
s.rubyforge_project = %q{example}
- s.rubygems_version = %q{#{Gem::RubyGemsVersion}}
+ s.rubygems_version = %q{#{Gem::VERSION}}
s.summary = %q{this is a summary}
s.test_files = [\"test/suite.rb\"]
@@ -810,7 +835,7 @@ Gem::Specification.new do |s|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rake>, [\"> 0.4\"])
s.add_runtime_dependency(%q<jabber4r>, [\"> 0.0.0\"])
s.add_runtime_dependency(%q<pqa>, [\"> 0.4\", \"<= 0.6\"])
@@ -883,7 +908,7 @@ end
yaml_str = @a1.to_yaml
- same_spec = YAML.load(yaml_str)
+ same_spec = YAML.load yaml_str
assert_equal Gem::Platform.new('powerpc-darwin7'), same_spec.platform
assert_equal 'powerpc-darwin7.9.0', same_spec.original_platform
@@ -1173,7 +1198,7 @@ end
@a1.validate
end
- assert_equal "expected RubyGems version #{Gem::RubyGemsVersion}, was 3",
+ assert_equal "expected RubyGems version #{Gem::VERSION}, was 3",
e.message
end
@@ -1228,6 +1253,20 @@ end
assert_equal Gem::Version.new('1'), @a1.version
end
+ def test_load_errors_contain_filename
+ specfile = Tempfile.new(self.class.name.downcase)
+ specfile.write "raise 'boom'"
+ specfile.close
+ begin
+ Gem::Specification.load(specfile.path)
+ rescue => e
+ name_rexp = Regexp.new(Regexp.escape(specfile.path))
+ assert e.backtrace.grep(name_rexp).any?
+ end
+ ensure
+ specfile.delete
+ end
+
def util_setup_validate
Dir.chdir @tempdir do
FileUtils.mkdir_p File.join('ext', 'a')