ruby-changes:46777
From: ko1 <ko1@a...>
Date: Fri, 26 May 2017 08:43:39 +0900 (JST)
Subject: [ruby-changes:46777] ko1:r58893 (trunk): use timeout scale.
ko1 2017-05-26 08:43:33 +0900 (Fri, 26 May 2017) New Revision: 58893 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58893 Log: 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. Modified files: trunk/test/lib/envutil.rb trunk/test/ruby/test_thread.rb Index: test/lib/envutil.rb =================================================================== --- test/lib/envutil.rb (revision 58892) +++ test/lib/envutil.rb (revision 58893) @@ -46,16 +46,24 @@ module EnvUtil https://github.com/ruby/ruby/blob/trunk/test/lib/envutil.rb#L46 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 Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 58892) +++ test/ruby/test_thread.rb (revision 58893) @@ -1135,9 +1135,9 @@ q.pop https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L1135 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/