summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-12-24 16:26:17 +0900
committeraycabta <aycabta@gmail.com>2021-12-24 17:12:01 +0900
commitf8a0ef30b20207aa57cce9537babcc283d8f6a4d (patch)
treee65ba15eadb4739a8582ff3e23d23ede881811f2
parent03f16d37bfaae86efe9633843bd26c3bfb9731fb (diff)
Set time limit for waiting for terminating process within a test
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5339
-rw-r--r--test/readline/test_readline.rb12
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."