From 0e04785a7d3e86e87137aa3716efcdd91080b2a1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 10 Sep 2026 19:10:58 +0900 Subject: [PATCH] Test the `getch` timeout on an isolated pty with no input Testing on the default tty should be performed only in the CI environment. --- test/io/console/test_io_console.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index 1878264..74c5a0a 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -610,6 +610,10 @@ def test_intr end end + def test_getch_timeout + assert_equal(["nil"], run_pty("p IO.console.getch(intr: true, time: 0.1, min: 0)")) + end + unless IO.console def test_close assert_equal(["true"], run_pty("IO.console.close; p IO.console.fileno >= 0")) @@ -719,7 +723,7 @@ def test_sync def test_getch_timeout assert_nil(IO.console.getch(intr: true, time: 0.1, min: 0)) - end + end if ENV["CI"] def test_ttyname return unless IO.method_defined?(:ttyname)