aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-12-17 18:20:37 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-12-17 23:55:24 +0900
commit905a926ea84e199478e32e6da5cd0e8d756132f1 (patch)
treefee81d1bfa7f822f2ee33fa9d99ed7252e1fa00e
parent4b7d27ca0de5e1294fa2072d948953ef49753fc5 (diff)
downloadruby-905a926ea84e199478e32e6da5cd0e8d756132f1.tar.gz
[ruby/io-console] Timeout in the child process
https://github.com/ruby/io-console/commit/b8411689a5
-rw-r--r--test/io/console/test_io_console.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index 083b4a7fb9..219b84615e 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -330,6 +330,7 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
def test_intr
run_pty("#{<<~"begin;"}\n#{<<~'end;'}") do |r, w, _|
begin;
+ require 'timeout'
STDOUT.puts `stty -a`.scan(/\b\w+ *= *\^.;/), ""
STDOUT.flush
con = IO.console
@@ -337,8 +338,8 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
p c.ord
p con.getch(intr: false).ord
begin
- p con.getch(intr: true).ord
- rescue Interrupt => e
+ p Timeout.timeout(1) {con.getch(intr: true)}.ord
+ rescue Timeout::Error, Interrupt => e
p e
end
end