From f8a0ef30b20207aa57cce9537babcc283d8f6a4d Mon Sep 17 00:00:00 2001 From: aycabta Date: Fri, 24 Dec 2021 16:26:17 +0900 Subject: Set time limit for waiting for terminating process within a test --- test/readline/test_readline.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb index f59e9ee900..15423fd672 100644 --- a/test/readline/test_readline.rb +++ b/test/readline/test_readline.rb @@ -570,8 +570,16 @@ module BasetestReadline rescue Timeout::Error => e assert false, "Timed out to handle SIGINT!\nLog: #{log}\nBacktrace:\n#{e.full_message(highlight: false)}\n----" ensure - status = Process.wait2(pid).last - assert status.success?, "Unknown failure with exit status #{status}\nLog: #{log}\n----" + status = nil + begin + Timeout.timeout(TIMEOUT) do + status = Process.wait2(pid).last + end + rescue Timeout::Error => e + Process.kill(:KILL, pid) + assert false, "Timed out to wait for terminating a process in a test of SIGINT!\nLog: #{log}\nBacktrace:\n#{e.full_message(highlight: false)}\n----" + end + assert status&.success?, "Unknown failure with exit status #{status.inspect}\nLog: #{log}\n----" end assert log.include?('INT'), "Interrupt was handled correctly." -- cgit v1.2.3