mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
Read RUBY_TEST_TIMEOUT_SCALE in EnvUtil
test-bundled-gems runs the tests with the test-unit gem, which loads EnvUtil through gems/lib but never goes through tool/lib/test/unit.rb, so the scale was ignored there. `--timeout-scale` still takes precedence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d06e3f2a5d
commit
fa6ffde024
3 files changed
+10
-3
Notes:
git
2026-10-03 21:22:30 +00:00
No files matched your search
@@ -81,6 +81,11 @@ module EnvUtil
|
||||
self.timeout_scale = 10
|
||||
end
|
||||
|
||||
# Read here so that runners other than tool/lib/test/unit.rb, such as
|
||||
# the test-unit gem in test-bundled-gems, also scale timeouts.
|
||||
scale = (ENV["RUBY_TEST_TIMEOUT_SCALE"] || ENV["RUBY_TEST_SUBPROCESS_TIMEOUT_SCALE"]).to_f
|
||||
self.timeout_scale = scale if scale > 0
|
||||
|
||||
def apply_timeout_scale(t)
|
||||
if scale = EnvUtil.timeout_scale
|
||||
t * scale
|
||||
|
||||
@@ -1383,9 +1383,7 @@ module Test
|
||||
end
|
||||
|
||||
def non_options(files, options)
|
||||
if scale = options[:timeout_scale] or
|
||||
(scale = ENV["RUBY_TEST_TIMEOUT_SCALE"] || ENV["RUBY_TEST_SUBPROCESS_TIMEOUT_SCALE"] and
|
||||
(scale = scale.to_f) > 0)
|
||||
if scale = options[:timeout_scale]
|
||||
EnvUtil.timeout_scale = scale
|
||||
end
|
||||
super
|
||||
|
||||
@@ -17,6 +17,10 @@ class TestEnvUtil < Test::Unit::TestCase
|
||||
EnvUtil.timeout_scale = original_scale
|
||||
end
|
||||
|
||||
def test_timeout_scale_from_env
|
||||
assert_separately([{"RUBY_TEST_TIMEOUT_SCALE" => "2.5"}], "assert_equal(2.5, EnvUtil.timeout_scale)")
|
||||
end
|
||||
|
||||
def test_invoke_ruby_captures_output_and_status
|
||||
stdout, stderr, status = EnvUtil.invoke_ruby(
|
||||
["-e", "STDOUT.print('out'); STDERR.print('err')"],
|
||||
|
||||
Reference in new issue
Block a user