diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-25 23:43:33 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-25 23:43:33 +0000 |
commit | 7d52ed594ecc0fe4587b2a9132f5b4a8e39cf2e9 (patch) | |
tree | 36a7c60b04331d2a62d0339eb8ffa19fad89ac4a | |
parent | 20a82f8839581742438b526a6acda447c43add34 (diff) | |
download | ruby-7d52ed594ecc0fe4587b2a9132f5b4a8e39cf2e9.tar.gz |
use timeout scale.
* test/lib/envutil.rb: introduce EnvUtil.apply_timeout_scale to use
this scale from outside.
* test/ruby/test_thread.rb (test_fork_in_thread): respect timeout scale.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/lib/envutil.rb | 16 | ||||
-rw-r--r-- | test/ruby/test_thread.rb | 4 |
2 files changed, 14 insertions, 6 deletions
diff --git a/test/lib/envutil.rb b/test/lib/envutil.rb index e6cdd776e2..152ea741c9 100644 --- a/test/lib/envutil.rb +++ b/test/lib/envutil.rb @@ -46,16 +46,24 @@ module EnvUtil attr_accessor :subprocess_timeout_scale end + def apply_timeout_scale(t) + if scale = EnvUtil.subprocess_timeout_scale + t * scale + else + t + end + end + module_function :apply_timeout_scale + def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr = false, encoding: nil, timeout: 10, reprieve: 1, timeout_error: Timeout::Error, stdout_filter: nil, stderr_filter: nil, signal: :TERM, rubybin: EnvUtil.rubybin, **opt) - if scale = EnvUtil.subprocess_timeout_scale - timeout *= scale if timeout - reprieve *= scale if reprieve - end + timeout = apply_timeout_scale(timeout) + reprieve = apply_timeout_scale(reprieve) if reprieve + in_c, in_p = IO.pipe out_p, out_c = IO.pipe if capture_stdout err_p, err_c = IO.pipe if capture_stderr && capture_stderr != :merge_to_stdout diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index a4d70c4607..529c52f4ba 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -1135,9 +1135,9 @@ q.pop end Process.wait2(f.pid) end - unless th.join(3) + unless th.join(EnvUtil.apply_timeout_scale(3)) Process.kill(:QUIT, f.pid) - Process.kill(:KILL, f.pid) unless th.join(1) + Process.kill(:KILL, f.pid) unless th.join(EnvUtil.apply_timeout_scale(1)) end _, status = th.value output = f.read |