ruby-changes:40860
From: nobu <ko1@a...>
Date: Tue, 8 Dec 2015 14:12:32 +0900 (JST)
Subject: [ruby-changes:40860] nobu:r52939 (trunk): test_io_console.rb: separate master and slave
nobu 2015-12-08 14:12:15 +0900 (Tue, 08 Dec 2015) New Revision: 52939 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52939 Log: test_io_console.rb: separate master and slave * test/io/console/test_io_console.rb (test_getpass): separate master side and slave side in each threads. r52937 deadlocked on OS X. [Bug #11780] [ruby-dev:49412] Modified files: trunk/test/io/console/test_io_console.rb Index: test/io/console/test_io_console.rb =================================================================== --- test/io/console/test_io_console.rb (revision 52938) +++ test/io/console/test_io_console.rb (revision 52939) @@ -181,14 +181,21 @@ class TestIO_Console < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L181 end def test_getpass + # run_pty("p IO.console.getpass('> ')") do |r, w| + # assert_equal("> ", r.readpartial(10)) + # w.print "asdf\n" + # assert_equal("\r\n", r.gets) + # assert_equal("\"asdf\"", r.gets.chomp) + # end helper {|m, s| begin th = Thread.start { - sleep 0.1 - m.print "asdf\n" + s.getpass("> ") } - assert_equal("asdf", s.getpass("> ")) - assert_equal("> \r\n", m.readpartial(10)) + assert_equal("> ", m.readpartial(10)) + m.print "asdf\n" + assert_equal("asdf", th.value) + assert_equal("\r\n", m.gets) ensure th.join rescue nil end @@ -285,17 +292,18 @@ class TestIO_Console < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L292 rescue RuntimeError skip $! else - result = [] - n.times {result << r.gets.chomp} - Process.wait(pid) if block_given? - yield result + yield r, w, pid else + result = [] + n.times {result << r.gets.chomp} + Process.wait(pid) result end ensure r.close if r w.close if w + Process.wait(pid) if pid end end if defined?(PTY) and defined?(IO::console) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/