ruby-changes:59035
From: Nobuyoshi <ko1@a...>
Date: Mon, 2 Dec 2019 13:17:49 +0900 (JST)
Subject: [ruby-changes:59035] b1c92363a7 (master): Wait for the main thread to start reading by Queue
https://git.ruby-lang.org/ruby.git/commit/?id=b1c92363a7 From b1c92363a74b0e649a685ae47ae400fbaab7b29d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 2 Dec 2019 13:16:55 +0900 Subject: Wait for the main thread to start reading by Queue Otherwise, the written data to pty before the reading started may be just lost. diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index 8547ae9..eb73514 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 https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L41 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 https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L59 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]) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/