From 65f40967d5c2ee2df1755f8a9159553df15e6295 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 21 Feb 2024 22:35:14 +0900 Subject: [rubygems/rubygems] Get rid of too long paths This is a fix-up of #7483. Test method names in Rubygems are often very long, and the path under the temporary directory generated from them can easily exceed system limits. Even without including the method name in the path name, by saving the method and path name pair, it is possible to find the method from the remaining path name. https://github.com/rubygems/rubygems/commit/de55064a3d --- test/rubygems/helper.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb index c33d1bba21..6b4aaa5525 100644 --- a/test/rubygems/helper.rb +++ b/test/rubygems/helper.rb @@ -289,8 +289,8 @@ class Gem::TestCase < Test::Unit::TestCase FileUtils.mkdir_p @tmp - @tempdir = Dir.mktmpdir(method_name.to_s, @tmp) - @@tempdirs << @tempdir + @tempdir = Dir.mktmpdir("test_rubygems_", @tmp) + @@tempdirs << [method_name, @tempdir] ENV["GEM_VENDOR"] = nil ENV["GEMRC"] = nil @@ -475,7 +475,13 @@ class Gem::TestCase < Test::Unit::TestCase @back_ui.close - assert_empty @@tempdirs.select {|tempdir| File.exist?(tempdir) } + ghosts = @@tempdirs.filter_map do |test_name, tempdir| + if File.exist?(tempdir) + FileUtils.rm_rf(tempdir) + test_name + end + end + assert_empty ghosts end def credential_setup -- cgit v1.2.3