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

ruby-changes:61131

From: David <ko1@a...>
Date: Fri, 8 May 2020 14:14:56 +0900 (JST)
Subject: [ruby-changes:61131] 93293043f1 (master): [rubygems/rubygems] Remove unneeded global teardown

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

From 93293043f135dec5a972378682b9e947fba7c4a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
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

diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 0609519..e2a880e 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -357,12 +357,7 @@ class Gem::TestCase < Minitest::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L357
     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 8991f65..dc6d3b0 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/

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