From e82802070a6b64c86a09731497ef9eafaebdee5c Mon Sep 17 00:00:00 2001 From: hsbt Date: Tue, 28 Nov 2017 22:30:28 +0000 Subject: Merge rubygems-2.7.3. http://blog.rubygems.org/2017/11/28/2.7.3-released.html git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems.rb | 6 +- lib/rubygems/commands/cleanup_command.rb | 11 ++- lib/rubygems/commands/setup_command.rb | 31 +++++--- lib/rubygems/util/licenses.rb | 37 +++++++++ test/rubygems/test_gem_command.rb | 6 ++ test/rubygems/test_gem_commands_cleanup_command.rb | 43 +++++++++++ test/rubygems/test_gem_commands_setup_command.rb | 88 ++++++++++++++++++++++ test/rubygems/test_gem_commands_signin_command.rb | 11 ++- test/rubygems/test_gem_ext_configure_builder.rb | 2 +- 9 files changed, 212 insertions(+), 23 deletions(-) diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 56290aa570..b7097f22cd 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -10,7 +10,7 @@ require 'rbconfig' require 'thread' module Gem - VERSION = "2.7.2" + VERSION = "2.7.3" end # Must be first since it unloads the prelude from 1.9.2 @@ -47,9 +47,7 @@ require 'rubygems/errors' # As of RubyGems 1.3.2, RubyGems will load plugins installed in gems or # $LOAD_PATH. Plugins must be named 'rubygems_plugin' (.rb, .so, etc) and # placed at the root of your gem's #require_path. Plugins are discovered via -# Gem::find_files and then loaded. Take care when implementing a plugin as your -# plugin file may be loaded multiple times if multiple versions of your gem -# are installed. +# Gem::find_files and then loaded. # # For an example plugin, see the {Graph gem}[https://github.com/seattlerb/graph] # which adds a `gem graph` command. diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb index db1bf3a794..79c23c840d 100644 --- a/lib/rubygems/commands/cleanup_command.rb +++ b/lib/rubygems/commands/cleanup_command.rb @@ -8,13 +8,20 @@ class Gem::Commands::CleanupCommand < Gem::Command def initialize super 'cleanup', 'Clean up old versions of installed gems', - :force => false, :install_dir => Gem.dir + :force => false, :install_dir => Gem.dir, + :check_dev => true add_option('-n', '-d', '--dryrun', 'Do not uninstall gems') do |value, options| options[:dryrun] = true end + add_option('-D', '--[no-]check-development', + 'Check development dependencies while uninstalling', + '(default: true)') do |value, options| + options[:check_dev] = value + end + @candidate_gems = nil @default_gems = [] @full = nil @@ -138,7 +145,7 @@ If no gems are named all gems in GEM_HOME are cleaned. end def uninstall_dep spec - return unless @full.ok_to_remove?(spec.full_name) + return unless @full.ok_to_remove?(spec.full_name, options[:check_dev]) if options[:dryrun] then say "Dry Run Mode: Would uninstall #{spec.full_name}" diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index 93a46d4350..5d1414d102 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -82,11 +82,7 @@ class Gem::Commands::SetupCommand < Gem::Command add_option '--[no-]regenerate-binstubs', 'Regenerate gem binstubs' do |value, options| - if value then - options[:regenerate_binstubs] = true - else - options.delete(:regenerate_binstubs) - end + options[:regenerate_binstubs] = value end @verbose = nil @@ -156,7 +152,7 @@ By default, this RubyGems will install gem as: say "RubyGems #{Gem::VERSION} installed" - regenerate_binstubs + regenerate_binstubs if options[:regenerate_binstubs] uninstall_old_gemcutter @@ -357,7 +353,7 @@ By default, this RubyGems will install gem as: mkdir_p Gem::Specification.default_specifications_dir # Workaround for non-git environment. - gemspec = File.read('bundler/bundler.gemspec').gsub(/`git ls-files -z`/, "''") + gemspec = File.open('bundler/bundler.gemspec', 'rb'){|f| f.read.gsub(/`git ls-files -z`/, "''") } File.open('bundler/bundler.gemspec', 'w'){|f| f.write gemspec } bundler_spec = Gem::Specification.load("bundler/bundler.gemspec") @@ -372,13 +368,24 @@ By default, this RubyGems will install gem as: bundler_spec = Gem::Specification.load(default_spec_path) - Dir.entries(bundler_spec.gems_dir). - select {|default_gem| default_gem.start_with?("bundler-") }. - each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) } + if File.directory? bundler_spec.gems_dir + Dir.entries(bundler_spec.gems_dir). + select {|default_gem| File.basename(default_gem).match(/^bundler-#{Gem::Version::VERSION_PATTERN}$/) }. + each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) } + end mkdir_p bundler_spec.bin_dir bundler_spec.executables.each {|e| cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_spec.bin_dir, e) } + if Gem.win_platform? + require 'rubygems/installer' + + installer = Gem::Installer.for_spec bundler_spec + bundler_spec.executables.each do |e| + installer.generate_windows_script e, bundler_spec.bin_dir + end + end + say "Bundler #{bundler_spec.version} installed" end @@ -442,7 +449,7 @@ By default, this RubyGems will install gem as: # for installation of bundler as default gems def template_files Dir.chdir "bundler/lib" do - (Dir[File.join('bundler', 'templates', '**', '*')] + Dir[File.join('bundler', 'templates', '**', '.*')]). + (Dir[File.join('bundler', 'templates', '**', '{*,.*}')]). select{|f| !File.directory?(f)} end end @@ -450,7 +457,7 @@ By default, this RubyGems will install gem as: # for cleanup old bundler files def template_files_in dir Dir.chdir dir do - (Dir[File.join('templates', '**', '*')] + Dir[File.join('templates', '**', '.*')]). + (Dir[File.join('templates', '**', '{*,.*}')]). select{|f| !File.directory?(f)} end end diff --git a/lib/rubygems/util/licenses.rb b/lib/rubygems/util/licenses.rb index f4a99af39e..96fed282f1 100644 --- a/lib/rubygems/util/licenses.rb +++ b/lib/rubygems/util/licenses.rb @@ -48,9 +48,13 @@ class Gem::Licenses BSD-3-Clause-Attribution BSD-3-Clause-Clear BSD-3-Clause-LBNL + BSD-3-Clause-No-Nuclear-License + BSD-3-Clause-No-Nuclear-License-2014 + BSD-3-Clause-No-Nuclear-Warranty BSD-4-Clause BSD-4-Clause-UC BSD-Protection + BSD-Source-Code BSL-1.0 Bahyph Barr @@ -126,6 +130,7 @@ class Gem::Licenses Entessa ErlPL-1.1 Eurosym + FSFAP FSFUL FSFULLR FTL @@ -137,8 +142,18 @@ class Gem::Licenses GFDL-1.3 GL2PS GPL-1.0 + GPL-1.0+ GPL-2.0 + GPL-2.0+ + GPL-2.0-with-GCC-exception + GPL-2.0-with-autoconf-exception + GPL-2.0-with-bison-exception + GPL-2.0-with-classpath-exception + GPL-2.0-with-font-exception GPL-3.0 + GPL-3.0+ + GPL-3.0-with-GCC-exception + GPL-3.0-with-autoconf-exception Giftware Glide Glulxe @@ -152,14 +167,20 @@ class Gem::Licenses ISC ImageMagick Imlib2 + Info-ZIP Intel Intel-ACPI Interbase-1.0 JSON JasPer-2.0 + LAL-1.2 + LAL-1.3 LGPL-2.0 + LGPL-2.0+ LGPL-2.1 + LGPL-2.1+ LGPL-3.0 + LGPL-3.0+ LGPLLR LPL-1.0 LPL-1.02 @@ -170,6 +191,9 @@ class Gem::Licenses LPPL-1.3c Latex2e Leptonica + LiLiQ-P-1.1 + LiLiQ-R-1.1 + LiLiQ-Rplus-1.1 Libpng MIT MIT-CMU @@ -193,6 +217,7 @@ class Gem::Licenses NBPL-1.0 NCSA NGPL + NLOD-1.0 NLPL NOSL NPL-1.0 @@ -201,11 +226,13 @@ class Gem::Licenses NRL NTP Naumen + Net-SNMP NetCDF Newsletr Nokia Noweb Nunit + OCCT-PL OCLC-2.0 ODbL-1.0 OFL-1.0 @@ -229,6 +256,7 @@ class Gem::Licenses OLDAP-2.8 OML OPL-1.0 + OSET-PL-2.1 OSL-1.0 OSL-1.1 OSL-2.0 @@ -259,6 +287,7 @@ class Gem::Licenses SISSL SISSL-1.2 SMLNJ + SMPPL SNIA SPL-1.0 SWL @@ -269,12 +298,16 @@ class Gem::Licenses Spencer-86 Spencer-94 Spencer-99 + StandardML-NJ SugarCRM-1.1.3 TCL + TCP-wrappers TMate TORQUE-1.1 TOSL UPL-1.0 + Unicode-DFS-2015 + Unicode-DFS-2016 Unicode-TOU Unlicense VOSTROM @@ -282,7 +315,9 @@ class Gem::Licenses Vim W3C W3C-19980720 + W3C-20150513 WTFPL + WXwindows Watcom-1.0 Wsuipa X11 @@ -302,8 +337,10 @@ class Gem::Licenses Zlib bzip2-1.0.5 bzip2-1.0.6 + curl diffmark dvipdfm + eCos-2.0 eGenix gSOAP-1.3b gnuplot diff --git a/test/rubygems/test_gem_command.rb b/test/rubygems/test_gem_command.rb index 913cd72aa0..4442c6108e 100644 --- a/test/rubygems/test_gem_command.rb +++ b/test/rubygems/test_gem_command.rb @@ -13,6 +13,7 @@ class TestGemCommand < Gem::TestCase @xopt = nil + @common_options = Gem::Command.common_options.dup Gem::Command.common_options.clear Gem::Command.common_options << [ ['-x', '--exe', 'Execute'], lambda do |*a| @@ -24,6 +25,11 @@ class TestGemCommand < Gem::TestCase @cmd = Gem::Command.new @cmd_name, 'summary' end + def teardown + super + Gem::Command.common_options.replace @common_options + end + def test_self_add_specific_extra_args added_args = %w[--all] @cmd.add_option '--all' do |v,o| end diff --git a/test/rubygems/test_gem_commands_cleanup_command.rb b/test/rubygems/test_gem_commands_cleanup_command.rb index 8354160dbf..c55e195975 100644 --- a/test/rubygems/test_gem_commands_cleanup_command.rb +++ b/test/rubygems/test_gem_commands_cleanup_command.rb @@ -32,6 +32,21 @@ class TestGemCommandsCleanupCommand < Gem::TestCase assert @cmd.options[:dryrun] end + def test_handle_options_check_development + @cmd.handle_options [] + assert @cmd.options[:check_dev] + + %w[-D --check-development].each do |options| + @cmd.handle_options [options] + assert @cmd.options[:check_dev] + end + + %w[--no-check-development].each do |options| + @cmd.handle_options [options] + refute @cmd.options[:check_dev] + end + end + def test_execute @cmd.options[:args] = %w[a] @@ -55,6 +70,34 @@ class TestGemCommandsCleanupCommand < Gem::TestCase refute_path_exists @b_1.gem_dir end + def test_execute_dev_dependencies + @b_1 = util_spec 'b', 1 do |s| s.add_development_dependency 'a', '1' end + @c_1 = util_spec 'c', 1 do |s| s.add_development_dependency 'a', '2' end + + install_gem @b_1 + install_gem @c_1 + + @cmd.handle_options %w[--check-development] + + @cmd.execute + + assert_path_exists @a_1.gem_dir + end + + def test_execute_without_dev_dependencies + @b_1 = util_spec 'b', 1 do |s| s.add_development_dependency 'a', '1' end + @c_1 = util_spec 'c', 1 do |s| s.add_development_dependency 'a', '2' end + + install_gem @b_1 + install_gem @c_1 + + @cmd.handle_options %w[--no-check-development] + + @cmd.execute + + refute_path_exists @a_1.gem_dir + end + def test_execute_all gemhome2 = File.join @tempdir, 'gemhome2' diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb index 22c831fa5e..433b60df16 100644 --- a/test/rubygems/test_gem_commands_setup_command.rb +++ b/test/rubygems/test_gem_commands_setup_command.rb @@ -27,6 +27,67 @@ class TestGemCommandsSetupCommand < Gem::TestCase 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 + + FileUtils.mkdir_p 'default/gems' + + gemspec = Gem::Specification.new + gemspec.name = "bundler" + gemspec.version = "1.16.0" + gemspec.bindir = "exe" + gemspec.executables = ["bundle"] + + open 'bundler/bundler.gemspec', 'w' do |io| + io.puts gemspec.to_ruby + end + + open(File.join(Gem::Specification.default_specifications_dir, "bundler-1.15.4.gemspec"), 'w') do |io| + io.puts '# bundler' + end + + FileUtils.mkdir_p File.join(Gem.default_dir, "specifications") + open(File.join(Gem.default_dir, "specifications", "bundler-audit-1.0.0.gemspec"), 'w') do |io| + io.puts '# bundler-audit' + end + + FileUtils.mkdir_p 'default/gems/bundler-1.15.4' + FileUtils.mkdir_p 'default/gems/bundler-audit-1.0.0' + end + + def gem_install name + gem = util_spec name do |s| + s.executables = [name] + s.files = %W[bin/#{name}] + end + write_file File.join @tempdir, 'bin', name do |f| + f.puts '#!/usr/bin/ruby' + end + install_gem gem + File.join @gemhome, 'bin', name + end + + def test_execute_regenerate_binstubs + gem_bin_path = gem_install 'a' + write_file gem_bin_path do |io| + io.puts 'I changed it!' + end + + @cmd.options[:document] = [] + @cmd.execute + + assert_match %r{\A#!}, File.read(gem_bin_path) + end + + def test_execute_no_regenerate_binstubs + gem_bin_path = gem_install 'a' + write_file gem_bin_path do |io| + io.puts 'I changed it!' + end + + @cmd.options[:document] = [] + @cmd.options[:regenerate_binstubs] = false + @cmd.execute + + assert_equal "I changed it!\n", File.read(gem_bin_path) end def test_pem_files_in @@ -55,6 +116,33 @@ class TestGemCommandsSetupCommand < Gem::TestCase end end + def test_install_default_bundler_gem + @cmd.extend FileUtils + + @cmd.install_default_bundler_gem + + if Gem.win_platform? + bundler_spec = Gem::Specification.load("bundler/bundler.gemspec") + default_spec_path = File.join(Gem::Specification.default_specifications_dir, "#{bundler_spec.full_name}.gemspec") + spec = Gem::Specification.load(default_spec_path) + + spec.executables.each do |e| + assert_path_exists File.join(spec.bin_dir, "#{e}.bat") + end + end + + default_dir = Gem::Specification.default_specifications_dir + + 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(Gem.default_dir, "specifications", "bundler-audit-1.0.0.gemspec") + assert_path_exists 'default/gems/bundler-audit-1.0.0' + end if Gem::USE_BUNDLER_FOR_GEMDEPS + def test_remove_old_lib_files lib = File.join @install_dir, 'lib' lib_rubygems = File.join lib, 'rubygems' diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb index b41fed86e8..56eecfc1f8 100644 --- a/test/rubygems/test_gem_commands_signin_command.rb +++ b/test/rubygems/test_gem_commands_signin_command.rb @@ -27,10 +27,11 @@ class TestGemCommandsSigninCommand < Gem::TestCase def test_execute_when_already_signed_in_with_same_host host = 'http://some-gemcutter-compatible-host.org' - sign_in_ui = util_capture(nil, host) { @cmd.execute } + + util_capture(nil, host) { @cmd.execute } old_credentials = YAML.load_file Gem.configuration.credentials_path - sign_in_ui = util_capture(nil, host) { @cmd.execute } + util_capture(nil, host) { @cmd.execute } new_credentials = YAML.load_file Gem.configuration.credentials_path assert_equal old_credentials[host], new_credentials[host] @@ -38,9 +39,11 @@ class TestGemCommandsSigninCommand < Gem::TestCase def test_execute_when_already_signed_in_with_different_host api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf04045xxxx' - sign_in_ui = util_capture(nil, nil, api_key) { @cmd.execute } + + util_capture(nil, nil, api_key) { @cmd.execute } host = 'http://some-gemcutter-compatible-host.org' - sign_in_ui = util_capture(nil, host, api_key) { @cmd.execute } + + util_capture(nil, host, api_key) { @cmd.execute } credentials = YAML.load_file Gem.configuration.credentials_path assert_equal credentials[:rubygems_api_key], api_key diff --git a/test/rubygems/test_gem_ext_configure_builder.rb b/test/rubygems/test_gem_ext_configure_builder.rb index 6fd28770d3..cf7559d56c 100644 --- a/test/rubygems/test_gem_ext_configure_builder.rb +++ b/test/rubygems/test_gem_ext_configure_builder.rb @@ -54,7 +54,7 @@ class TestGemExtConfigureBuilder < Gem::TestCase end end - shell_error_msg = %r{(\./configure: .*)|((?:Can't|cannot) open \./configure(?:: No such file or directory)?)} + shell_error_msg = %r{(\./configure: .*)|((?:[Cc]an't|cannot) open '?\./configure'?(?:: No such file or directory)?)} sh_prefix_configure = "sh ./configure --prefix=" assert_match 'configure failed', error.message -- cgit v1.2.3