From 93293043f135dec5a972378682b9e947fba7c4a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 29 Apr 2020 14:18:59 +0200 Subject: [rubygems/rubygems] Remove unneeded global teardown Instead, make each test cleanup after itself. https://github.com/rubygems/rubygems/commit/e0aba9d64f --- lib/rubygems/test_case.rb | 9 ++++----- test/rubygems/test_gem_commands_build_command.rb | 2 ++ test/rubygems/test_gem_commands_cert_command.rb | 4 ++++ test/rubygems/test_gem_commands_owner_command.rb | 6 ++++++ test/rubygems/test_gem_commands_push_command.rb | 2 ++ test/rubygems/test_gem_commands_signin_command.rb | 4 ++-- test/rubygems/test_gem_commands_yank_command.rb | 6 ++++++ test/rubygems/test_gem_config_file.rb | 2 ++ test/rubygems/test_gem_gemcutter_utilities.rb | 2 ++ test/rubygems/test_gem_source.rb | 2 +- test/rubygems/test_gem_spec_fetcher.rb | 2 +- 11 files changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 0609519efa..e2a880ef2b 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -357,12 +357,7 @@ class Gem::TestCase < Minitest::Test 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 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 76ede1466f..ac5d2ddd16 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 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 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 bb9ed9e630..fd1e66b915 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 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 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 685365ed3b..b830916fbe 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 @cmd = Gem::Commands::OwnerCommand.new end + def teardown + credential_teardown + + super + end + def test_show_owners response = <