diff options
author | NAKAMURA Usaku <usa@ruby-lang.org> | 2022-03-19 22:41:16 +0900 |
---|---|---|
committer | NAKAMURA Usaku <usa@ruby-lang.org> | 2022-03-19 22:41:16 +0900 |
commit | 7eaec9a6b355a685a3a9503a005b91f4b3cb4f39 (patch) | |
tree | 696cb2af22077cfbe40519b86ed732d949a4ba01 /test | |
parent | 5da2a3e31699570ae1a951c8bbc489040051d19e (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.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 1e4d88ef1e..37f1477483 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -440,6 +440,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| |