Created
December 2, 2009 18:15
-
-
Save raggi/247405 to your computer and use it in GitHub Desktop.
ruby sync io bug on fbsd + osx, 1.8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This bug seems to occur on 1.8.6..1.9 on OSX and FreeBSD. It's known not to occur on Linux. | |
require 'rubygems' | |
require 'minitest/unit' | |
include MiniTest::Assertions | |
require 'tempfile' | |
path = nil | |
begin | |
Tempfile.open('testing.sync.pos') do |f| # Has been tested without tempfile. | |
path = f.path | |
end | |
open(path, 'a+') do |f| # Has been tested with w+, etc. | |
assert_equal 0, f.pos | |
f.write('a') | |
assert_equal 1, f.pos | |
f.write('b') | |
assert_equal 2, f.pos | |
f.sync = true | |
assert_equal 2, f.pos | |
f.write('c') | |
assert_equal 3, f.pos # Bug returns 2 here | |
end | |
ensure | |
File.delete(path) if File.exists?(path) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment