mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
20a82f8839
commit
7d52ed594e
2 changed files with 14 additions and 6 deletions
|
@ -46,16 +46,24 @@ module EnvUtil
|
||||||
attr_accessor :subprocess_timeout_scale
|
attr_accessor :subprocess_timeout_scale
|
||||||
end
|
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,
|
def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr = false,
|
||||||
encoding: nil, timeout: 10, reprieve: 1, timeout_error: Timeout::Error,
|
encoding: nil, timeout: 10, reprieve: 1, timeout_error: Timeout::Error,
|
||||||
stdout_filter: nil, stderr_filter: nil,
|
stdout_filter: nil, stderr_filter: nil,
|
||||||
signal: :TERM,
|
signal: :TERM,
|
||||||
rubybin: EnvUtil.rubybin,
|
rubybin: EnvUtil.rubybin,
|
||||||
**opt)
|
**opt)
|
||||||
if scale = EnvUtil.subprocess_timeout_scale
|
timeout = apply_timeout_scale(timeout)
|
||||||
timeout *= scale if timeout
|
reprieve = apply_timeout_scale(reprieve) if reprieve
|
||||||
reprieve *= scale if reprieve
|
|
||||||
end
|
|
||||||
in_c, in_p = IO.pipe
|
in_c, in_p = IO.pipe
|
||||||
out_p, out_c = IO.pipe if capture_stdout
|
out_p, out_c = IO.pipe if capture_stdout
|
||||||
err_p, err_c = IO.pipe if capture_stderr && capture_stderr != :merge_to_stdout
|
err_p, err_c = IO.pipe if capture_stderr && capture_stderr != :merge_to_stdout
|
||||||
|
|
|
@ -1135,9 +1135,9 @@ q.pop
|
||||||
end
|
end
|
||||||
Process.wait2(f.pid)
|
Process.wait2(f.pid)
|
||||||
end
|
end
|
||||||
unless th.join(3)
|
unless th.join(EnvUtil.apply_timeout_scale(3))
|
||||||
Process.kill(:QUIT, f.pid)
|
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
|
end
|
||||||
_, status = th.value
|
_, status = th.value
|
||||||
output = f.read
|
output = f.read
|
||||||
|
|
Loading…
Reference in a new issue