Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/tmpdir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def self.tmpdir
# 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.
Comment thread
ioquatix marked this conversation as resolved.
#
# Dir.mktmpdir {|dir|
Expand Down Expand Up @@ -111,7 +111,7 @@ def self.mktmpdir(prefix_suffix=nil, *rest, **options, &block)
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
Expand Down
11 changes: 11 additions & 0 deletions test/test_tmpdir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ def test_mktmpdir_nil
}
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
Expand Down