1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Wait for the main thread to start reading by Queue

Otherwise, the written data to pty before the reading started may
be just lost.
This commit is contained in:
Nobuyoshi Nakada 2019-12-02 13:16:55 +09:00
parent de74d2c3b0
commit b1c92363a7
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -41,12 +41,15 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
end
def test_raw_minchar
q = Thread::Queue.new
helper {|m, s|
len = 0
assert_equal([nil, 0], [s.getch(min: 0), len])
main = Thread.current
go = false
th = Thread.start {
q.pop
sleep 0.01 until main.stop?
len += 1
m.print("a")
m.flush
@ -56,6 +59,8 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
m.flush
}
begin
sleep 0.1
q.push(1)
assert_equal(["a", 1], [s.getch(min: 1), len])
go = true
assert_equal(["1", 11], [s.getch, len])