mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 08:25:20 +08:00
[ruby/tmpdir] Make mktmpdir cleanup tolerate missing paths.
https://github.com/ruby/tmpdir/commit/57c6cad284
This commit is contained in:
1 parent
20e8c63fad
commit
2b751ac7e3
2 files changed
+13
-2
No files matched your search
+2
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user