[前][次][番号順一覧][スレッド一覧]

ruby-changes:61145

From: Hiroshi <ko1@a...>
Date: Fri, 8 May 2020 14:15:05 +0900 (JST)
Subject: [ruby-changes:61145] ac2c07e983 (master): Revert "[rubygems/rubygems] Remove unneeded global teardown"

https://git.ruby-lang.org/ruby.git/commit/?id=ac2c07e983

From ac2c07e98373bb62be618001c897fa9d5809d8a4 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Fri, 8 May 2020 12:39:30 +0900
Subject: Revert "[rubygems/rubygems] Remove unneeded global teardown"

This reverts commit 93d1588c782ab9d61699f98b6c64d7f0ab8121c0.

diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index cd74ec6..a63c99f 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -356,7 +356,12 @@ 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
@@ -476,10 +481,6 @@ class Gem::TestCase < Minitest::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L481
     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 ac5d2dd..76ede14 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 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
 
@@ -442,7 +441,6 @@ class TestGemCommandsBuildCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_build_command.rb#L441
     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 fd1e66b..bb9ed9e 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 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
@@ -628,9 +627,6 @@ 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#L627
   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 b830916..685365e 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 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 30bc589..877621d 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 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 dc6d3b0..8991f65 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
-    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 e84c7ea..a9e4e03 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 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 c79563d..36725f9 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 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 1d7ecf1..d82d644 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 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 3b533fe..88e89bd 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.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 b141a5b..0a55c5d 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.rmdir Gem.user_home
+    FileUtils.rm_rf Gem.user_home
 
     assert Gem::SpecFetcher.new
   end
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]