Skip to content

Commit

Permalink
Do not leave test file
Browse files Browse the repository at this point in the history
Run this test separately because something seems remained unreleased
on Windows.
  • Loading branch information
nobu committed Dec 25, 2023
1 parent b4efa4b commit 2cdbeb2
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions test/ruby/test_io_buffer.rb
Expand Up @@ -519,22 +519,26 @@ def test_shared
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

0 comments on commit 2cdbeb2

Please sign in to comment.