aboutsummaryrefslogtreecommitdiffstats
path: root/test/lib
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-05-26 17:19:46 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-05-26 17:23:14 +0900
commit4668a3a9da9f02b073631013e71722868ceafa53 (patch)
treeda4b3288693f7bc88238063af1e01029451d99d1 /test/lib
parent02b39daef834890981689f1f697c7c25cad55dd6 (diff)
downloadruby-4668a3a9da9f02b073631013e71722868ceafa53.tar.gz
test/lib/envutil.rb (EnvUtil.timeout): added.
It is a wrapper for Timeout.timeout with the scale factor applied.
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/envutil.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/lib/envutil.rb b/test/lib/envutil.rb
index f4d63d5a0a..f9c0e57fcf 100644
--- a/test/lib/envutil.rb
+++ b/test/lib/envutil.rb
@@ -65,6 +65,13 @@ module EnvUtil
end
module_function :apply_timeout_scale
+ def timeout(sec, klass = nil, message = nil, &blk)
+ return yield(sec) if sec == nil or sec.zero?
+ sec = apply_timeout_scale(sec)
+ Timeout.timeout(sec, klass, message, &blk)
+ end
+ module_function :timeout
+
def terminate(pid, signal = :TERM, pgroup = nil, reprieve = 1)
reprieve = apply_timeout_scale(reprieve) if reprieve