test/unit.rb: --subprocess-timeout-scale option
* test/lib/envutil.rb (EnvUtil#invoke_ruby): add subprocess timeout scaling factor. * test/lib/test/unit.rb (Test::Unit::SubprocessOption): add --subprocess-timeout-scale option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
642b3a260b
commit
52acc428f0
@ -40,12 +40,20 @@ module EnvUtil
|
|||||||
DEFAULT_SIGNALS = Signal.list
|
DEFAULT_SIGNALS = Signal.list
|
||||||
DEFAULT_SIGNALS.delete("TERM") if /mswin|mingw/ =~ RUBY_PLATFORM
|
DEFAULT_SIGNALS.delete("TERM") if /mswin|mingw/ =~ RUBY_PLATFORM
|
||||||
|
|
||||||
|
class << self
|
||||||
|
attr_accessor :subprocess_timeout_scale
|
||||||
|
end
|
||||||
|
|
||||||
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 *= scale if timeout
|
||||||
|
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
|
||||||
|
@ -932,6 +932,21 @@ module Test
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module SubprocessOption
|
||||||
|
def setup_options(parser, options)
|
||||||
|
super
|
||||||
|
parser.separator "subprocess options:"
|
||||||
|
parser.on '--subprocess-timeout-scale NUM', "Scale subprocess timeout", Float do |scale|
|
||||||
|
raise OptionParser::InvalidArgument, "timeout scale must be positive" unless scale > 0
|
||||||
|
options[:timeout_scale] = scale
|
||||||
|
end
|
||||||
|
if scale = options[:timeout_scale] or
|
||||||
|
(scale = ENV["RUBY_TEST_SUBPROCESS_TIMEOUT_SCALE"] and (scale = scale.to_f) > 0)
|
||||||
|
EnvUtil.subprocess_timeout_scale = scale
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Runner < MiniTest::Unit # :nodoc: all
|
class Runner < MiniTest::Unit # :nodoc: all
|
||||||
include Test::Unit::Options
|
include Test::Unit::Options
|
||||||
include Test::Unit::StatusLine
|
include Test::Unit::StatusLine
|
||||||
@ -942,6 +957,7 @@ module Test
|
|||||||
include Test::Unit::LoadPathOption
|
include Test::Unit::LoadPathOption
|
||||||
include Test::Unit::GCStressOption
|
include Test::Unit::GCStressOption
|
||||||
include Test::Unit::ExcludesOption
|
include Test::Unit::ExcludesOption
|
||||||
|
include Test::Unit::SubprocessOption
|
||||||
include Test::Unit::RunCount
|
include Test::Unit::RunCount
|
||||||
|
|
||||||
class << self; undef autorun; end
|
class << self; undef autorun; end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user