summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-12-02 13:16:55 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-12-02 13:17:05 +0900
commitb1c92363a74b0e649a685ae47ae400fbaab7b29d (patch)
treec5cc16ce3b5a747437db988fb448ec17d092095e /test
parentde74d2c3b0005048a2c4433bde68b9be10c86f01 (diff)
Wait for the main thread to start reading by Queue
Otherwise, the written data to pty before the reading started may be just lost.
Diffstat (limited to 'test')
-rw-r--r--test/io/console/test_io_console.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index 8547ae9d70..eb73514e43 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -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])