summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-08 12:39:30 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-08 14:13:29 +0900
commitac2c07e98373bb62be618001c897fa9d5809d8a4 (patch)
treeac3ae70c43ce5038078bce0466b451585b1f908b
parentceacb06311cf150cd3682b277bbe6cf7e7bbbc30 (diff)
Revert "[rubygems/rubygems] Remove unneeded global teardown"
This reverts commit 93d1588c782ab9d61699f98b6c64d7f0ab8121c0.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3092
-rw-r--r--lib/rubygems/test_case.rb9
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_owner_command.rb6
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb2
-rw-r--r--test/rubygems/test_gem_commands_signin_command.rb4
-rw-r--r--test/rubygems/test_gem_commands_yank_command.rb6
-rw-r--r--test/rubygems/test_gem_config_file.rb2
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb2
-rw-r--r--test/rubygems/test_gem_source.rb2
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb2
11 files changed, 9 insertions, 32 deletions
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index cd74ec614c..a63c99fd8e 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -356,7 +356,12 @@ 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
@@ -476,10 +481,6 @@ 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 ac5d2ddd16..76ede1466f 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -398,7 +398,6 @@ 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
@@ -442,7 +441,6 @@ 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 fd1e66b915..bb9ed9e630 100644
--- a/test/rubygems/test_gem_commands_cert_command.rb
+++ b/test/rubygems/test_gem_commands_cert_command.rb
@@ -597,7 +597,6 @@ 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
@@ -628,9 +627,6 @@ 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 b830916fbe..685365ed3b 100644
--- a/test/rubygems/test_gem_commands_owner_command.rb
+++ b/test/rubygems/test_gem_commands_owner_command.rb
@@ -19,12 +19,6 @@ class TestGemCommandsOwnerCommand < Gem::TestCase
@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 30bc589f92..877621d489 100644
--- a/test/rubygems/test_gem_commands_push_command.rb
+++ b/test/rubygems/test_gem_commands_push_command.rb
@@ -40,8 +40,6 @@ class TestGemCommandsPushCommand < Gem::TestCase
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 dc6d3b054a..8991f65302 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
end
def teardown
- credential_teardown
-
+ credentials_path = Gem.configuration.credentials_path
+ File.delete(credentials_path) if File.exist?(credentials_path)
super
end
diff --git a/test/rubygems/test_gem_commands_yank_command.rb b/test/rubygems/test_gem_commands_yank_command.rb
index e84c7eaadd..a9e4e03dea 100644
--- a/test/rubygems/test_gem_commands_yank_command.rb
+++ b/test/rubygems/test_gem_commands_yank_command.rb
@@ -18,12 +18,6 @@ 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]
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
index c79563d650..36725f9390 100644
--- a/test/rubygems/test_gem_config_file.rb
+++ b/test/rubygems/test_gem_config_file.rb
@@ -28,8 +28,6 @@ class TestGemConfigFile < Gem::TestCase
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 1d7ecf14b1..d82d6447e7 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -25,8 +25,6 @@ class TestGemGemcutterUtilities < Gem::TestCase
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 3b533febe4..88e89bd192 100644
--- a/test/rubygems/test_gem_source.rb
+++ b/test/rubygems/test_gem_source.rb
@@ -228,7 +228,7 @@ class TestGemSource < Gem::TestCase
end
def test_update_cache_eh_home_nonexistent
- FileUtils.rmdir Gem.user_home
+ FileUtils.rm_rf 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 b141a5b7b5..0a55c5d2e8 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
end
def test_initialize_nonexistent_home_dir
- FileUtils.rmdir Gem.user_home
+ FileUtils.rm_rf Gem.user_home
assert Gem::SpecFetcher.new
end