summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 05:12:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 05:12:15 +0000
commit95184065445e2888a624911214db67fe3695ec85 (patch)
tree2286aa762459c6b631c539e3aba9820ed4abe44c
parentf2a7ca746fe946784ab42e8dbc21cbc6342cee61 (diff)
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/io/console/test_io_console.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index 74674ced9a3..980478fcbf1 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -181,14 +181,21 @@ class TestIO_Console < Test::Unit::TestCase
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::TestCase
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)