Stub File.unlink without redefining it in the tempfile test

Redefining the method warns under RUBYOPT=-w, which CI uses, and the test expects nothing on stderr. Prepending a module leaves the original method in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hiroshi SHIBATAandClaude Opus 5.5 committed 2026-09-26 13:16:06 +09:00
1 parent 75d5467039
commit b5245a5d33
1 file changed
+5 -3
Notes: git 2026-09-26 04:16:41 +00:00
+5 -3
View File
@@ -237,9 +237,11 @@ File.open(path, "w").close
def test_finalizer_ignores_eacces_on_unlink
assert_in_out_err("-r#{LIB_TEMPFILE_RB_PATH}", <<~'RUBY') do |(filename,*), (error,*)|
def File.unlink(*)
raise Errno::EACCES
end
File.singleton_class.prepend(Module.new do
def unlink(*)
raise Errno::EACCES
end
end)
file = Tempfile.new("foo")
puts file.path
RUBY