ruby-changes:61719
From: David <ko1@a...>
Date: Mon, 15 Jun 2020 19:48:45 +0900 (JST)
Subject: [ruby-changes:61719] c3ecd1cbd3 (master): Revert "Revert "[rubygems/rubygems] Remove unneeded global teardown""
https://git.ruby-lang.org/ruby.git/commit/?id=c3ecd1cbd3 From c3ecd1cbd37db93fe181f00dd0c43059d2f3fcec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Thu, 11 Jun 2020 12:12:13 +0200 Subject: Revert "Revert "[rubygems/rubygems] Remove unneeded global teardown"" This reverts commit ac2c07e98373bb62be618001c897fa9d5809d8a4. diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index fef9540..2c1b08c 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -356,12 +356,7 @@ class Gem::TestCase < Minitest::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L356 Dir.chdir @tempdir ENV['HOME'] = @userhome - FileUtils.mkdir_p File.join(@userhome, ".gem") - File.write File.join(@userhome, ".gemrc"), "--- {}" - Gem.instance_variable_set :@user_home, nil - Gem.instance_variable_set :@cache_home, nil - Gem.instance_variable_set :@data_home, nil Gem.instance_variable_set :@gemdeps, nil Gem.instance_variable_set :@env_requirements_by_name, nil Gem.send :remove_instance_variable, :@ruby_version if @@ -482,6 +477,10 @@ class Gem::TestCase < Minitest::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L477 File.chmod 0600, @temp_cred end + def credential_teardown + FileUtils.rm_rf @temp_cred + end + def common_installer_setup common_installer_teardown diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb index 76ede14..ac5d2dd 100644 --- a/test/rubygems/test_gem_commands_build_command.rb +++ b/test/rubygems/test_gem_commands_build_command.rb @@ -398,6 +398,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_build_command.rb#L398 skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform? gem_path = File.join Gem.user_home, ".gem" + Dir.mkdir gem_path Gem::Security.trust_dir @@ -441,6 +442,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_build_command.rb#L442 skip 'openssl is missing' unless defined?(OpenSSL::SSL) && !java_platform? gem_path = File.join Gem.user_home, ".gem" + Dir.mkdir gem_path Gem::Security.trust_dir diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb index bb9ed9e..fd1e66b 100644 --- a/test/rubygems/test_gem_commands_cert_command.rb +++ b/test/rubygems/test_gem_commands_cert_command.rb @@ -597,6 +597,7 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_cert_command.rb#L597 def test_execute_re_sign gem_path = File.join Gem.user_home, ".gem" + Dir.mkdir gem_path path = File.join @tempdir, 'cert.pem' Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600 @@ -627,6 +628,9 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_cert_command.rb#L628 end def test_execute_re_sign_with_cert_expiration_length_days + gem_path = File.join Gem.user_home, ".gem" + Dir.mkdir gem_path + path = File.join @tempdir, 'cert.pem' Gem::Security.write EXPIRED_PUBLIC_CERT, path, 0600 diff --git a/test/rubygems/test_gem_commands_owner_command.rb b/test/rubygems/test_gem_commands_owner_command.rb index 685365e..b830916 100644 --- a/test/rubygems/test_gem_commands_owner_command.rb +++ b/test/rubygems/test_gem_commands_owner_command.rb @@ -19,6 +19,12 @@ class TestGemCommandsOwnerCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_owner_command.rb#L19 @cmd = Gem::Commands::OwnerCommand.new end + def teardown + credential_teardown + + super + end + def test_show_owners response = <<EOF --- diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb index 877621d..30bc589 100644 --- a/test/rubygems/test_gem_commands_push_command.rb +++ b/test/rubygems/test_gem_commands_push_command.rb @@ -40,6 +40,8 @@ class TestGemCommandsPushCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_push_command.rb#L40 end def teardown + credential_teardown + super singleton_gem_class.class_eval do diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb index b559ddd..5994050 100644 --- a/test/rubygems/test_gem_commands_signin_command.rb +++ b/test/rubygems/test_gem_commands_signin_command.rb @@ -17,8 +17,8 @@ class TestGemCommandsSigninCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_signin_command.rb#L17 end def teardown - credentials_path = Gem.configuration.credentials_path - File.delete(credentials_path) if File.exist?(credentials_path) + credential_teardown + super end diff --git a/test/rubygems/test_gem_commands_yank_command.rb b/test/rubygems/test_gem_commands_yank_command.rb index a9e4e03..e84c7ea 100644 --- a/test/rubygems/test_gem_commands_yank_command.rb +++ b/test/rubygems/test_gem_commands_yank_command.rb @@ -18,6 +18,12 @@ class TestGemCommandsYankCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_yank_command.rb#L18 Gem.configuration.api_keys[:KEY] = 'other' end + def teardown + credential_teardown + + super + end + def test_handle_options @cmd.handle_options %w[a --version 1.0 --platform x86-darwin -k KEY --host HOST] diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb index 36725f9..c79563d 100644 --- a/test/rubygems/test_gem_config_file.rb +++ b/test/rubygems/test_gem_config_file.rb @@ -28,6 +28,8 @@ class TestGemConfigFile < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_config_file.rb#L28 ENV['GEMRC'] = @env_gemrc + credential_teardown + super end diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb index d82d644..1d7ecf1 100644 --- a/test/rubygems/test_gem_gemcutter_utilities.rb +++ b/test/rubygems/test_gem_gemcutter_utilities.rb @@ -25,6 +25,8 @@ class TestGemGemcutterUtilities < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_gemcutter_utilities.rb#L25 ENV['RUBYGEMS_HOST'] = nil Gem.configuration.rubygems_api_key = nil + credential_teardown + super end diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb index 88e89bd..3b533fe 100644 --- a/test/rubygems/test_gem_source.rb +++ b/test/rubygems/test_gem_source.rb @@ -228,7 +228,7 @@ class TestGemSource < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_source.rb#L228 end def test_update_cache_eh_home_nonexistent - FileUtils.rm_rf Gem.user_home + FileUtils.rmdir Gem.user_home refute @source.update_cache? end diff --git a/test/rubygems/test_gem_spec_fetcher.rb b/test/rubygems/test_gem_spec_fetcher.rb index 0a55c5d..b141a5b 100644 --- a/test/rubygems/test_gem_spec_fetcher.rb +++ b/test/rubygems/test_gem_spec_fetcher.rb @@ -33,7 +33,7 @@ class TestGemSpecFetcher < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_spec_fetcher.rb#L33 end def test_initialize_nonexistent_home_dir - FileUtils.rm_rf Gem.user_home + FileUtils.rmdir Gem.user_home assert Gem::SpecFetcher.new end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/