ruby-changes:46429
From: hsbt <ko1@a...>
Date: Mon, 1 May 2017 20:40:57 +0900 (JST)
Subject: [ruby-changes:46429] hsbt:r58530 (trunk): Merge rubygems-2.6.12 from rubygems/rubygems.
hsbt 2017-05-01 20:40:46 +0900 (Mon, 01 May 2017) New Revision: 58530 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58530 Log: Merge rubygems-2.6.12 from rubygems/rubygems. * Details of changes: https://github.com/rubygems/rubygems/blob/009080040279282d7b8ddd09acab41719cb4ba00/History.txt#L3 * I kept ko1's commmit related thread issue. It's not merged 2.6 branch on rubygems. https://github.com/ruby/ruby/commit/1721dfa0ea963a85d4ac1e3415eb18ef427d4d36 * I removed test_realworld_default_gem from rubygems-2.6.12. It fails on Ruby trunk. Because it's differences of test suite and environment. https://github.com/rubygems/rubygems/pull/1899 Modified files: trunk/lib/rubygems/commands/open_command.rb trunk/lib/rubygems/commands/query_command.rb trunk/lib/rubygems/commands/sources_command.rb trunk/lib/rubygems/dependency_list.rb trunk/lib/rubygems/installer.rb trunk/lib/rubygems/platform.rb trunk/lib/rubygems/security.rb trunk/lib/rubygems/server.rb trunk/lib/rubygems/specification.rb trunk/lib/rubygems/test_case.rb trunk/lib/rubygems.rb trunk/test/rubygems/test_gem.rb trunk/test/rubygems/test_gem_commands_open_command.rb trunk/test/rubygems/test_gem_commands_query_command.rb trunk/test/rubygems/test_gem_commands_sources_command.rb trunk/test/rubygems/test_gem_installer.rb Index: test/rubygems/test_gem.rb =================================================================== --- test/rubygems/test_gem.rb (revision 58529) +++ test/rubygems/test_gem.rb (revision 58530) @@ -75,6 +75,29 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L75 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 https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L515 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 https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L541 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 Index: test/rubygems/test_gem_commands_query_command.rb =================================================================== --- test/rubygems/test_gem_commands_query_command.rb (revision 58529) +++ test/rubygems/test_gem_commands_query_command.rb (revision 58530) @@ -642,7 +642,7 @@ pl (1) https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_query_command.rb#L642 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' @@ -663,6 +663,60 @@ coolgem (4.2.1) https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_query_command.rb#L663 EOF 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 Index: test/rubygems/test_gem_installer.rb =================================================================== --- test/rubygems/test_gem_installer.rb (revision 58529) +++ test/rubygems/test_gem_installer.rb (revision 58530) @@ -62,7 +62,12 @@ if ARGV.first https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_installer.rb#L62 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' Index: test/rubygems/test_gem_commands_sources_command.rb =================================================================== --- test/rubygems/test_gem_commands_sources_command.rb (revision 58529) +++ test/rubygems/test_gem_commands_sources_command.rb (revision 58530) @@ -108,6 +108,58 @@ source #{@gem_repo} already present in t https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_sources_command.rb#L108 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' Index: test/rubygems/test_gem_commands_open_command.rb =================================================================== --- test/rubygems/test_gem_commands_open_command.rb (revision 58529) +++ test/rubygems/test_gem_commands_open_command.rb (revision 58530) @@ -24,7 +24,8 @@ class TestGemCommandsOpenCommand < Gem:: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_open_command.rb#L24 @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]) Index: lib/rubygems.rb =================================================================== --- lib/rubygems.rb (revision 58529) +++ lib/rubygems.rb (revision 58530) @@ -10,7 +10,7 @@ require 'rbconfig' https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L10 require 'thread' module Gem - VERSION = "2.6.11" + VERSION = "2.6.12" end # Must be first since it unloads the prelude from 1.9.2 @@ -234,6 +234,7 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L234 def self.finish_resolve(request_set=Gem::RequestSet.new) request_set.import Gem::Specification.unresolved_deps.values + request_set.import Gem.loaded_specs.values.map {|s| Gem::Dependency.new(s.name, s.version) } request_set.resolve_current.each do |s| s.full_spec.activate Index: lib/rubygems/server.rb =================================================================== --- lib/rubygems/server.rb (revision 58529) +++ lib/rubygems/server.rb (revision 58530) @@ -657,7 +657,7 @@ div.method-source-code pre { color: #ffd https://github.com/ruby/ruby/blob/trunk/lib/rubygems/server.rb#L657 "only_one_executable" => true, "full_name" => "rubygems-#{Gem::VERSION}", "has_deps" => false, - "homepage" => "http://docs.rubygems.org/", + "homepage" => "http://guides.rubygems.org/", "name" => 'rubygems', "ri_installed" => true, "summary" => "RubyGems itself", Index: lib/rubygems/security.rb =================================================================== --- lib/rubygems/security.rb (revision 58529) +++ lib/rubygems/security.rb (revision 58530) @@ -455,7 +455,7 @@ module Gem::Security https://github.com/ruby/ruby/blob/trunk/lib/rubygems/security.rb#L455 ## # Creates a new key pair of the specified +length+ and +algorithm+. The - # default is a 2048 bit RSA key. + # default is a 3072 bit RSA key. def self.create_key length = KEY_LENGTH, algorithm = KEY_ALGORITHM algorithm.new length Index: lib/rubygems/specification.rb =================================================================== --- lib/rubygems/specification.rb (revision 58529) +++ lib/rubygems/specification.rb (revision 58530) @@ -2102,7 +2102,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L2102 if $DEBUG super else - "#<#{self.class}:0x#{__id__.to_s(16)} #{full_name}>" + "#{super[0..-2]} #{full_name}>" end end Index: lib/rubygems/commands/sources_command.rb =================================================================== --- lib/rubygems/commands/sources_command.rb (revision 58529) +++ lib/rubygems/commands/sources_command.rb (revision 58530) @@ -44,7 +44,7 @@ class Gem::Commands::SourcesCommand < Ge https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/sources_command.rb#L44 source = Gem::Source.new source_uri begin - if Gem.sources.include? source_uri then + if Gem.sources.include? source then say "source #{source_uri} already present in the cache" else source.load_specs :released Index: lib/rubygems/commands/open_command.rb =================================================================== --- lib/rubygems/commands/open_command.rb (revision 58529) +++ lib/rubygems/commands/open_command.rb (revision 58530) @@ -72,7 +72,7 @@ class Gem::Commands::OpenCommand < Gem:: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/open_command.rb#L72 end def spec_for name - spec = Gem::Specification.find_all_by_name(name, @version).last + spec = Gem::Specification.find_all_by_name(name, @version).first return spec if spec Index: lib/rubygems/commands/query_command.rb =================================================================== --- lib/rubygems/commands/query_command.rb (revision 58529) +++ lib/rubygems/commands/query_command.rb (revision 58530) @@ -86,7 +86,7 @@ is too hard to use. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/query_command.rb#L86 name = Array(options[:name]) else args = options[:args].to_a - name = options[:exact] ? args : args.map{|arg| /#{arg}/i } + name = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i } end prerelease = options[:prerelease] Index: lib/rubygems/dependency_list.rb =================================================================== --- lib/rubygems/dependency_list.rb (revision 58529) +++ lib/rubygems/dependency_list.rb (revision 58530) @@ -104,7 +104,7 @@ class Gem::DependencyList https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_list.rb#L104 end def inspect # :nodoc: - "#<%s:0x%x %p>" % [self.class, object_id, map { |s| s.full_name }] + "%s %p>" % [super[0..-2], map { |s| s.full_name }] end ## Index: lib/rubygems/installer.rb =================================================================== --- lib/rubygems/installer.rb (revision 58529) +++ lib/rubygems/installer.rb (revision 58530) @@ -214,7 +214,7 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L214 ruby_executable = true existing = io.read.slice(%r{ - ^( + ^\s*( gem \s | load \s Gem\.bin_path\( | load \s Gem\.activate_bin_path\( @@ -701,6 +701,8 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L701 # Return the text for an application file. def app_script_text(bin_file_name) + # note that the `load` lines cannot be indented, as old RG versions match + # against the beginning of the line return <<-TEXT #{shebang bin_file_name} # @@ -723,7 +725,12 @@ if ARGV.first https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L725 end end +if Gem.respond_to?(:activate_bin_path) load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version) +else +gem #{spec.name.dump}, version +load Gem.bin_path(#{spec.name.dump}, #{bin_file_name.dump}, version) +end TEXT end Index: lib/rubygems/test_case.rb =================================================================== --- lib/rubygems/test_case.rb (revision 58529) +++ lib/rubygems/test_case.rb (revision 58530) @@ -484,7 +484,7 @@ class Gem::TestCase < MiniTest::Unit::Te https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L484 system @git, 'add', gemspec system @git, 'commit', '-a', '-m', 'a non-empty commit message', '--quiet' - head = Gem::Util.popen('git', 'rev-parse', 'master').strip + head = Gem::Util.popen(@git, 'rev-parse', 'master').strip end return name, git_spec.version, directory, head @@ -1498,6 +1498,8 @@ end https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L1498 begin gem 'rdoc' require 'rdoc' + + require 'rubygems/rdoc' rescue LoadError, Gem::LoadError end @@ -1514,3 +1516,4 @@ tmpdirs << (ENV['GEM_PATH'] = Dir.mktmpd https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L1516 pid = $$ END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid} Gem.clear_paths +Gem.loaded_specs.clear Index: lib/rubygems/platform.rb =================================================================== --- lib/rubygems/platform.rb (revision 58529) +++ lib/rubygems/platform.rb (revision 58530) @@ -112,7 +112,7 @@ class Gem::Platform https://github.com/ruby/ruby/blob/trunk/lib/rubygems/platform.rb#L112 end def inspect - "#<%s:0x%x @cpu=%p, @os=%p, @version=%p>" % [self.class, object_id, *to_a] + "%s @cpu=%p, @os=%p, @version=%p>" % [super[0..-2], *to_a] end def to_a -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/