summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2022-03-13 15:10:34 +0900
committernagachika <nagachika@ruby-lang.org>2022-03-13 15:10:34 +0900
commitf4f0c793f6eb427b0a85445bff49fdc6b73447ae (patch)
tree6b9bdfcc65455b444d7101ecd7fa547c49ce7614 /test
parent6175823bab28b5d12f66371d67d006df37751fbc (diff)
merge revision(s) b555e659c4974acc423083b71b1bd5ec6a926046: [Backport #18388]
Do not use `fcopyfile` if appending to non-empty file [Bug #18388] `fcopyfile` appends `src` to `to` and then truncates `to` to it's original size. --- io.c | 7 +++++++ test/ruby/test_io.rb | 12 ++++++++++++ 2 files changed, 19 insertions(+)
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 5b84fd6a4d..e178e7579b 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -476,6 +476,18 @@ class TestIO < Test::Unit::TestCase
}
end
+ def test_copy_stream_append_to_nonempty
+ with_srccontent("foobar") {|src, content|
+ preface = 'preface'
+ File.write('dst', preface)
+ File.open('dst', 'ab') do |dst|
+ ret = IO.copy_stream(src, dst)
+ assert_equal(content.bytesize, ret)
+ assert_equal(preface + content, File.read("dst"))
+ end
+ }
+ end
+
def test_copy_stream_smaller
with_srccontent {|src, content|