From 6e2240a2f954c84ed12357382c9c065ae4b91e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 28 May 2021 12:47:49 +0200 Subject: Sync latest bundler & rubygems development version --- test/rubygems/helper.rb | 8 ++++++-- .../packages/ill-formatted-platform-1.0.0.10.gem | Bin 0 -> 10240 bytes test/rubygems/test_gem_bundler_version_finder.rb | 4 +--- test/rubygems/test_gem_command.rb | 12 ++++++++++++ test/rubygems/test_gem_commands_help_command.rb | 7 +++++++ test/rubygems/test_gem_commands_push_command.rb | 5 ----- test/rubygems/test_gem_commands_setup_command.rb | 4 ++-- test/rubygems/test_gem_commands_signin_command.rb | 7 +++++++ test/rubygems/test_gem_dependency.rb | 6 ++++++ test/rubygems/test_gem_ext_builder.rb | 6 +++--- test/rubygems/test_gem_ext_ext_conf_builder.rb | 1 + test/rubygems/test_gem_ext_rake_builder.rb | 2 ++ test/rubygems/test_gem_gemcutter_utilities.rb | 6 ------ test/rubygems/test_gem_installer.rb | 20 ++++++++++++++++++++ test/rubygems/test_gem_specification.rb | 6 +++--- test/rubygems/test_kernel.rb | 2 ++ test/rubygems/test_require.rb | 2 -- 17 files changed, 72 insertions(+), 26 deletions(-) create mode 100644 test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem (limited to 'test') diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb index 6635481a9f..fbdc34e357 100644 --- a/test/rubygems/helper.rb +++ b/test/rubygems/helper.rb @@ -544,6 +544,10 @@ class Gem::TestCase < Test::Unit::TestCase Gem.pre_uninstall_hooks.clear end + def without_any_upwards_gemfiles + ENV["BUNDLE_GEMFILE"] = File.join(@tempdir, "Gemfile") + end + ## # A git_gem is used with a gem dependencies file. The gem created here # has no files, just a gem specification for the given +name+ and +version+. @@ -1291,7 +1295,7 @@ Also, a list: end def ruby_with_rubygems_in_load_path - [Gem.ruby, "-I", File.expand_path("../../lib", __dir__)] + [Gem.ruby, "-I", $LOAD_PATH.find{|p| p == File.dirname($LOADED_FEATURES.find{|f| f.end_with?("/rubygems.rb") }) }] end def with_clean_path_to_ruby @@ -1591,7 +1595,7 @@ class Object metaclass.send :undef_method, name metaclass.send :alias_method, name, new_name metaclass.send :undef_method, new_name - end unless method_defined?(:stub) # lib/resolv/test_dns.rb also has the same method definition + end end require_relative 'utilities' diff --git a/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem b/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem new file mode 100644 index 0000000000..58a13535c2 Binary files /dev/null and b/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem differ diff --git a/test/rubygems/test_gem_bundler_version_finder.rb b/test/rubygems/test_gem_bundler_version_finder.rb index 4ba3b9accf..e971e6ae29 100644 --- a/test/rubygems/test_gem_bundler_version_finder.rb +++ b/test/rubygems/test_gem_bundler_version_finder.rb @@ -6,14 +6,12 @@ class TestGemBundlerVersionFinder < Gem::TestCase super @argv = ARGV.dup - @env = ENV.to_hash.clone - ENV.delete("BUNDLER_VERSION") @dollar_0 = $0 + without_any_upwards_gemfiles end def teardown ARGV.replace @argv - ENV.replace @env $0 = @dollar_0 super diff --git a/test/rubygems/test_gem_command.rb b/test/rubygems/test_gem_command.rb index 669740fceb..43ce6ea39f 100644 --- a/test/rubygems/test_gem_command.rb +++ b/test/rubygems/test_gem_command.rb @@ -189,6 +189,18 @@ class TestGemCommand < Gem::TestCase assert_match %r{Usage: gem doit}, @ui.output end + def test_add_option + assert_nothing_raised RuntimeError do + @cmd.add_option('--force', 'skip validation of the spec') {|v,o| } + end + end + + def test_add_option_with_empty + assert_raise RuntimeError, "Do not pass an empty string in opts" do + @cmd.add_option('', 'skip validation of the spec') {|v,o| } + end + end + def test_option_recognition @cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options| options[:help] = true diff --git a/test/rubygems/test_gem_commands_help_command.rb b/test/rubygems/test_gem_commands_help_command.rb index ac315538cc..a70dd770e1 100644 --- a/test/rubygems/test_gem_commands_help_command.rb +++ b/test/rubygems/test_gem_commands_help_command.rb @@ -35,6 +35,13 @@ class TestGemCommandsHelpCommand < Gem::TestCase end end + def test_gem_help_build + util_gem 'build' do |out, err| + assert_match(/-C PATH *Run as if gem build was started in /, out) + assert_equal '', err + end + end + def test_gem_help_commands mgr = Gem::CommandManager.new diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb index e1bc22dbae..fa3968ffce 100644 --- a/test/rubygems/test_gem_commands_push_command.rb +++ b/test/rubygems/test_gem_commands_push_command.rb @@ -155,7 +155,6 @@ class TestGemCommandsPushCommand < Gem::TestCase @host => @api_key, } - FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path File.open Gem.configuration.credentials_path, 'w' do |f| f.write keys.to_yaml end @@ -190,7 +189,6 @@ class TestGemCommandsPushCommand < Gem::TestCase @host => @api_key, } - FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path File.open Gem.configuration.credentials_path, 'w' do |f| f.write keys.to_yaml end @@ -232,7 +230,6 @@ class TestGemCommandsPushCommand < Gem::TestCase :rubygems_api_key => @api_key, } - FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path File.open Gem.configuration.credentials_path, 'w' do |f| f.write keys.to_yaml end @@ -274,7 +271,6 @@ class TestGemCommandsPushCommand < Gem::TestCase @host => @api_key, } - FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path File.open Gem.configuration.credentials_path, 'w' do |f| f.write keys.to_yaml end @@ -305,7 +301,6 @@ class TestGemCommandsPushCommand < Gem::TestCase host => api_key, } - FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path File.open Gem.configuration.credentials_path, 'w' do |f| f.write keys.to_yaml end diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb index 21e2e9e6e4..3aa6bfa2fe 100644 --- a/test/rubygems/test_gem_commands_setup_command.rb +++ b/test/rubygems/test_gem_commands_setup_command.rb @@ -175,7 +175,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase assert_path_exist File.join(dir, 'bundler.rb') assert_path_exist File.join(dir, 'bundler/b.rb') - assert_path_exist File.join(dir, 'bundler/templates/.circleci/config.yml') unless RUBY_ENGINE == "truffleruby" # https://github.com/oracle/truffleruby/issues/2116 + assert_path_exist File.join(dir, 'bundler/templates/.circleci/config.yml') assert_path_exist File.join(dir, 'bundler/templates/.travis.yml') end end @@ -272,7 +272,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase @cmd.remove_old_lib_files lib - files_that_go.each {|file| assert_path_not_exist(file) unless file == old_bundler_ci && RUBY_ENGINE == "truffleruby" } # https://github.com/oracle/truffleruby/issues/2116 + files_that_go.each {|file| assert_path_not_exist(file) unless file == old_bundler_ci } files_that_stay.each {|file| assert_path_exist file } end diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb index 8f2477035c..eaf32886b3 100644 --- a/test/rubygems/test_gem_commands_signin_command.rb +++ b/test/rubygems/test_gem_commands_signin_command.rb @@ -26,6 +26,13 @@ class TestGemCommandsSigninCommand < Gem::TestCase assert_match %r{Signed in.}, sign_in_ui.output end + def test_execute_when_not_already_signed_in_and_not_preexisting_credentials_folder + FileUtils.rm Gem.configuration.credentials_path + + sign_in_ui = util_capture { @cmd.execute } + assert_match %r{Signed in.}, sign_in_ui.output + end + def test_execute_when_already_signed_in_with_same_host host = 'http://some-gemcutter-compatible-host.org' diff --git a/test/rubygems/test_gem_dependency.rb b/test/rubygems/test_gem_dependency.rb index 828021c119..1ca0fc378c 100644 --- a/test/rubygems/test_gem_dependency.rb +++ b/test/rubygems/test_gem_dependency.rb @@ -3,6 +3,12 @@ require_relative 'helper' require 'rubygems/dependency' class TestGemDependency < Gem::TestCase + def setup + super + + without_any_upwards_gemfiles + end + def test_initialize d = dep "pkg", "> 1.0" diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb index b765c17ed1..165194510e 100644 --- a/test/rubygems/test_gem_ext_builder.rb +++ b/test/rubygems/test_gem_ext_builder.rb @@ -106,7 +106,7 @@ install: end def test_build_extensions - skip if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning + pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning @spec.extensions << 'ext/extconf.rb' ext_dir = File.join @spec.gem_dir, 'ext' @@ -142,7 +142,7 @@ install: end def test_build_extensions_with_gemhome_with_space - skip if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning + pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning new_gemhome = File.join @tempdir, 'gem home' File.rename(@gemhome, new_gemhome) @gemhome = new_gemhome @@ -163,7 +163,7 @@ install: false end end - skip if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning + pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS') # not working from the beginning @spec.extensions << 'ext/extconf.rb' diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb index 9279756d63..70833f35cf 100644 --- a/test/rubygems/test_gem_ext_ext_conf_builder.rb +++ b/test/rubygems/test_gem_ext_ext_conf_builder.rb @@ -41,6 +41,7 @@ class TestGemExtExtConfBuilder < Gem::TestCase assert_contains_make_command '', output[7] assert_contains_make_command 'install', output[10] assert_empty Dir.glob(File.join(@ext, 'siteconf*.rb')) + assert_empty Dir.glob(File.join(@ext, '.gem.*')) end def test_class_build_rbconfig_make_prog diff --git a/test/rubygems/test_gem_ext_rake_builder.rb b/test/rubygems/test_gem_ext_rake_builder.rb index 5dff29ff6e..3d8922eed5 100644 --- a/test/rubygems/test_gem_ext_rake_builder.rb +++ b/test/rubygems/test_gem_ext_rake_builder.rb @@ -48,6 +48,8 @@ class TestGemExtRakeBuilder < Gem::TestCase end def test_class_no_openssl_override + pend 'openssl is missing' unless Gem::HAVE_OPENSSL + create_temp_mkrf_file('task :default') rake = util_spec 'rake' do |s| diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb index bb76fd2154..23aff00cbe 100644 --- a/test/rubygems/test_gem_gemcutter_utilities.rb +++ b/test/rubygems/test_gem_gemcutter_utilities.rb @@ -35,8 +35,6 @@ class TestGemGemcutterUtilities < Gem::TestCase "http://rubygems.engineyard.com" => "EYKEY", } - FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path - File.open Gem.configuration.credentials_path, 'w' do |f| f.write keys.to_yaml end @@ -50,7 +48,6 @@ class TestGemGemcutterUtilities < Gem::TestCase def test_api_key keys = { :rubygems_api_key => 'KEY' } - FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path File.open Gem.configuration.credentials_path, 'w' do |f| f.write keys.to_yaml @@ -63,7 +60,6 @@ class TestGemGemcutterUtilities < Gem::TestCase def test_api_key_override keys = { :rubygems_api_key => 'KEY', :other => 'OTHER' } - FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path File.open Gem.configuration.credentials_path, 'w' do |f| f.write keys.to_yaml @@ -168,7 +164,6 @@ class TestGemGemcutterUtilities < Gem::TestCase api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' other_api_key = 'f46dbb18bb6a9c97cdc61b5b85c186a17403cdcbf' - FileUtils.mkdir_p File.dirname(Gem.configuration.credentials_path) File.open Gem.configuration.credentials_path, 'w' do |f| f.write Hash[:other_api_key, other_api_key].to_yaml end @@ -246,7 +241,6 @@ class TestGemGemcutterUtilities < Gem::TestCase def test_verify_api_key keys = {:other => 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'} - FileUtils.mkdir_p File.dirname(Gem.configuration.credentials_path) File.open Gem.configuration.credentials_path, 'w' do |f| f.write keys.to_yaml end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index bb1126748e..a2b390d639 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -1776,6 +1776,26 @@ gem 'other', version end end + def test_pre_install_checks_malicious_platform_before_eval + gem_with_ill_formated_platform = File.expand_path("packages/ill-formatted-platform-1.0.0.10.gem", __dir__) + + installer = Gem::Installer.at( + gem_with_ill_formated_platform, + :install_dir => @gem_home, + :user_install => false, + :force => true + ) + + use_ui @ui do + e = assert_raise Gem::InstallError do + installer.pre_install_checks + end + + assert_equal "x86-mswin32\n system('id > /tmp/nyangawa')# is an invalid platform", e.message + assert_empty @ui.output + end + end + def test_shebang installer = setup_base_installer diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index e145310168..20509c8f3d 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -3612,7 +3612,7 @@ Did you mean 'Ruby'? @m2.validate end - assert_equal "metadata key too large (129 > 128)", e.message + assert_equal "metadata key is too large (129 > 128)", e.message end end @@ -3629,7 +3629,7 @@ Did you mean 'Ruby'? @m2.validate end - assert_equal "metadata values must be a String", e.message + assert_equal "metadata['fail'] value must be a String", e.message end end @@ -3646,7 +3646,7 @@ Did you mean 'Ruby'? @m2.validate end - assert_equal "metadata value too large (1025 > 1024)", e.message + assert_equal "metadata['fail'] value is too large (1025 > 1024)", e.message end end diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb index 28dbe15006..dee36d05ee 100644 --- a/test/rubygems/test_kernel.rb +++ b/test/rubygems/test_kernel.rb @@ -8,6 +8,8 @@ class TestKernel < Gem::TestCase @old_path = $:.dup util_make_gems + + without_any_upwards_gemfiles end def teardown diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb index 1c33dafbe2..07e412cc76 100644 --- a/test/rubygems/test_require.rb +++ b/test/rubygems/test_require.rb @@ -679,8 +679,6 @@ class TestGemRequire < Gem::TestCase end def test_no_crash_when_overriding_warn_with_warning_module - pend "https://github.com/oracle/truffleruby/issues/2109" if RUBY_ENGINE == "truffleruby" - Dir.mktmpdir("warn_test") do |dir| File.write(dir + "/main.rb", "module Warning; def warn(str); super; end; end; warn 'Foo Bar'") _, err = capture_subprocess_io do -- cgit v1.2.3