diff options
author | Hiroshi SHIBATA <[email protected]> | 2020-02-01 11:14:04 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2020-02-01 11:14:57 +0900 |
commit | 600a715c9bde99fe2e9a669465d78833445273e8 () | |
tree | 8244622e8cc02b40dd0dad29d30fc60a11342396 /test | |
parent | adc303131187654d8ce83f3db17eefa3d5bae26c (diff) |
Merge the current master branch of rubygems/rubygems.
Just started to develop RubyGems 3.2.0.
-rw-r--r-- | test/rubygems/test_deprecate.rb | 18 | ||||
-rw-r--r-- | test/rubygems/test_gem.rb | 79 | ||||
-rw-r--r-- | test/rubygems/test_gem_command_manager.rb | 41 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_build_command.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_pristine_command.rb | 37 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_query_command.rb | 857 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_setup_command.rb | 37 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_sources_command.rb | 40 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_update_command.rb | 54 | ||||
-rw-r--r-- | test/rubygems/test_gem_config_file.rb | 7 | ||||
-rw-r--r-- | test/rubygems/test_gem_dependency_installer.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_doctor.rb | 28 | ||||
-rw-r--r-- | test/rubygems/test_gem_gem_runner.rb | 30 | ||||
-rw-r--r-- | test/rubygems/test_gem_installer.rb | 74 | ||||
-rw-r--r-- | test/rubygems/test_gem_remote_fetcher.rb | 25 | ||||
-rw-r--r-- | test/rubygems/test_gem_request_set.rb | 52 | ||||
-rw-r--r-- | test/rubygems/test_gem_specification.rb | 13 | ||||
-rw-r--r-- | test/rubygems/test_gem_uninstaller.rb | 104 | ||||
-rw-r--r-- | test/rubygems/test_gem_version.rb | 2 |
19 files changed, 556 insertions, 946 deletions
@@ -77,4 +77,22 @@ class TestDeprecate < Gem::TestCase assert_match(/on or after 2099-03-01/, err) end end @@ -11,12 +11,6 @@ if File.exist?(File.join(Dir.tmpdir, "Gemfile")) raise "rubygems/bundler tests do not work correctly if there is #{ File.join(Dir.tmpdir, "Gemfile") }" end -# TODO: push this up to test_case.rb once battle tested - -$LOAD_PATH.map! do |path| - path.dup.tap(&Gem::UNTAINT) -end - class TestGem < Gem::TestCase PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant @@ -161,10 +155,8 @@ class TestGem < Gem::TestCase def test_self_install_permissions_with_format_executable_and_non_standard_ruby_install_name Gem::Installer.exec_format = nil - with_clean_path_to_ruby do - ruby_install_name 'ruby27' do - assert_self_install_permissions(format_executable: true) - end end ensure Gem::Installer.exec_format = nil @@ -1024,21 +1016,17 @@ class TestGem < Gem::TestCase end def test_self_ruby_escaping_spaces_in_path - with_clean_path_to_ruby do - with_bindir_and_exeext("C:/Ruby 1.8/bin", ".exe") do - ruby_install_name "ruby" do - assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby - end end end end def test_self_ruby_path_without_spaces - with_clean_path_to_ruby do - with_bindir_and_exeext("C:/Ruby18/bin", ".exe") do - ruby_install_name "ruby" do - assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby - end end end end @@ -1090,7 +1078,7 @@ class TestGem < Gem::TestCase util_restore_RUBY_VERSION end - def test_self_ruby_version_with_prerelease util_set_RUBY_VERSION '2.6.0', -1, 63539, 'ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]' assert_equal Gem::Version.new('2.6.0.preview2'), Gem.ruby_version @@ -1098,6 +1086,14 @@ class TestGem < Gem::TestCase util_restore_RUBY_VERSION end def test_self_ruby_version_with_non_mri_implementations_with_mri_prerelase_compatibility util_set_RUBY_VERSION '2.6.0', -1, 63539, 'weirdjruby 9.2.0.0 (2.6.0preview2) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]', 'weirdjruby', '9.2.0.0' @@ -1106,7 +1102,7 @@ class TestGem < Gem::TestCase util_restore_RUBY_VERSION end - def test_self_ruby_version_with_trunk util_set_RUBY_VERSION '1.9.2', -1, 23493, 'ruby 1.9.2dev (2009-05-20 trunk 23493) [x86_64-linux]' assert_equal Gem::Version.new('1.9.2.dev'), Gem.ruby_version @@ -1114,6 +1110,14 @@ class TestGem < Gem::TestCase util_restore_RUBY_VERSION end def test_self_rubygems_version assert_equal Gem::Version.new(Gem::VERSION), Gem.rubygems_version end @@ -1470,7 +1474,6 @@ class TestGem < Gem::TestCase install_gem foo2 end - Gem.searcher = nil Gem::Specification.reset gem 'foo' @@ -1904,15 +1907,19 @@ You may need to `gem install -g` to install missing gems end def ruby_install_name(name) - orig_RUBY_INSTALL_NAME = RbConfig::CONFIG['ruby_install_name'] - RbConfig::CONFIG['ruby_install_name'] = name - yield - ensure - if orig_RUBY_INSTALL_NAME - RbConfig::CONFIG['ruby_install_name'] = orig_RUBY_INSTALL_NAME - else - RbConfig::CONFIG.delete 'ruby_install_name' end end @@ -1924,16 +1931,6 @@ You may need to `gem install -g` to install missing gems end end - def with_clean_path_to_ruby - orig_ruby = Gem.ruby - - Gem.instance_variable_set :@ruby, nil - - yield - ensure - Gem.instance_variable_set :@ruby, orig_ruby - end - def with_plugin(path) test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}", PROJECT_DIR) @@ -224,26 +224,34 @@ class TestGemCommandManager < Gem::TestCase end #check defaults - @command_manager.process_args %w[query] assert_equal(//, check_options[:name]) assert_equal :local, check_options[:domain] assert_equal false, check_options[:details] #check settings check_options = nil - @command_manager.process_args %w[query --name foobar --local --details] assert_equal(/foobar/i, check_options[:name]) assert_equal :local, check_options[:domain] assert_equal true, check_options[:details] #remote domain check_options = nil - @command_manager.process_args %w[query --remote] assert_equal :remote, check_options[:domain] #both (local/remote) domains check_options = nil - @command_manager.process_args %w[query --both] assert_equal :both, check_options[:domain] end @@ -268,4 +276,29 @@ class TestGemCommandManager < Gem::TestCase assert_equal Dir.pwd, check_options[:install_dir] end end @@ -147,7 +147,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase error = @ui.error.split "\n" assert_equal "WARNING: licenses is empty, but is recommended. Use a license identifier from", error.shift assert_equal "http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.", error.shift - assert_equal "WARNING: See http://guides.rubygems.org/specification-reference/ for help", error.shift assert_equal [], error gem_file = File.join @tempdir, File.basename(@gem.cache_file) @@ -215,7 +215,6 @@ class TestGemCommandsPristineCommand < Gem::TestCase io.write "# extconf.rb\nrequire 'mkmf'; create_makefile 'a'" end - util_build_gem a install_gem a @cmd.options[:args] = %w[a] @@ -491,6 +490,42 @@ class TestGemCommandsPristineCommand < Gem::TestCase refute File.exist? gem_lib end def test_execute_bindir a = util_spec 'a' do |s| s.name = "test_gem" @@ -1,857 +0,0 @@ -# frozen_string_literal: true -require 'rubygems/test_case' -require 'rubygems/commands/query_command' - -module TestGemCommandsQueryCommandSetup - def setup - super - - @cmd = Gem::Commands::QueryCommand.new - - @specs = add_gems_to_fetcher - @stub_ui = Gem::MockGemUi.new - @stub_fetcher = Gem::FakeFetcher.new - - @stub_fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do - raise Gem::RemoteFetcher::FetchError - end - end -end - -class TestGemCommandsQueryCommandWithInstalledGems < Gem::TestCase - - include TestGemCommandsQueryCommandSetup - - def test_execute - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.handle_options %w[-r] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -a (2) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_all - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.handle_options %w[-r --all] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -a (2, 1) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_all_prerelease - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.handle_options %w[-r --all --prerelease] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -a (3.a, 2, 1) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_details - spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |s| - s.summary = 'This is a lot of text. ' * 4 - s.authors = ['Abraham Lincoln', 'Hirohito'] - s.homepage = 'http://a.example.com/' - end - - fetcher.legacy_platform - end - - @cmd.handle_options %w[-r -d] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -a (2) - Authors: Abraham Lincoln, Hirohito - Homepage: http://a.example.com/ - - This is a lot of text. This is a lot of text. This is a lot of text. - This is a lot of text. - -pl (1) - Platform: i386-linux - Author: A User - Homepage: http://example.com - - this is a summary - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_details_cleans_text - spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |s| - s.summary = 'This is a lot of text. ' * 4 - s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"] - s.homepage = "http://a.example.com/\x03" - end - - fetcher.legacy_platform - end - - @cmd.handle_options %w[-r -d] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -a (2) - Authors: Abraham Lincoln ., . Hirohito - Homepage: http://a.example.com/. - - This is a lot of text. This is a lot of text. This is a lot of text. - This is a lot of text. - -pl (1) - Platform: i386-linux - Author: A User - Homepage: http://example.com - - this is a summary - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_details_truncates_summary - spec_fetcher do |fetcher| - fetcher.spec 'a', 2 do |s| - s.summary = 'This is a lot of text. ' * 10_000 - s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"] - s.homepage = "http://a.example.com/\x03" - end - - fetcher.legacy_platform - end - - @cmd.handle_options %w[-r -d] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -a (2) - Authors: Abraham Lincoln ., . Hirohito - Homepage: http://a.example.com/. - - Truncating the summary for a-2 to 100,000 characters: -#{" This is a lot of text. This is a lot of text. This is a lot of text.\n" * 1449} This is a lot of te - -pl (1) - Platform: i386-linux - Author: A User - Homepage: http://example.com - - this is a summary - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_installed - @cmd.handle_options %w[-n a --installed] - - assert_raises Gem::MockGemUi::SystemExitException do - use_ui @stub_ui do - @cmd.execute - end - end - - assert_equal "true\n", @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_installed_inverse - @cmd.handle_options %w[-n a --no-installed] - - e = assert_raises Gem::MockGemUi::TermError do - use_ui @stub_ui do - @cmd.execute - end - end - - assert_equal "false\n", @stub_ui.output - assert_equal '', @stub_ui.error - - assert_equal 1, e.exit_code - end - - def test_execute_installed_inverse_not_installed - @cmd.handle_options %w[-n not_installed --no-installed] - - assert_raises Gem::MockGemUi::SystemExitException do - use_ui @stub_ui do - @cmd.execute - end - end - - assert_equal "true\n", @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_installed_no_name - @cmd.handle_options %w[--installed] - - e = assert_raises Gem::MockGemUi::TermError do - use_ui @stub_ui do - @cmd.execute - end - end - - assert_equal '', @stub_ui.output - assert_equal "ERROR: You must specify a gem name\n", @stub_ui.error - - assert_equal 4, e.exit_code - end - - def test_execute_installed_not_installed - @cmd.handle_options %w[-n not_installed --installed] - - e = assert_raises Gem::MockGemUi::TermError do - use_ui @stub_ui do - @cmd.execute - end - end - - assert_equal "false\n", @stub_ui.output - assert_equal '', @stub_ui.error - - assert_equal 1, e.exit_code - end - - def test_execute_installed_version - @cmd.handle_options %w[-n a --installed --version 2] - - assert_raises Gem::MockGemUi::SystemExitException do - use_ui @stub_ui do - @cmd.execute - end - end - - assert_equal "true\n", @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_installed_version_not_installed - @cmd.handle_options %w[-n c --installed --version 2] - - e = assert_raises Gem::MockGemUi::TermError do - use_ui @stub_ui do - @cmd.execute - end - end - - assert_equal "false\n", @stub_ui.output - assert_equal '', @stub_ui.error - - assert_equal 1, e.exit_code - end - - def test_execute_local - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.options[:domain] = :local - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** LOCAL GEMS *** - -a (3.a, 2, 1) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_local_notty - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.handle_options %w[] - - @stub_ui.outs.tty = false - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF -a (3.a, 2, 1) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_local_quiet - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.options[:domain] = :local - Gem.configuration.verbose = false - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF -a (3.a, 2, 1) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_no_versions - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.handle_options %w[-r --no-versions] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -a -pl - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_notty - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.handle_options %w[-r] - - @stub_ui.outs.tty = false - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF -a (2) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_prerelease - @cmd.handle_options %w[-r --prerelease] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -a (3.a) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_prerelease_local - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.handle_options %w[-l --prerelease] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** LOCAL GEMS *** - -a (3.a, 2, 1) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - end - - def test_execute_no_prerelease_local - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.handle_options %w[-l --no-prerelease] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** LOCAL GEMS *** - -a (2, 1) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - end - - def test_execute_remote - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.options[:domain] = :remote - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -a (2) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_remote_notty - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.handle_options %w[] - - @stub_ui.outs.tty = false - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF -a (3.a, 2, 1) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_remote_quiet - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.options[:domain] = :remote - Gem.configuration.verbose = false - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF -a (2) -pl (1 i386-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_make_entry - a_2_name = @specs['a-2'].original_name - - @stub_fetcher.data.delete \ - "#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{a_2_name}.gemspec.rz" - - a2 = @specs['a-2'] - entry_tuples = [ - [Gem::NameTuple.new(a2.name, a2.version, a2.platform), - Gem.sources.first], - ] - - platforms = { a2.version => [a2.platform] } - - entry = @cmd.send :make_entry, entry_tuples, platforms - - assert_equal 'a (2)', entry - end - - # Test for multiple args handling! - def test_execute_multiple_args - spec_fetcher do |fetcher| - fetcher.legacy_platform - end - - @cmd.handle_options %w[a pl] - - use_ui @stub_ui do - @cmd.execute - end - - assert_match %r%^a %, @stub_ui.output - assert_match %r%^pl %, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_show_gems - @cmd.options[:name] = // - @cmd.options[:domain] = :remote - - use_ui @stub_ui do - @cmd.send :show_gems, /a/i - end - - assert_match %r%^a %, @stub_ui.output - refute_match %r%^pl %, @stub_ui.output - assert_empty @stub_ui.error - end - - private - - def add_gems_to_fetcher - spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 2 - fetcher.spec 'a', '3.a' - end - end - -end - -class TestGemCommandsQueryCommandWithoutInstalledGems < Gem::TestCase - - include TestGemCommandsQueryCommandSetup - - def test_execute_platform - spec_fetcher do |fetcher| - fetcher.spec 'a', 1 - fetcher.spec 'a', 1 do |s| - s.platform = 'x86-linux' - end - - fetcher.spec 'a', 2 do |s| - s.platform = 'universal-darwin' - end - end - - @cmd.handle_options %w[-r -a] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -a (2 universal-darwin, 1 ruby x86-linux) - EOF - - assert_equal expected, @stub_ui.output - assert_equal '', @stub_ui.error - end - - def test_execute_show_default_gems - spec_fetcher { |fetcher| fetcher.spec 'a', 2 } - - a1 = new_default_spec 'a', 1 - install_default_specs a1 - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** LOCAL GEMS *** - -a (2, default: 1) -EOF - - assert_equal expected, @stub_ui.output - end - - def test_execute_show_default_gems_with_platform - a1 = new_default_spec 'a', 1 - a1.platform = 'java' - install_default_specs a1 - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** LOCAL GEMS *** - -a (default: 1 java) -EOF - - assert_equal expected, @stub_ui.output - end - - def test_execute_default_details - spec_fetcher do |fetcher| - fetcher.spec 'a', 2 - end - - a1 = new_default_spec 'a', 1 - install_default_specs a1 - - @cmd.handle_options %w[-l -d] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** LOCAL GEMS *** - -a (2, 1) - Author: A User - Homepage: http://example.com - Installed at (2): #{@gemhome} - (1, default): #{a1.base_dir} - - this is a summary - EOF - - assert_equal expected, @stub_ui.output - end - - def test_execute_local_details - spec_fetcher do |fetcher| - fetcher.spec 'a', 1 do |s| - s.platform = 'x86-linux' - end - - fetcher.spec 'a', 2 do |s| - s.summary = 'This is a lot of text. ' * 4 - s.authors = ['Abraham Lincoln', 'Hirohito'] - s.homepage = 'http://a.example.com/' - s.platform = 'universal-darwin' - end - - fetcher.legacy_platform - end - - @cmd.handle_options %w[-l -d] - - use_ui @stub_ui do - @cmd.execute - end - - str = @stub_ui.output - - str.gsub!(/\(\d\): [^\n]*/, "-") - str.gsub!(/at: [^\n]*/, "at: -") - - expected = <<-EOF - -*** LOCAL GEMS *** - -a (2, 1) - Platforms: - 1: x86-linux - 2: universal-darwin - Authors: Abraham Lincoln, Hirohito - Homepage: http://a.example.com/ - Installed at - - - - - This is a lot of text. This is a lot of text. This is a lot of text. - This is a lot of text. - -pl (1) - Platform: i386-linux - Author: A User - Homepage: http://example.com - Installed at: - - - this is a summary - EOF - - assert_equal expected, @stub_ui.output - end - - def test_execute_exact_remote - 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[--remote --exact coolgem] - - use_ui @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** REMOTE GEMS *** - -coolgem (4.2.1) - EOF - - assert_equal expected, @stub_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 @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** LOCAL GEMS *** - -coolgem (4.2.1) - EOF - - assert_equal expected, @stub_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 @stub_ui do - @cmd.execute - end - - expected = <<-EOF - -*** LOCAL GEMS *** - -coolgem (4.2.1) - -*** LOCAL GEMS *** - -othergem (1.2.3) - EOF - - assert_equal expected, @stub_ui.output - end - - private - - def add_gems_to_fetcher - spec_fetcher do |fetcher| - fetcher.download 'a', 1 - fetcher.download 'a', 2 - fetcher.download 'a', '3.a' - end - end - -end @@ -98,6 +98,18 @@ class TestGemCommandsSetupCommand < Gem::TestCase File.join @gemhome, 'bin', name end def test_execute_regenerate_binstubs gem_bin_path = gem_install 'a' write_file gem_bin_path do |io| @@ -123,6 +135,31 @@ class TestGemCommandsSetupCommand < Gem::TestCase assert_equal "I changed it!\n", File.read(gem_bin_path) end def test_execute_informs_about_installed_executables use_ui @ui do @cmd.execute @@ -247,7 +247,7 @@ source http://gems.example.com/ already present in the cache end def test_execute_add_http_rubygems_org - http_rubygems_org = 'http://rubygems.org' spec_fetcher do |fetcher| fetcher.spec 'a', 1 @@ -284,6 +284,44 @@ source http://gems.example.com/ already present in the cache assert_empty @ui.error end def test_execute_add_bad_uri @cmd.handle_options %w[--add beta-gems.example.com] @@ -159,6 +159,44 @@ class TestGemCommandsUpdateCommand < Gem::TestCase assert_empty out end def test_execute_system_specifically_to_latest_version spec_fetcher do |fetcher| fetcher.download 'rubygems-update', 8 do |s| @@ -359,10 +397,10 @@ class TestGemCommandsUpdateCommand < Gem::TestCase end def test_execute_user_install - spec_fetcher do |fetcher| - fetcher.download 'a', 2 - fetcher.spec 'a', 1 - end @cmd.handle_options %w[--user-install] @@ -373,7 +411,13 @@ class TestGemCommandsUpdateCommand < Gem::TestCase installer = @cmd.installer user_install = installer.instance_variable_get :@user_install - assert user_install, 'user_install must be set on the installer' end def test_fetch_remote_gems @@ -11,10 +11,6 @@ class TestGemConfigFile < Gem::TestCase @cfg_args = %W[--config-file #{@temp_conf}] - @orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE - Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE - Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE, - File.join(@tempdir, 'system-gemrc') Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear Gem::ConfigFile::PLATFORM_DEFAULTS.clear @@ -27,9 +23,6 @@ class TestGemConfigFile < Gem::TestCase def teardown Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.clear Gem::ConfigFile::PLATFORM_DEFAULTS.clear - Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE - Gem::ConfigFile.send :const_set, :SYSTEM_WIDE_CONFIG_FILE, - @orig_SYSTEM_WIDE_CONFIG_FILE ENV['GEMRC'] = @env_gemrc @@ -440,7 +440,7 @@ class TestGemDependencyInstaller < Gem::TestCase e1 = util_spec 'e', '1', nil, 'extconf.rb' do |s| s.extensions << 'extconf.rb' end - e1_gem = File.join @tempdir, 'gems', "#{e1.full_name}.gem" _, f1_gem = util_gem 'f', '1', 'e' => nil @@ -153,6 +153,34 @@ This directory does not appear to be a RubyGems repository, skipping assert true # count end def test_gem_repository_eh doctor = Gem::Doctor.new @gemhome @@ -67,4 +67,34 @@ class TestGemGemRunner < Gem::TestCase assert_equal %w[--foo], args end end @@ -744,6 +744,70 @@ gem 'other', version assert_match(/#{default_shebang}/, shebang_line) end def test_initialize spec = util_spec 'a' do |s| s.platform = Gem::Platform.new 'mswin32' @@ -940,7 +1004,13 @@ gem 'other', version end def test_install_creates_binstub_that_prefers_user_installed_gem_to_default - install_default_gems new_default_spec('default', '2') installer = util_setup_installer do |spec| spec.name = 'default' @@ -958,8 +1028,6 @@ gem 'other', version end end - exe = File.join @gemhome, 'bin', 'executable' - e = assert_raises RuntimeError do instance_eval File.read(exe) end @@ -153,20 +153,18 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy).to_s end - def test_fetch_size_bad_uri fetcher = Gem::RemoteFetcher.new nil @fetcher = fetcher e = assert_raises ArgumentError do - Gem::Deprecate.skip_during do - fetcher.fetch_size 'gems.example.com/yaml' - end end assert_equal 'uri scheme is invalid: nil', e.message end - def test_fetch_size_socket_error fetcher = Gem::RemoteFetcher.new nil @fetcher = fetcher def fetcher.request(uri, request_class, last_modified = nil) @@ -175,9 +173,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== uri = 'http://gems.example.com/yaml' e = assert_raises Gem::RemoteFetcher::FetchError do - Gem::Deprecate.skip_during do - fetcher.fetch_size uri - end end assert_equal "SocketError: oops (#{uri})", e.message @@ -186,9 +182,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== def test_no_proxy use_ui @stub_ui do assert_data_from_server @fetcher.fetch_path(@server_uri) - Gem::Deprecate.skip_during do - assert_equal SERVER_DATA.size, @fetcher.fetch_size(@server_uri) - end end end @@ -917,7 +912,6 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== end def test_ssl_client_cert_auth_connection - skip 'openssl is missing' unless defined?(OpenSSL::SSL) skip 'openssl in jruby fails' if java_platform? ssl_server = self.class.start_ssl_server({ @@ -935,8 +929,6 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== end def test_do_not_allow_invalid_client_cert_auth_connection - skip 'openssl is missing' unless defined?(OpenSSL::SSL) - ssl_server = self.class.start_ssl_server({ :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT}) @@ -1083,9 +1075,6 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== DIR = File.expand_path(File.dirname(__FILE__)) def start_ssl_server(config = {}) - raise MiniTest::Skip, 'openssl not installed' unless - defined?(OpenSSL::SSL) - null_logger = NilLog.new server = WEBrick::HTTPServer.new({ :Port => 0, @@ -1109,8 +1098,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== begin server.start rescue Exception => ex - abort ex.message puts "ERROR during server thread: #{ex.message}" ensure server.shutdown end @@ -183,6 +183,58 @@ 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 @@ -2784,7 +2784,7 @@ end add_runtime_dependency 'l', '~> 1.2', '> 1.2.3' #{w}: open-ended dependency on o (>= 0) is not recommended use a bounded requirement, such as '~> x.y' -#{w}: See http://guides.rubygems.org/specification-reference/ for help EXPECTED assert_equal expected, @ui.error, 'warning' @@ -2816,7 +2816,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use: end assert_equal <<-EXPECTED, @ui.error -#{w}: See http://guides.rubygems.org/specification-reference/ for help EXPECTED end end @@ -2927,7 +2927,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use: end end - assert_match 'See http://guides.rubygems.org/specification-reference/ for help', @ui.error end def test_validate_executables @@ -3100,7 +3100,7 @@ Please report a bug if this causes problems. assert_equal '"ftp://rubygems.org" is not a valid HTTP URI', e.message - @a1.homepage = 'http://rubygems.org' assert_equal true, @a1.validate @a1.homepage = 'https://rubygems.org' @@ -3430,7 +3430,7 @@ Did you mean 'Ruby'? @a1.validate end - assert_match 'See http://guides.rubygems.org/specification-reference/ for help', @ui.error end def test_version @@ -3532,7 +3532,8 @@ Did you mean 'Ruby'? s.metadata = { "one" => "two", "home" => "three", - "homepage_uri" => "https://example.com/user/repo" } end @@ -169,6 +169,41 @@ class TestGemUninstaller < Gem::InstallerTestCase end end def test_path_ok_eh uninstaller = Gem::Uninstaller.new nil @@ -524,6 +559,35 @@ create_makefile '#{@spec.name}' assert_match %r!Successfully uninstalled q-1!, lines.last end def test_uninstall_no_permission uninstaller = Gem::Uninstaller.new @spec.name, :executables => true @@ -542,4 +606,44 @@ create_makefile '#{@spec.name}' end end end @@ -236,7 +236,7 @@ class TestGemVersion < Gem::TestCase assert_equal expected, v(version).approximate_recommendation end - # Assert that the "approximate" recommendation for +version+ satifies +version+. def assert_approximate_satisfies_itself(version) gem_version = v(version) |