ruby-changes:50126
From: hsbt <ko1@a...>
Date: Tue, 6 Feb 2018 11:58:44 +0900 (JST)
Subject: [ruby-changes:50126] hsbt:r62244 (trunk): Merge RubyGems-2.7.5 from upstream.
hsbt 2018-02-06 11:58:35 +0900 (Tue, 06 Feb 2018) New Revision: 62244 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62244 Log: Merge RubyGems-2.7.5 from upstream. Please see its details: http://blog.rubygems.org/2018/02/06/2.7.5-released.html Modified files: trunk/lib/rubygems/commands/generate_index_command.rb trunk/lib/rubygems/commands/setup_command.rb trunk/lib/rubygems/commands/unpack_command.rb trunk/lib/rubygems/config_file.rb trunk/lib/rubygems/ext/builder.rb trunk/lib/rubygems/indexer.rb trunk/lib/rubygems/installer.rb trunk/lib/rubygems/package/file_source.rb trunk/lib/rubygems/package/old.rb trunk/lib/rubygems/package.rb trunk/lib/rubygems/request_set/lockfile.rb trunk/lib/rubygems/security/trust_dir.rb trunk/lib/rubygems/security.rb trunk/lib/rubygems/source.rb trunk/lib/rubygems/stub_specification.rb trunk/lib/rubygems/test_case.rb trunk/lib/rubygems/test_utilities.rb trunk/lib/rubygems/util.rb trunk/lib/rubygems/validator.rb trunk/lib/rubygems.rb trunk/test/rubygems/test_gem.rb trunk/test/rubygems/test_gem_commands_cleanup_command.rb trunk/test/rubygems/test_gem_commands_install_command.rb trunk/test/rubygems/test_gem_commands_push_command.rb trunk/test/rubygems/test_gem_commands_setup_command.rb trunk/test/rubygems/test_gem_commands_uninstall_command.rb trunk/test/rubygems/test_gem_dependency_installer.rb trunk/test/rubygems/test_gem_doctor.rb trunk/test/rubygems/test_gem_ext_builder.rb trunk/test/rubygems/test_gem_gemcutter_utilities.rb trunk/test/rubygems/test_gem_indexer.rb trunk/test/rubygems/test_gem_install_update_options.rb trunk/test/rubygems/test_gem_installer.rb trunk/test/rubygems/test_gem_package.rb trunk/test/rubygems/test_gem_package_old.rb trunk/test/rubygems/test_gem_rdoc.rb trunk/test/rubygems/test_gem_remote_fetcher.rb trunk/test/rubygems/test_gem_request_set.rb trunk/test/rubygems/test_gem_request_set_lockfile.rb trunk/test/rubygems/test_gem_request_set_lockfile_parser.rb trunk/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb trunk/test/rubygems/test_gem_resolver_git_specification.rb trunk/test/rubygems/test_gem_server.rb trunk/test/rubygems/test_gem_source.rb trunk/test/rubygems/test_gem_source_git.rb trunk/test/rubygems/test_gem_specification.rb trunk/test/rubygems/test_gem_stub_specification.rb trunk/test/rubygems/test_gem_util.rb trunk/test/rubygems/test_gem_version.rb trunk/test/rubygems/test_require.rb Index: test/rubygems/test_gem_commands_setup_command.rb =================================================================== --- test/rubygems/test_gem_commands_setup_command.rb (revision 62243) +++ test/rubygems/test_gem_commands_setup_command.rb (revision 62244) @@ -6,6 +6,8 @@ require 'rubygems/commands/setup_command https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L6 class TestGemCommandsSetupCommand < Gem::TestCase + BUNDLER_VERS = `gem list -e bundler`[/([^() ]+)\)\Z/, 1] || "1.16.1" + def setup super @@ -16,27 +18,27 @@ class TestGemCommandsSetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L18 FileUtils.mkdir_p 'bin' FileUtils.mkdir_p 'lib/rubygems/ssl_certs/rubygems.org' - open 'bin/gem', 'w' do |io| io.puts '# gem' end - open 'lib/rubygems.rb', 'w' do |io| io.puts '# rubygems.rb' end - open 'lib/rubygems/test_case.rb', 'w' do |io| io.puts '# test_case.rb' end - open 'lib/rubygems/ssl_certs/rubygems.org/foo.pem', 'w' do |io| io.puts 'PEM' end + File.open 'bin/gem', 'w' do |io| io.puts '# gem' end + File.open 'lib/rubygems.rb', 'w' do |io| io.puts '# rubygems.rb' end + File.open 'lib/rubygems/test_case.rb', 'w' do |io| io.puts '# test_case.rb' end + File.open 'lib/rubygems/ssl_certs/rubygems.org/foo.pem', 'w' do |io| io.puts 'PEM' end FileUtils.mkdir_p 'bundler/exe' FileUtils.mkdir_p 'bundler/lib/bundler' - open 'bundler/exe/bundle', 'w' do |io| io.puts '# bundle' end - open 'bundler/lib/bundler.rb', 'w' do |io| io.puts '# bundler.rb' end - open 'bundler/lib/bundler/b.rb', 'w' do |io| io.puts '# b.rb' end + File.open 'bundler/exe/bundle', 'w' do |io| io.puts '# bundle' end + File.open 'bundler/lib/bundler.rb', 'w' do |io| io.puts '# bundler.rb' end + File.open 'bundler/lib/bundler/b.rb', 'w' do |io| io.puts '# b.rb' end FileUtils.mkdir_p 'default/gems' gemspec = Gem::Specification.new gemspec.name = "bundler" - gemspec.version = "1.16.0" + gemspec.version = BUNDLER_VERS gemspec.bindir = "exe" gemspec.executables = ["bundle"] - open 'bundler/bundler.gemspec', 'w' do |io| + File.open 'bundler/bundler.gemspec', 'w' do |io| io.puts gemspec.to_ruby end @@ -46,6 +48,11 @@ class TestGemCommandsSetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L48 end FileUtils.mkdir_p File.join(Gem.default_dir, "specifications") + + open(File.join(Gem.default_dir, "specifications", "bundler-#{BUNDLER_VERS}.gemspec"), 'w') do |io| + io.puts "# bundler-#{BUNDLER_VERS}" + end + open(File.join(Gem.default_dir, "specifications", "bundler-audit-1.0.0.gemspec"), 'w') do |io| io.puts '# bundler-audit' end @@ -134,13 +141,25 @@ class TestGemCommandsSetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L141 default_dir = Gem::Specification.default_specifications_dir + # expect to remove other versions of bundler gemspecs on default specification directory. refute_path_exists File.join(default_dir, "bundler-1.15.4.gemspec") - refute_path_exists 'default/gems/bundler-1.15.4' - - assert_path_exists File.join(default_dir, "bundler-1.16.0.gemspec") - assert_path_exists 'default/gems/bundler-1.16.0' + assert_path_exists File.join(default_dir, "bundler-#{BUNDLER_VERS}.gemspec") + # expect to not remove bundler-* gemspecs. assert_path_exists File.join(Gem.default_dir, "specifications", "bundler-audit-1.0.0.gemspec") + + # expect to remove normal gem that was same version. because it's promoted default gems. + refute_path_exists File.join(Gem.default_dir, "specifications", "bundler-#{BUNDLER_VERS}.gemspec") + + # expect to install default gems. It location was `site_ruby` directory on real world. + assert_path_exists "default/gems/bundler-#{BUNDLER_VERS}" + + # expect to not remove other versions of bundler on `site_ruby` + assert_path_exists 'default/gems/bundler-1.15.4' + + # TODO: We need to assert to remove same version of bundler on gem_dir directory(It's not site_ruby dir) + + # expect to not remove bundler-* direcotyr. assert_path_exists 'default/gems/bundler-audit-1.0.0' end if Gem::USE_BUNDLER_FOR_GEMDEPS @@ -162,14 +181,14 @@ class TestGemCommandsSetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L181 FileUtils.mkdir_p lib_rubygems_defaults FileUtils.mkdir_p lib_bundler - open securerandom_rb, 'w' do |io| io.puts '# securerandom.rb' end + File.open securerandom_rb, 'w' do |io| io.puts '# securerandom.rb' end - open old_builder_rb, 'w' do |io| io.puts '# builder.rb' end - open old_format_rb, 'w' do |io| io.puts '# format.rb' end - open old_bundler_c_rb, 'w' do |io| io.puts '# c.rb' end + File.open old_builder_rb, 'w' do |io| io.puts '# builder.rb' end + File.open old_format_rb, 'w' do |io| io.puts '# format.rb' end + File.open old_bundler_c_rb, 'w' do |io| io.puts '# c.rb' end - open engine_defaults_rb, 'w' do |io| io.puts '# jruby.rb' end - open os_defaults_rb, 'w' do |io| io.puts '# operating_system.rb' end + File.open engine_defaults_rb, 'w' do |io| io.puts '# jruby.rb' end + File.open os_defaults_rb, 'w' do |io| io.puts '# operating_system.rb' end @cmd.remove_old_lib_files lib @@ -191,7 +210,7 @@ class TestGemCommandsSetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L210 @cmd.options[:previous_version] = Gem::Version.new '2.0.2' - open 'History.txt', 'w' do |io| + File.open 'History.txt', 'w' do |io| io.puts <<-History_txt # coding: UTF-8 Index: test/rubygems/test_gem_rdoc.rb =================================================================== --- test/rubygems/test_gem_rdoc.rb (revision 62243) +++ test/rubygems/test_gem_rdoc.rb (revision 62244) @@ -223,7 +223,7 @@ class TestGemRDoc < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_rdoc.rb#L223 def test_remove_unwritable skip 'chmod not supported' if Gem.win_platform? - skip 'skipped in root privilege' if Process.uid == 0 + skip 'skipped in root privilege' if Process.uid.zero? FileUtils.mkdir_p @a.base_dir FileUtils.chmod 0, @a.base_dir @@ -252,7 +252,7 @@ class TestGemRDoc < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_rdoc.rb#L252 def test_setup_unwritable skip 'chmod not supported' if Gem.win_platform? - skip 'skipped in root privilege' if Process.uid == 0 + skip 'skipped in root privilege' if Process.uid.zero? FileUtils.mkdir_p @a.doc_dir FileUtils.chmod 0, @a.doc_dir Index: test/rubygems/test_gem_source.rb =================================================================== --- test/rubygems/test_gem_source.rb (revision 62243) +++ test/rubygems/test_gem_source.rb (revision 62244) @@ -110,7 +110,7 @@ class TestGemSource < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_source.rb#L110 cache_file = File.join cache_dir, a1.spec_name - open cache_file, 'wb' do |io| + File.open cache_file, 'wb' do |io| Marshal.dump a1, io end @@ -163,7 +163,7 @@ class TestGemSource < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_source.rb#L163 cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}" - open cache_file, 'wb' do |io| + File.open cache_file, 'wb' do |io| Marshal.dump latest_specs, io end @@ -187,7 +187,7 @@ class TestGemSource < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_source.rb#L187 cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}" - open cache_file, 'wb' do |io| + File.open cache_file, 'wb' do |io| # Setup invalid data in the cache: io.write Marshal.dump(latest_specs)[0, 10] end Index: lib/rubygems/package/old.rb =================================================================== --- lib/rubygems/package/old.rb (revision 62243) +++ lib/rubygems/package/old.rb (revision 62244) @@ -80,7 +80,7 @@ class Gem::Package::Old < Gem::Package https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package/old.rb#L80 FileUtils.mkdir_p File.dirname destination - open destination, 'wb', entry['mode'] do |out| + File.open destination, 'wb', entry['mode'] do |out| out.write file_data end Index: lib/rubygems/indexer.rb =================================================================== --- lib/rubygems/indexer.rb (revision 62243) +++ lib/rubygems/indexer.rb (revision 62244) @@ -2,6 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/indexer.rb#L2 require 'rubygems' require 'rubygems/package' require 'time' +require 'tmpdir' begin gem 'builder' @@ -64,7 +65,7 @@ class Gem::Indexer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/indexer.rb#L65 @build_modern = options[:build_modern] @dest_directory = directory - @directory = File.join(Dir.tmpdir, "gem_generate_index_#{$$}") + @directory = Dir.mktmpdir 'gem_generate_index' marshal_name = "Marshal.#{Gem.marshal_version}" @@ -123,7 +124,7 @@ class Gem::Indexer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/indexer.rb#L124 marshal_name = File.join @quick_marshal_dir, spec_file_name marshal_zipped = Gem.deflate Marshal.dump(spec) - open marshal_name, 'wb' do |io| io.write marshal_zipped end + File.open marshal_name, 'wb' do |io| io.write marshal_zipped end files << marshal_name @@ -261,7 +262,7 @@ class Gem::Indexer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/indexer.rb#L262 zipped = Gem.deflate data - open "#{filename}.#{extension}", 'wb' do |io| + File.open "#{filename}.#{extension}", 'wb' do |io| io.write zipped end end @@ -427,7 +428,7 @@ class Gem::Indexer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/indexer.rb#L428 specs_index = compact_specs specs_index.uniq.sort - open dest, 'wb' do |io| + File.open dest, 'wb' do |io| Marshal.dump specs_index, io end end Index: lib/rubygems/package.rb =================================================================== --- lib/rubygems/package.rb (revision 62243) +++ lib/rubygems/package.rb (revision 62244) @@ -219,7 +219,7 @@ class Gem::Package https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package.rb#L219 next unless stat.file? tar.add_file_simple file, stat.mode, stat.size do |dst_io| - open file, 'rb' do |src_io| + File.open file, 'rb' do |src_io| dst_io.write src_io.read 16384 until src_io.eof? end end @@ -380,7 +380,7 @@ EOM https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package.rb#L380 FileUtils.mkdir_p mkdir, mkdir_options - open destination, 'wb' do |out| + File.open destination, 'wb' do |out| out.write entry.read FileUtils.chmod entry.header.mode, destination end if entry.file? Index: lib/rubygems/commands/unpack_command.rb =================================================================== --- lib/rubygems/commands/unpack_command.rb (revision 62243) +++ lib/rubygems/commands/unpack_command.rb (revision 62244) @@ -94,7 +94,7 @@ command help for an example. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/unpack_command.rb#L94 spec_file = File.basename spec.spec_file - open spec_file, 'w' do |io| + File.open spec_file, 'w' do |io| io.write metadata end else @@ -176,7 +176,7 @@ command help for an example. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/unpack_command.rb#L176 metadata = nil - open path, Gem.binary_mode do |io| + File.open path, Gem.binary_mode do |io| tar = Gem::Package::TarReader.new io tar.each_entry do |entry| case entry.full_name Index: lib/rubygems/test_utilities.rb =================================================================== --- lib/rubygems/test_utilities.rb (revision 62243) +++ lib/rubygems/test_utilities.rb (revision 62244) @@ -346,7 +346,7 @@ class Gem::TestCase::SpecFetcherSetup https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_utilities.rb#L346 end def write_spec spec # :nodoc: - open spec.spec_file, 'w' do |io| + File.open spec.spec_file, 'w' do |io| io.write spec.to_ruby_for_cache end end Index: lib/rubygems/commands/generate_index_command.rb =================================================================== --- lib/rubygems/commands/generate_index_command.rb (revision 62243) +++ lib/rubygems/commands/generate_index_command.rb (revision 62244) @@ -68,7 +68,7 @@ Marshal::MINOR_VERSION constants. It is https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/generate_index_command.rb#L68 if not File.exist?(options[:directory]) or not File.directory?(options[:directory]) then - alert_error "unknown directory name #{directory}." + alert_error "unknown directory name #{options[:directory]}." terminate_interaction 1 else indexer = Gem::Indexer.new options.delete(:directory), options Index: lib/rubygems/request_set/lockfile.rb =================================================================== --- lib/rubygems/request_set/lockfile.rb (revision 62243) +++ lib/rubygems/request_set/lockfile.rb (revision 62244) @@ -223,7 +223,7 @@ class Gem::RequestSet::Lockfile https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/lockfile.rb#L223 def write content = to_s - open "#{@gem_deps_file}.lock", 'w' do |io| + File.open "#{@gem_deps_file}.lock", 'w' do |io| io.write content end end Index: test/rubygems/test_gem_indexer.rb =================================================================== --- test/rubygems/test_gem_indexer.rb (revision 62243) +++ test/rubygems/test_gem_indexer.rb (revision 62244) @@ -39,8 +39,7 @@ class TestGemIndexer < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_indexer.rb#L39 def test_initialize assert_equal @tempdir, @indexer.dest_directory - assert_equal File.join(Dir.tmpdir, "gem_generate_index_#{$$}"), - @indexer.directory + assert_match %r{#{Dir.mktmpdir('gem_generate_index').match(/.*-/)}}, @indexer.directory indexer = Gem::Indexer.new @tempdir assert indexer.build_modern Index: test/rubygems/test_gem_specification.rb =================================================================== --- test/rubygems/test_gem_specification.rb (revision 62243) +++ test/rubygems/test_gem_specification.rb (revision 62244) @@ -922,7 +922,7 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L922 end def test_self_load_relative - open 'a-2.gemspec', 'w' do |io| + File.open 'a-2.gemspec', 'w' do |io| io.write @a2.to_ruby_for_cache end @@ -1114,7 +1114,7 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1114 end def test_self_remove_spec_removed - open @a1.spec_file, 'w' do |io| + File.open @a1.spec_file, 'w' do |io| io.write @a1.to_ruby end @@ -1366,13 +1366,13 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1366 assert_empty @ext.build_args - open @ext.build_info_file, 'w' do |io| + File.open @ext.build_info_file, 'w' do |io| io.puts end assert_empty @ext.build_args - open @ext.build_info_file, 'w' do |io| + File.open @ext.build_info_file, 'w' do |io| io.puts '--with-foo-dir=wherever' end @@ -1388,9 +1388,9 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1388 extconf_rb = File.join @ext.gem_dir, @ext.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - open extconf_rb, 'w' do |f| + File.open extconf_rb, 'w' do |f| f.write <<-'RUBY' - open 'Makefile', 'w' do |f| + File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" f.puts "default:\n\techo built" f.puts "install:\n\techo installed" @@ -1438,9 +1438,9 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1438 extconf_rb = File.join spec.gem_dir, spec.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - open extconf_rb, 'w' do |f| + File.open extconf_rb, 'w' do |f| f.write <<-'RUBY' - open 'Makefile', 'w' do |f| + File.open 'Makefile', 'w' do |f| f.puts "default:\n\techo built" f.puts "install:\n\techo installed" end @@ -1464,7 +1464,7 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1464 def test_build_extensions_extensions_dir_unwritable skip 'chmod not supported' if Gem.win_platform? - skip 'skipped in root privilege' if Process.uid == 0 + skip 'skipped in root privilege' if Process.uid.zero? ext_spec @@ -1473,9 +1473,9 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1473 extconf_rb = File.join @ext.gem_dir, @ext.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - open extconf_rb, 'w' do |f| + File.open extconf_rb, 'w' do |f| f.write <<-'RUBY' - open 'Makefile', 'w' do |f| + File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" f.puts "default:\n\techo built" f.puts "install:\n\techo installed" @@ -1490,7 +1490,7 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1490 @ext.build_extensions refute_path_exists @ext.extension_dir ensure - unless ($DEBUG or win_platform? or Process.uid == 0) then + unless ($DEBUG or win_platform? or Process.uid.zero?) then FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions') FileUtils.chmod 0755, @ext.base_dir end @@ -1506,9 +1506,9 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1506 extconf_rb = File.join @ext.gem_dir, @ext.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - open extconf_rb, 'w' do |f| + File.open extconf_rb, 'w' do |f| f.write <<-'RUBY' - open 'Makefile', 'w' do |f| + File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" f.puts "default:\n\techo built" f.puts "install:\n\techo installed" @@ -1555,9 +1555,9 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1555 extconf_rb = File.join @ext.gem_dir, @ext.extensions.first FileUtils.mkdir_p File.dirname extconf_rb - open extconf_rb, 'w' do |f| + File.open extconf_rb, 'w' do |f| f.write <<-'RUBY' - open 'Makefile', 'w' do |f| + File.open 'Makefile', 'w' do |f| f.puts "clean:\n\techo clean" f.puts "default:\n\techo built" f.puts "install:\n\techo installed" @@ -3422,9 +3422,9 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L3422 extconf_rb = File.join @ext.gem_dir, @ext.extensions.fi (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/