diff options
author | aycabta <aycabta@gmail.com> | 2021-12-24 16:26:17 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2021-12-24 17:12:01 +0900 |
commit | f8a0ef30b20207aa57cce9537babcc283d8f6a4d (patch) | |
tree | e65ba15eadb4739a8582ff3e23d23ede881811f2 /test/readline/test_readline.rb | |
parent | 03f16d37bfaae86efe9633843bd26c3bfb9731fb (diff) | |
download | ruby-f8a0ef30b20207aa57cce9537babcc283d8f6a4d.tar.gz |
Set time limit for waiting for terminating process within a test
Diffstat (limited to 'test/readline/test_readline.rb')
-rw-r--r-- | test/readline/test_readline.rb | 12 |
1 files 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." |