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

ruby-changes:72315

From: Tomas <ko1@a...>
Date: Sun, 26 Jun 2022 11:15:58 +0900 (JST)
Subject: [ruby-changes:72315] 56809537a4 (master): [rubygems/rubygems] Clean up temporary directory after generate_index --update

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

From 56809537a46417d4c0f93de9ea9fc9a623ea83f1 Mon Sep 17 00:00:00 2001
From: Tomas Volf <tomas.volf@s...>
Date: Fri, 24 Jun 2022 09:21:47 +0200
Subject: [rubygems/rubygems] Clean up temporary directory after generate_index
 --update

While generate_index did clean up temporary directory, when running with
--update flag, that did not happen and the temporary directory was left
behind.

This commit fixes that and modifies tests in order to make sure this is
not reintroduced later on.

Fixes #5635.

https://github.com/rubygems/rubygems/commit/9fa34dc329
---
 lib/rubygems/indexer.rb           | 2 ++
 test/rubygems/helper.rb           | 6 ++++++
 test/rubygems/test_gem_indexer.rb | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index 6e8dade640..a5a86f4111 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -401,6 +401,8 @@ class Gem::Indexer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/indexer.rb#L401
 
       File.utime newest_mtime, newest_mtime, dst_name
     end
+  ensure
+    FileUtils.rm_rf @directory
   end
 
   ##
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index 75eed7be6b..7bd7dd0c3b 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -119,6 +119,12 @@ class Gem::TestCase < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/helper.rb#L119
     assert File.directory?(path), msg
   end
 
+  def refute_directory_exists(path, msg = nil)
+    msg = build_message(msg, "Expected path '#{path}' not to be a directory")
+    assert_path_not_exist path
+    refute File.directory?(path), msg
+  end
+
   # https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L188
   def _synchronize
     yield
diff --git a/test/rubygems/test_gem_indexer.rb b/test/rubygems/test_gem_indexer.rb
index 6653f29adf..24afae5fcc 100644
--- a/test/rubygems/test_gem_indexer.rb
+++ b/test/rubygems/test_gem_indexer.rb
@@ -103,6 +103,8 @@ class TestGemIndexer < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_indexer.rb#L103
 
     assert_indexed @indexerdir, "latest_specs.#{@marshal_version}"
     assert_indexed @indexerdir, "latest_specs.#{@marshal_version}.gz"
+
+    refute_directory_exists @indexer.directory
   end
 
   def test_generate_index_modern
@@ -342,6 +344,8 @@ class TestGemIndexer < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_indexer.rb#L344
 
       assert_includes pre_specs_index, @d2_1_a_tuple
       refute_includes pre_specs_index, @d2_1_tuple
+
+      refute_directory_exists @indexer.directory
     end
   end
 
-- 
cgit v1.2.1


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

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