merge revision(s) 62244,62246,62301,62302,62303,62422,62436,62452: [Backport #14481]

Merge RubyGems-2.7.5 from upstream.

	  Please see its details: http://blog.rubygems.org/2018/02/06/2.7.5-released.html

	test_gem_util.rb: fix broken test

	* test/rubygems/test_gem_util.rb: no guarantee that tmpdir is
	  always underneath the root directory at all.

	test_gem_commands_setup_command.rb: BUNDLER_VERS

	* test/rubygems/test_gem_commands_setup_command.rb: run bundled
	  gem command, instead of installed one.

	no need to set bundled bundler unless Gem::USE_BUNDLER_FOR_GEMDEPS


	revert r62302 and force to define the version constant


	Merge RubyGems 2.7.6 from upstream.

	  It fixed some security vulnerabilities.

	  http://blog.rubygems.org/2018/02/15/2.7.6-released.html

	fix regexp literal warning.

	test/rubygems/test_gem_server.rb: eliminate duplicated character class warning.
	[Bug #14481]

	Remove unnecessary `[]`s

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2018-03-19 08:27:04 +00:00
parent 6d6880ff40
commit 90df7a08e4
58 changed files with 633 additions and 197 deletions

View file

@ -6,6 +6,13 @@ require 'rubygems/commands/setup_command'
class TestGemCommandsSetupCommand < Gem::TestCase
bundler_gemspec = File.expand_path("../../../bundler/lib/bundler/version.rb", __FILE__)
if File.exist?(bundler_gemspec)
BUNDLER_VERS = File.read(bundler_gemspec).match(/VERSION = "(#{Gem::Version::VERSION_PATTERN})"/)[1]
else
BUNDLER_VERS = "1.16.1"
end
def setup
super
@ -16,27 +23,27 @@ class TestGemCommandsSetupCommand < Gem::TestCase
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 +53,11 @@ class TestGemCommandsSetupCommand < Gem::TestCase
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 +146,25 @@ class TestGemCommandsSetupCommand < Gem::TestCase
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 +186,14 @@ class TestGemCommandsSetupCommand < Gem::TestCase
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 +215,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
@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