1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Remove unneeded global teardown

Instead, make each test cleanup after itself.

https://github.com/rubygems/rubygems/commit/e0aba9d64f
This commit is contained in:
David Rodríguez 2020-04-29 14:18:59 +02:00 committed by Hiroshi SHIBATA
parent ae684f664f
commit 93d1588c78
11 changed files with 32 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 = <<EOF
---

View file

@ -40,6 +40,8 @@ class TestGemCommandsPushCommand < Gem::TestCase
end
def teardown
credential_teardown
super
singleton_gem_class.class_eval do

View file

@ -17,8 +17,8 @@ class TestGemCommandsSigninCommand < Gem::TestCase
end
def teardown
credentials_path = Gem.configuration.credentials_path
File.delete(credentials_path) if File.exist?(credentials_path)
credential_teardown
super
end

View file

@ -18,6 +18,12 @@ class TestGemCommandsYankCommand < Gem::TestCase
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]

View file

@ -28,6 +28,8 @@ class TestGemConfigFile < Gem::TestCase
ENV['GEMRC'] = @env_gemrc
credential_teardown
super
end

View file

@ -25,6 +25,8 @@ class TestGemGemcutterUtilities < Gem::TestCase
ENV['RUBYGEMS_HOST'] = nil
Gem.configuration.rubygems_api_key = nil
credential_teardown
super
end

View file

@ -228,7 +228,7 @@ class TestGemSource < Gem::TestCase
end
def test_update_cache_eh_home_nonexistent
FileUtils.rm_rf Gem.user_home
FileUtils.rmdir Gem.user_home
refute @source.update_cache?
end

View file

@ -33,7 +33,7 @@ class TestGemSpecFetcher < Gem::TestCase
end
def test_initialize_nonexistent_home_dir
FileUtils.rm_rf Gem.user_home
FileUtils.rmdir Gem.user_home
assert Gem::SpecFetcher.new
end