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
This commit is contained in:
parent
f2a7ca746f
commit
9518406544
@ -181,14 +181,21 @@ class TestIO_Console < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_getpass
|
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|
|
helper {|m, s|
|
||||||
begin
|
begin
|
||||||
th = Thread.start {
|
th = Thread.start {
|
||||||
sleep 0.1
|
s.getpass("> ")
|
||||||
m.print "asdf\n"
|
|
||||||
}
|
}
|
||||||
assert_equal("asdf", s.getpass("> "))
|
assert_equal("> ", m.readpartial(10))
|
||||||
assert_equal("> \r\n", m.readpartial(10))
|
m.print "asdf\n"
|
||||||
|
assert_equal("asdf", th.value)
|
||||||
|
assert_equal("\r\n", m.gets)
|
||||||
ensure
|
ensure
|
||||||
th.join rescue nil
|
th.join rescue nil
|
||||||
end
|
end
|
||||||
@ -285,17 +292,18 @@ class TestIO_Console < Test::Unit::TestCase
|
|||||||
rescue RuntimeError
|
rescue RuntimeError
|
||||||
skip $!
|
skip $!
|
||||||
else
|
else
|
||||||
result = []
|
|
||||||
n.times {result << r.gets.chomp}
|
|
||||||
Process.wait(pid)
|
|
||||||
if block_given?
|
if block_given?
|
||||||
yield result
|
yield r, w, pid
|
||||||
else
|
else
|
||||||
|
result = []
|
||||||
|
n.times {result << r.gets.chomp}
|
||||||
|
Process.wait(pid)
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
r.close if r
|
r.close if r
|
||||||
w.close if w
|
w.close if w
|
||||||
|
Process.wait(pid) if pid
|
||||||
end
|
end
|
||||||
end if defined?(PTY) and defined?(IO::console)
|
end if defined?(PTY) and defined?(IO::console)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user