diff options
author | Nobuyoshi Nakada <[email protected]> | 2023-12-25 11:13:27 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2023-12-25 13:01:55 +0900 |
commit | 2cdbeb29e6e06d3492e2d4a388558ab883b07150 (patch) | |
tree | fe59d3a3477d0911a2b7f7aaa1cb1a1226c1cbda /test/ruby/test_io_buffer.rb | |
parent | b4efa4b7005efee484e61fbc6af9c652fee36db2 (diff) |
Do not leave test file
Run this test separately because something seems remained unreleased
on Windows.
Diffstat (limited to 'test/ruby/test_io_buffer.rb')
-rw-r--r-- | test/ruby/test_io_buffer.rb | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/test/ruby/test_io_buffer.rb b/test/ruby/test_io_buffer.rb index c4239101cf..b4b63b1eda 100644 --- a/test/ruby/test_io_buffer.rb +++ b/test/ruby/test_io_buffer.rb @@ -519,22 +519,26 @@ class TestIOBuffer < Test::Unit::TestCase end def test_private - tmpdir = Dir.tmpdir - buffer_path = File.join(tmpdir, "buffer.txt") - File.write(buffer_path, "Hello World") - - File.open(buffer_path) do |file| - buffer = IO::Buffer.map(file, nil, 0, IO::Buffer::PRIVATE) - assert buffer.private? - refute buffer.readonly? - - buffer.set_string("J") - - # It was not changed because the mapping was private: - file.seek(0) - assert_equal "Hello World", file.read - ensure - buffer&.free + Tempfile.create(%w"buffer .txt") do |file| + file.write("Hello World") + file.close + assert_separately(["-W0", "-", file.path], "#{<<-"begin;"}\n#{<<-'end;'}") + begin; + file = File.open(ARGV[0], "r+") + buffer = IO::Buffer.map(file, nil, 0, IO::Buffer::PRIVATE) + begin + assert buffer.private? + refute buffer.readonly? + + buffer.set_string("J") + + # It was not changed because the mapping was private: + file.seek(0) + assert_equal "Hello World", file.read + ensure + buffer&.free + end + end; end end end |