[ruby/tmpdir] Make mktmpdir cleanup tolerate missing paths.

https://github.com/ruby/tmpdir/commit/57c6cad284
This commit is contained in:
Samuel Williams authored and git committed 2026-06-21 21:43:29 +00:00
1 parent 20e8c63fad
commit 2b751ac7e3
2 files changed
+13 -2

No files matched your search

+2 -2
View File
@@ -73,7 +73,7 @@ class Dir
# If a block is given,
# it is yielded with the path of the directory.
# The directory and its contents are removed
# using FileUtils.remove_entry before Dir.mktmpdir returns.
# using FileUtils.remove_entry with force before Dir.mktmpdir returns.
# The value of the block is returned.
#
# Dir.mktmpdir {|dir|
@@ -111,7 +111,7 @@ class Dir
raise ArgumentError, "parent directory is world writable but not sticky: #{base}"
end
end
FileUtils.remove_entry path
FileUtils.remove_entry path, true
end
else
path
+11
View File
@@ -77,6 +77,17 @@ class TestTmpdir < Test::Unit::TestCase
}
end
def test_mktmpdir_tolerates_removed_directory
dir = nil
assert_nothing_raised do
Dir.mktmpdir do |d|
dir = d
FileUtils.remove_entry(d)
end
end
assert_file.not_exist?(dir)
end
def test_mktmpdir_mutate
bug16918 = '[ruby-core:98563]'
assert_nothing_raised(bug16918) do