diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-01-04 10:09:05 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-01-04 13:14:43 +0900 |
commit | 5537adf719a37a30b17d39111cc03700f353aa2d (patch) | |
tree | 7523de9950b8a0118143f4ee0029aee17d043e04 /test/rubygems | |
parent | 35c3a24c8cbcccff1108079360e2063fc354b4bd (diff) |
Track RubyGems master(3.3.0.dev) branch at 55634a8af18a52df86c4275d70fa1179118bcc20
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4021
Diffstat (limited to 'test/rubygems')
-rw-r--r-- | test/rubygems/data/null-required-rubygems-version.gemspec.rz | bin | 0 -> 421 bytes | |||
-rw-r--r-- | test/rubygems/test_config.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem_command_manager.rb | 18 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_setup_command.rb | 58 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_update_command.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem_dependency_installer.rb | 74 | ||||
-rw-r--r-- | test/rubygems/test_gem_ext_builder.rb | 12 | ||||
-rw-r--r-- | test/rubygems/test_gem_ext_cmake_builder.rb | 6 | ||||
-rw-r--r-- | test/rubygems/test_gem_ext_configure_builder.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem_remote_fetcher.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_requirement.rb | 1 | ||||
-rw-r--r-- | test/rubygems/test_gem_resolver_best_set.rb | 23 | ||||
-rw-r--r-- | test/rubygems/test_gem_specification.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem_text.rb | 6 |
14 files changed, 109 insertions, 107 deletions
diff --git a/test/rubygems/data/null-required-rubygems-version.gemspec.rz b/test/rubygems/data/null-required-rubygems-version.gemspec.rz Binary files differnew file mode 100644 index 0000000000..db3d0af084 --- /dev/null +++ b/test/rubygems/data/null-required-rubygems-version.gemspec.rz diff --git a/test/rubygems/test_config.rb b/test/rubygems/test_config.rb index 015e2b1d8a..692d8af1ab 100644 --- a/test/rubygems/test_config.rb +++ b/test/rubygems/test_config.rb @@ -12,14 +12,14 @@ class TestConfig < Gem::TestCase end def test_good_rake_path_is_escaped - path = Gem::TestCase.class_eval('@@good_rake') + path = Gem::TestCase.class_variable_get(:@@good_rake) ruby, rake = path.shellsplit assert_equal(Gem.ruby, ruby) assert_match(/\/good_rake.rb\z/, rake) end def test_bad_rake_path_is_escaped - path = Gem::TestCase.class_eval('@@bad_rake') + path = Gem::TestCase.class_variable_get(:@@bad_rake) ruby, rake = path.shellsplit assert_equal(Gem.ruby, ruby) assert_match(/\/bad_rake.rb\z/, rake) diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb index d4471b0b63..05a5d08fe7 100644 --- a/test/rubygems/test_gem_command_manager.rb +++ b/test/rubygems/test_gem_command_manager.rb @@ -50,13 +50,27 @@ class TestGemCommandManager < Gem::TestCase end def test_find_command_unknown - e = assert_raises Gem::CommandLineError do + e = assert_raises Gem::UnknownCommandError do @command_manager.find_command 'xyz' end assert_equal 'Unknown command xyz', e.message end + def test_find_command_unknown_suggestions + e = assert_raises Gem::UnknownCommandError do + @command_manager.find_command 'pish' + end + + message = 'Unknown command pish'.dup + + if RUBY_VERSION >= "2.4" && defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable) + message << "\nDid you mean? \"push\"" + end + + assert_equal message, e.message + end + def test_run_interrupt old_load_path = $:.dup $: << File.expand_path("test/rubygems", PROJECT_DIR) @@ -265,7 +279,7 @@ class TestGemCommandManager < Gem::TestCase #check defaults @command_manager.process_args %w[update] - assert_includes check_options[:document], 'rdoc' + assert_includes check_options[:document], 'ri' #check settings check_options = nil diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb index afdc5d0979..29850c9074 100644 --- a/test/rubygems/test_gem_commands_setup_command.rb +++ b/test/rubygems/test_gem_commands_setup_command.rb @@ -24,14 +24,15 @@ class TestGemCommandsSetupCommand < Gem::TestCase lib/rubygems/test_case.rb lib/rubygems/ssl_certs/rubygems.org/foo.pem bundler/exe/bundle + bundler/exe/bundler bundler/lib/bundler.rb bundler/lib/bundler/b.rb + bundler/bin/bundler/man/bundle-b.1 bundler/lib/bundler/man/bundle-b.1.ronn + bundler/lib/bundler/man/gemfile.5 bundler/lib/bundler/man/gemfile.5.ronn bundler/lib/bundler/templates/.circleci/config.yml bundler/lib/bundler/templates/.travis.yml - bundler/man/bundle-b.1 - bundler/man/gemfile.5 ] create_dummy_files(filelist) @@ -41,7 +42,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase gemspec.name = "bundler" gemspec.version = BUNDLER_VERS gemspec.bindir = "exe" - gemspec.executables = ["bundle"] + gemspec.executables = ["bundle", "bundler"] File.open 'bundler/bundler.gemspec', 'w' do |io| io.puts gemspec.to_ruby @@ -135,6 +136,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase exec_line = out.shift until exec_line == "RubyGems installed the following executables:" assert_equal "\t#{default_gem_bin_path}", out.shift assert_equal "\t#{default_bundle_bin_path}", out.shift + assert_equal "\t#{default_bundler_bin_path}", out.shift end def test_env_shebang_flag @@ -152,6 +154,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase bin_env = win_platform? ? "" : %w[/usr/bin/env /bin/env].find {|f| File.executable?(f) } + " " assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_gem_bin_path) assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_bundle_bin_path) + assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_bundler_bin_path) assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(gem_bin_path) end @@ -160,16 +163,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase @cmd.files_in('lib').sort end - def test_bundler_man1_files_in - assert_equal %w[bundle-b.1], - @cmd.bundler_man1_files_in('bundler/man').sort - end - - def test_bundler_man5_files_in - assert_equal %w[gemfile.5], - @cmd.bundler_man5_files_in('bundler/man').sort - end - def test_install_lib @cmd.extend FileUtils @@ -187,19 +180,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase end end - def test_install_man - @cmd.extend FileUtils - - Dir.mktmpdir 'man' do |dir| - @cmd.install_man dir - - assert_path_exists File.join("#{dir}/man1", 'bundle-b.1') - refute_path_exists File.join("#{dir}/man1", 'bundle-b.1.ronn') - assert_path_exists File.join("#{dir}/man5", 'gemfile.5') - refute_path_exists File.join("#{dir}/man5", 'gemfile.5.ronn') - end - end - def test_install_default_bundler_gem @cmd.extend FileUtils @@ -308,8 +288,8 @@ class TestGemCommandsSetupCommand < Gem::TestCase gemfile_5_ronn = File.join man, 'man5', 'gemfile.5.ronn' gemfile_5_txt = File.join man, 'man5', 'gemfile.5.txt' - files_that_go = [bundle_b_1_txt, bundle_b_1_ronn, gemfile_5_txt, gemfile_5_ronn] - files_that_stay = [ruby_1, bundle_b_1, gemfile_5] + files_that_go = [bundle_b_1, bundle_b_1_txt, bundle_b_1_ronn, gemfile_5, gemfile_5_txt, gemfile_5_ronn] + files_that_stay = [ruby_1] create_dummy_files(files_that_go + files_that_stay) @@ -326,22 +306,22 @@ class TestGemCommandsSetupCommand < Gem::TestCase @cmd.options[:previous_version] = Gem::Version.new '2.0.2' - File.open 'History.txt', 'w' do |io| + File.open 'CHANGELOG.md', 'w' do |io| io.puts <<-HISTORY_TXT -=== #{Gem::VERSION} / 2013-03-26 +# #{Gem::VERSION} / 2013-03-26 -* Bug fixes: +## Bug fixes: * Fixed release note display for LANG=C when installing rubygems * π is tasty -=== 2.0.2 / 2013-03-06 +# 2.0.2 / 2013-03-06 -* Bug fixes: +## Bug fixes: * Other bugs fixed -=== 2.0.1 / 2013-03-05 +# 2.0.1 / 2013-03-05 -* Bug fixes: +## Bug fixes: * Yet more bugs fixed HISTORY_TXT end @@ -351,9 +331,9 @@ class TestGemCommandsSetupCommand < Gem::TestCase end expected = <<-EXPECTED -=== #{Gem::VERSION} / 2013-03-26 +# #{Gem::VERSION} / 2013-03-26 -* Bug fixes: +## Bug fixes: * Fixed release note display for LANG=C when installing rubygems * π is tasty @@ -410,4 +390,8 @@ class TestGemCommandsSetupCommand < Gem::TestCase def default_bundle_bin_path File.join @install_dir, 'bin', 'bundle' end + + def default_bundler_bin_path + File.join @install_dir, 'bin', 'bundler' + end end unless Gem.java_platform? diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb index 749e9bee20..13cc10c298 100644 --- a/test/rubygems/test_gem_commands_update_command.rb +++ b/test/rubygems/test_gem_commands_update_command.rb @@ -552,7 +552,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase expected = { :args => [], - :document => %w[rdoc ri], + :document => %w[ri], :force => false, :system => true, } @@ -571,7 +571,7 @@ class TestGemCommandsUpdateCommand < Gem::TestCase expected = { :args => [], - :document => %w[rdoc ri], + :document => %w[ri], :force => false, :system => "1.3.7", } diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index fe8a74c750..85dba54675 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -946,6 +946,31 @@ class TestGemDependencyInstaller < Gem::TestCase assert_equal %w[d-2], inst.installed_gems.map {|s| s.full_name } end + def test_install_legacy_spec_with_nil_required_rubygems_version + path = File.expand_path "../data/null-required-rubygems-version.gemspec.rz", __FILE__ + spec = Marshal.load Gem.read_binary(path) + def spec.validate(*args); end + + util_build_gem spec + + cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem" + FileUtils.mkdir_p File.dirname cache_file + FileUtils.mv spec.cache_file, cache_file + + util_setup_spec_fetcher spec + + data = Gem.read_binary(cache_file) + + @fetcher.data['http://gems.example.com/gems/activesupport-1.0.0.gem'] = data + + dep = Gem::Dependency.new 'activesupport' + + inst = Gem::DependencyInstaller.new + inst.install dep + + assert_equal %w[activesupport-1.0.0], Gem::Specification.map(&:full_name) + end + def test_find_gems_gems_with_sources util_setup_gems @@ -1102,21 +1127,6 @@ class TestGemDependencyInstaller < Gem::TestCase assert_equal %w[a-1], requests end - def util_write_a1_bin - write_file File.join('gems', 'a-1', 'bin', 'a_bin') do |fp| - fp.puts "#!/usr/bin/ruby" - end - end - - def util_setup_c1_pre - @c1_pre, @c1_pre_gem = util_spec 'c', '1.a' do |s| - s.add_dependency 'a', '1.a' - s.add_dependency 'b', '1' - end - - util_reset_gems - end - def util_setup_d @d1, @d1_gem = util_gem 'd', '1' @d2, @d2_gem = util_gem 'd', '2' @@ -1124,43 +1134,13 @@ class TestGemDependencyInstaller < Gem::TestCase util_reset_gems end - def util_setup_wxyz - @x1_m, @x1_m_gem = util_spec 'x', '1' do |s| - s.platform = Gem::Platform.new %w[cpu my_platform 1] - end - - @x1_o, @x1_o_gem = util_spec 'x', '1' do |s| - s.platform = Gem::Platform.new %w[cpu other_platform 1] - end - - @w1, @w1_gem = util_spec 'w', '1', 'x' => nil - - @y1, @y1_gem = util_spec 'y', '1' - @y1_1_p, @y1_1_p_gem = util_spec 'y', '1.1' do |s| - s.platform = Gem::Platform.new %w[cpu my_platform 1] - end - - @z1, @z1_gem = util_spec 'z', '1', 'y' => nil - - util_reset_gems - end - def util_reset_gems @a1 ||= nil @b1 ||= nil @a1_pre ||= nil - @c1_pre ||= nil @d1 ||= nil @d2 ||= nil - @w1 ||= nil - @x1_m ||= nil - @x1_o ||= nil - @y1 ||= nil - @y1_1_p ||= nil - @z1 ||= nil - - util_setup_spec_fetcher(*[@a1, @a1_pre, @b1, @c1_pre, - @d1, @d2, @x1_m, @x1_o, @w1, @y1, - @y1_1_p, @z1].compact) + + util_setup_spec_fetcher(*[@a1, @a1_pre, @b1, @d1, @d2].compact) end end diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb index 6e6bf89f9c..0fe650b8a5 100644 --- a/test/rubygems/test_gem_ext_builder.rb +++ b/test/rubygems/test_gem_ext_builder.rb @@ -47,9 +47,9 @@ install: results = results.join("\n").b - assert_match %r{"DESTDIR=#{ENV['DESTDIR']}" clean$}, results - assert_match %r{"DESTDIR=#{ENV['DESTDIR']}"$}, results - assert_match %r{"DESTDIR=#{ENV['DESTDIR']}" install$}, results + assert_match %r{DESTDIR\\=#{ENV['DESTDIR']} clean$}, results + assert_match %r{DESTDIR\\=#{ENV['DESTDIR']}$}, results + assert_match %r{DESTDIR\\=#{ENV['DESTDIR']} install$}, results if /nmake/ !~ results assert_match %r{^clean: destination$}, results @@ -76,9 +76,9 @@ install: results = results.join("\n").b - assert_match %r{"DESTDIR=#{ENV['DESTDIR']}" clean$}, results - assert_match %r{"DESTDIR=#{ENV['DESTDIR']}"$}, results - assert_match %r{"DESTDIR=#{ENV['DESTDIR']}" install$}, results + assert_match %r{DESTDIR\\=#{ENV['DESTDIR']} clean$}, results + assert_match %r{DESTDIR\\=#{ENV['DESTDIR']}$}, results + assert_match %r{DESTDIR\\=#{ENV['DESTDIR']} install$}, results end def test_build_extensions diff --git a/test/rubygems/test_gem_ext_cmake_builder.rb b/test/rubygems/test_gem_ext_cmake_builder.rb index e347359679..dffe4a7fb3 100644 --- a/test/rubygems/test_gem_ext_cmake_builder.rb +++ b/test/rubygems/test_gem_ext_cmake_builder.rb @@ -40,8 +40,7 @@ install (FILES test.txt DESTINATION bin) output = output.join "\n" - assert_match \ - %r{^cmake \. -DCMAKE_INSTALL_PREFIX=#{Regexp.escape @dest_path}}, output + assert_match %r{^cmake \. -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}}, output assert_match %r{#{Regexp.escape @ext}}, output assert_contains_make_command '', output assert_contains_make_command 'install', output @@ -58,11 +57,10 @@ install (FILES test.txt DESTINATION bin) output = output.join "\n" shell_error_msg = %r{(CMake Error: .*)} - sh_prefix_cmake = "cmake . -DCMAKE_INSTALL_PREFIX=" assert_match 'cmake failed', error.message - assert_match %r{^#{sh_prefix_cmake}#{Regexp.escape @dest_path}}, output + assert_match %r{^cmake . -DCMAKE_INSTALL_PREFIX\\=#{Regexp.escape @dest_path}}, output assert_match %r{#{shell_error_msg}}, output end diff --git a/test/rubygems/test_gem_ext_configure_builder.rb b/test/rubygems/test_gem_ext_configure_builder.rb index a74f5ce055..6b11b0c2ab 100644 --- a/test/rubygems/test_gem_ext_configure_builder.rb +++ b/test/rubygems/test_gem_ext_configure_builder.rb @@ -28,7 +28,7 @@ class TestGemExtConfigureBuilder < Gem::TestCase Gem::Ext::ConfigureBuilder.build nil, @dest_path, output, [], nil, @ext assert_match(/^current directory:/, output.shift) - assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift + assert_equal "sh ./configure --prefix\\=#{@dest_path}", output.shift assert_equal "", output.shift assert_match(/^current directory:/, output.shift) assert_contains_make_command 'clean', output.shift @@ -50,7 +50,7 @@ class TestGemExtConfigureBuilder < Gem::TestCase end shell_error_msg = %r{(\./configure: .*)|((?:[Cc]an't|cannot) open '?\./configure'?(?:: No such file or directory)?)} - sh_prefix_configure = "sh ./configure --prefix=" + sh_prefix_configure = "sh ./configure --prefix\\=" assert_match 'configure failed', error.message diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index 371998497b..1c88e8d3e8 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -205,7 +205,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== @test_data end - raise Gem::RemoteFetcher::FetchError.new("haha!", nil) + raise Gem::RemoteFetcher::FetchError.new("haha!", '') end end diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb index 20127a1e15..670defe330 100644 --- a/test/rubygems/test_gem_requirement.rb +++ b/test/rubygems/test_gem_requirement.rb @@ -253,7 +253,6 @@ class TestGemRequirement < Gem::TestCase assert_satisfied_by "1.0.0.0", "= 1.0" assert_satisfied_by "10.3.2", "!= 9.3.4" assert_satisfied_by "10.3.2", "> 9.3.2" - assert_satisfied_by "10.3.2", "> 9.3.2" assert_satisfied_by " 9.3.2", ">= 9.3.2" assert_satisfied_by "9.3.2 ", ">= 9.3.2" assert_satisfied_by "", "= 0" diff --git a/test/rubygems/test_gem_resolver_best_set.rb b/test/rubygems/test_gem_resolver_best_set.rb index 657ad33387..019ca70499 100644 --- a/test/rubygems/test_gem_resolver_best_set.rb +++ b/test/rubygems/test_gem_resolver_best_set.rb @@ -132,4 +132,27 @@ class TestGemResolverBestSet < Gem::TestCase assert_equal error, e end + + def test_replace_failed_api_set_uri_with_credentials + set = @DR::BestSet.new + + api_uri = URI(@gem_repo) + './info/' + api_uri.user = 'user' + api_uri.password = 'pass' + api_set = Gem::Resolver::APISet.new api_uri + + set.sets << api_set + + error_uri = api_uri + 'a' + + error = Gem::RemoteFetcher::FetchError.new 'bogus', error_uri + + set.replace_failed_api_set error + + assert_equal 1, set.sets.size + + refute_includes set.sets, api_set + + assert_kind_of Gem::Resolver::IndexSet, set.sets.first + end end diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 76072184bd..374d58d38f 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -1200,10 +1200,8 @@ dependencies: [] Gem.platforms = orig_platform end - DATA_PATH = File.expand_path "../data", __FILE__ - def test_handles_private_null_type - path = File.join DATA_PATH, "null-type.gemspec.rz" + path = File.expand_path "../data/null-type.gemspec.rz", __FILE__ data = Marshal.load Gem::Util.inflate(Gem.read_binary(path)) diff --git a/test/rubygems/test_gem_text.rb b/test/rubygems/test_gem_text.rb index d8e4b75f3a..d9f024f1e6 100644 --- a/test/rubygems/test_gem_text.rb +++ b/test/rubygems/test_gem_text.rb @@ -83,6 +83,12 @@ Without the wrapping, the text might not look good in the RSS feed. assert_equal 7, levenshtein_distance("zentest", "xxxxxxx") end + def test_levenshtein_distance_all + assert_equal 6, levenshtein_distance("algorithm", "altruistic") + assert_equal 3, levenshtein_distance("saturday", "sunday") + assert_equal 3, levenshtein_distance("kitten", "sitting") + end + def test_truncate_text assert_equal "abc", truncate_text("abc", "desc") assert_equal "Truncating desc to 2 characters:\nab", truncate_text("abc", "desc", 2) |