summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 13:26:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 13:26:56 +0000
commit8f620b9b17ccbaae1e3eb9a1b9b5d528f4d5f900 (patch)
treed40eb3f022acf193c0a944dc4e797ddcdae061a1 /test
parentdc331ca5c0be1375e9b6307da43665b2486f2264 (diff)
retry IO#getpass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/io/console/test_io_console.rb19
1 files changed, 15 insertions, 4 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index c69eec757e..d5ddc08029 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -180,6 +180,16 @@ class TestIO_Console < Test::Unit::TestCase
}
end
+ def test_getpass
+ skip unless IO.method_defined?("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
+ end
+
def test_iflush
helper {|m, s|
m.print "a"
@@ -270,17 +280,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)