Do not leave test file
Run this test separately because something seems remained unreleased on Windows.
This commit is contained in:
parent
b4efa4b700
commit
2cdbeb29e6
@ -519,22 +519,26 @@ class TestIOBuffer < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_private
|
def test_private
|
||||||
tmpdir = Dir.tmpdir
|
Tempfile.create(%w"buffer .txt") do |file|
|
||||||
buffer_path = File.join(tmpdir, "buffer.txt")
|
file.write("Hello World")
|
||||||
File.write(buffer_path, "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?
|
||||||
|
|
||||||
File.open(buffer_path) do |file|
|
buffer.set_string("J")
|
||||||
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)
|
||||||
# It was not changed because the mapping was private:
|
assert_equal "Hello World", file.read
|
||||||
file.seek(0)
|
ensure
|
||||||
assert_equal "Hello World", file.read
|
buffer&.free
|
||||||
ensure
|
end
|
||||||
buffer&.free
|
end;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user