diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-24 00:51:01 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-24 00:51:01 +0000 |
commit | 52acc428f0d455bcbb2733f9ae0c83db180f8a1e (patch) | |
tree | 08bd87c010886ee6716dfe5a6b6d08a705b6155d /test/lib | |
parent | 642b3a260bda7e4b8380bcc797efce547879295e (diff) | |
download | ruby-52acc428f0d455bcbb2733f9ae0c83db180f8a1e.tar.gz |
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
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/envutil.rb | 8 | ||||
-rw-r--r-- | test/lib/test/unit.rb | 16 |
2 files changed, 24 insertions, 0 deletions
diff --git a/test/lib/envutil.rb b/test/lib/envutil.rb index 04fdc8d30f..89721754a2 100644 --- a/test/lib/envutil.rb +++ b/test/lib/envutil.rb @@ -40,12 +40,20 @@ module EnvUtil DEFAULT_SIGNALS = Signal.list 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, 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 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/lib/test/unit.rb b/test/lib/test/unit.rb index f0bd26f32f..30ead34d0f 100644 --- a/test/lib/test/unit.rb +++ b/test/lib/test/unit.rb @@ -932,6 +932,21 @@ module Test 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 include Test::Unit::Options include Test::Unit::StatusLine @@ -942,6 +957,7 @@ module Test include Test::Unit::LoadPathOption include Test::Unit::GCStressOption include Test::Unit::ExcludesOption + include Test::Unit::SubprocessOption include Test::Unit::RunCount class << self; undef autorun; end |