Skip to content

Commit

Permalink
[rubygems/rubygems] The temporary directory must been removed
Browse files Browse the repository at this point in the history
On Windows, open files cannot be removed and `FileUtils.rm_rf` just
silently fails.  This means also handle leaks, not only temporary file
leaks.

rubygems/rubygems@80a9c3ec08
  • Loading branch information
nobu authored and hsbt committed Feb 26, 2024
1 parent 65f4096 commit 7dd4b30
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions test/rubygems/helper.rb
Expand Up @@ -290,7 +290,6 @@ def setup
FileUtils.mkdir_p @tmp

@tempdir = Dir.mktmpdir("test_rubygems_", @tmp)
@@tempdirs << [method_name, @tempdir]

ENV["GEM_VENDOR"] = nil
ENV["GEMRC"] = nil
Expand Down Expand Up @@ -475,12 +474,11 @@ def teardown

@back_ui.close

refute_directory_exists @tempdir, "may be still in use"
ghosts = @@tempdirs.filter_map do |test_name, tempdir|
if File.exist?(tempdir)
FileUtils.rm_rf(tempdir)
test_name
end
test_name if File.exist?(tempdir)
end
@@tempdirs << [method_name, @tempdir]
assert_empty ghosts
end

Expand Down

0 comments on commit 7dd4b30

Please sign in to comment.