diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-10 05:10:55 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-10 05:10:55 +0000 |
commit | fd41a38470e1ba2ee1857eae08fe909ef34b9b2d (patch) | |
tree | 825325fce85e638616f592b7ba59b5f7c858b4e1 /test/rubygems | |
parent | 1069d3f18bb3017ba770cc5ac68e4513439e357c (diff) |
lib/rubygems: bump up RubyGems version to 2.6.12. [Backport #13842]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems')
-rw-r--r-- | test/rubygems/test_gem.rb | 33 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_open_command.rb | 3 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_query_command.rb | 56 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_sources_command.rb | 52 | ||||
-rw-r--r-- | test/rubygems/test_gem_installer.rb | 5 | ||||
-rw-r--r-- | test/rubygems/test_require.rb | 11 |
6 files changed, 153 insertions, 7 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index a605f9cdfe..62b36dfd41 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -75,6 +75,29 @@ class TestGem < Gem::TestCase end end + def test_self_finish_resolve_respects_loaded_specs + save_loaded_features do + a1 = new_spec "a", "1", "b" => "> 0" + b1 = new_spec "b", "1", "c" => ">= 1" + b2 = new_spec "b", "2", "c" => ">= 2" + c1 = new_spec "c", "1" + c2 = new_spec "c", "2" + + install_specs c1, c2, b1, b2, a1 + + a1.activate + c1.activate + + assert_equal %w(a-1 c-1), loaded_spec_names + assert_equal ["b (> 0)"], unresolved_names + + Gem.finish_resolve + + assert_equal %w(a-1 b-1 c-1), loaded_spec_names + assert_equal [], unresolved_names + end + end + def test_self_install spec_fetcher do |f| f.gem 'a', 1 @@ -492,7 +515,7 @@ class TestGem < Gem::TestCase skip if RUBY_VERSION <= "1.8.7" cwd = File.expand_path("test/rubygems", @@project_dir) - $LOAD_PATH.unshift cwd + actual_load_path = $LOAD_PATH.unshift(cwd).dup discover_path = File.join 'lib', 'sff', 'discover.rb' @@ -518,12 +541,12 @@ class TestGem < Gem::TestCase expected = [ File.expand_path('test/rubygems/sff/discover.rb', @@project_dir), File.join(foo1.full_gem_path, discover_path) - ] + ].sort - assert_equal expected, Gem.find_files('sff/discover') - assert_equal expected, Gem.find_files('sff/**.rb'), '[ruby-core:31730]' + assert_equal expected, Gem.find_files('sff/discover').sort + assert_equal expected, Gem.find_files('sff/**.rb').sort, '[ruby-core:31730]' ensure - assert_equal cwd, $LOAD_PATH.shift unless RUBY_VERSION <= "1.8.7" + assert_equal cwd, actual_load_path.shift unless RUBY_VERSION <= "1.8.7" end def test_self_find_latest_files diff --git a/test/rubygems/test_gem_commands_open_command.rb b/test/rubygems/test_gem_commands_open_command.rb index 3ec38972e6..a96fa6ea23 100644 --- a/test/rubygems/test_gem_commands_open_command.rb +++ b/test/rubygems/test_gem_commands_open_command.rb @@ -24,7 +24,8 @@ class TestGemCommandsOpenCommand < Gem::TestCase @cmd.options[:args] = %w[foo] @cmd.options[:editor] = "#{Gem.ruby} -e0 --" - spec = gem 'foo' + gem 'foo', '1.0.0' + spec = gem 'foo', '1.0.1' mock = MiniTest::Mock.new mock.expect(:call, true, [spec.full_gem_path]) diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb index 223f205b2d..d8d682b136 100644 --- a/test/rubygems/test_gem_commands_query_command.rb +++ b/test/rubygems/test_gem_commands_query_command.rb @@ -642,7 +642,7 @@ pl (1) assert_equal expected, @ui.output end - def test_execute_exact + def test_execute_exact_remote spec_fetcher do |fetcher| fetcher.spec 'coolgem-omg', 3 fetcher.spec 'coolgem', '4.2.1' @@ -665,6 +665,60 @@ coolgem (4.2.1) assert_equal expected, @ui.output end + def test_execute_exact_local + spec_fetcher do |fetcher| + fetcher.spec 'coolgem-omg', 3 + fetcher.spec 'coolgem', '4.2.1' + fetcher.spec 'wow_coolgem', 1 + end + + @cmd.handle_options %w[--exact coolgem] + + use_ui @ui do + @cmd.execute + end + + expected = <<-EOF + +*** LOCAL GEMS *** + +coolgem (4.2.1) + EOF + + assert_equal expected, @ui.output + end + + def test_execute_exact_multiple + spec_fetcher do |fetcher| + fetcher.spec 'coolgem-omg', 3 + fetcher.spec 'coolgem', '4.2.1' + fetcher.spec 'wow_coolgem', 1 + + fetcher.spec 'othergem-omg', 3 + fetcher.spec 'othergem', '1.2.3' + fetcher.spec 'wow_othergem', 1 + end + + @cmd.handle_options %w[--exact coolgem othergem] + + use_ui @ui do + @cmd.execute + end + + expected = <<-EOF + +*** LOCAL GEMS *** + +coolgem (4.2.1) + +*** LOCAL GEMS *** + +othergem (1.2.3) + EOF + + assert_equal expected, @ui.output + end + private def add_gems_to_fetcher diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb index 014b4b4c12..d5b6d99419 100644 --- a/test/rubygems/test_gem_commands_sources_command.rb +++ b/test/rubygems/test_gem_commands_sources_command.rb @@ -108,6 +108,58 @@ source #{@gem_repo} already present in the cache assert_equal '', @ui.error end + def test_execute_add_redundant_source_trailing_slash + # Remove pre-existing gem source (w/ slash) + repo_with_slash = "http://gems.example.com/" + @cmd.handle_options %W[--remove #{repo_with_slash}] + use_ui @ui do + @cmd.execute + end + source = Gem::Source.new repo_with_slash + assert_equal false, Gem.sources.include?(source) + + expected = <<-EOF +#{repo_with_slash} removed from sources + EOF + + assert_equal expected, @ui.output + assert_equal '', @ui.error + + # Re-add pre-existing gem source (w/o slash) + repo_without_slash = "http://gems.example.com" + @cmd.handle_options %W[--add #{repo_without_slash}] + use_ui @ui do + @cmd.execute + end + source = Gem::Source.new repo_without_slash + assert_equal true, Gem.sources.include?(source) + + expected = <<-EOF +http://gems.example.com/ removed from sources +http://gems.example.com added to sources + EOF + + assert_equal expected, @ui.output + assert_equal '', @ui.error + + # Re-add original gem source (w/ slash) + @cmd.handle_options %W[--add #{repo_with_slash}] + use_ui @ui do + @cmd.execute + end + source = Gem::Source.new repo_with_slash + assert_equal true, Gem.sources.include?(source) + + expected = <<-EOF +http://gems.example.com/ removed from sources +http://gems.example.com added to sources +source http://gems.example.com/ already present in the cache + EOF + + assert_equal expected, @ui.output + assert_equal '', @ui.error + end + def test_execute_add_http_rubygems_org http_rubygems_org = 'http://rubygems.org' diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 6ceb2c6dfc..882981d344 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -62,7 +62,12 @@ if ARGV.first end end +if Gem.respond_to?(:activate_bin_path) load Gem.activate_bin_path('a', 'executable', version) +else +gem "a", version +load Gem.bin_path("a", "executable", version) +end EOF wrapper = @installer.app_script_text 'executable' diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb index dd606e44d4..936f78fb2a 100644 --- a/test/rubygems/test_require.rb +++ b/test/rubygems/test_require.rb @@ -301,6 +301,17 @@ class TestGemRequire < Gem::TestCase assert_equal %w(default-2.0.0.0), loaded_spec_names end + def test_realworld_default_gem + skip "no default gems on ruby < 2.0" unless RUBY_VERSION >= "2" + cmd = <<-RUBY + $stderr = $stdout + require "json" + puts Gem.loaded_specs["json"].default_gem? + RUBY + output = Gem::Util.popen(Gem.ruby, "-e", cmd).strip + assert_equal "true", output + end + def test_default_gem_and_normal_gem default_gem_spec = new_default_spec("default", "2.0.0.0", nil, "default/gem.rb") |