Maybe one time in twenty it succeeds, but I have not tried to check whether this is revision dependent. The latest revision I tested and which failed the test was 21852
=end
=begin
I got this also. I'm on Mac 10.5.6 running ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.6.0]
I don't understand what this test is trying to test. It does not make any sense to me. You fill the pipe with a's. So, the pipe is full. Then you try to write 4096 b's and 4096 c's. That is in blocking mode so it is going to block until there is space. You read only 8192 of space but the pipe may not be back enabled until you read more than that. I would read one byte at a time. Ignore the a's and count the b's and c's until it goes empty, then see if you got 4096 b's and c's.
assert_finish 10, %q{
begin
require "io/nonblock"
r, w = IO.pipe
w.nonblock = true
w.write_nonblock("a" * 100000)
w.nonblock = false
t1 = Thread.new { w.write("b" * 4096) }
t2 = Thread.new { w.write("c" * 4096) }
b_count = 0
c_count = 0
while c = r.sysread(1)
b_count += 1 if c == "b"
c_count += 1 if c == "c"
break if b_count == 4096 && c_count == 4096
end
t1.join
t2.join
rescue LoadError
end
}, '[ruby-dev:32566]'