diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2022-04-05 14:07:25 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2022-04-05 14:08:07 +0900 |
commit | 1ac839dc3a70fa5dd18e67a37026234514b04b83 (patch) | |
tree | 4f21cc51a736c07e2d4b1289c733d0f276fafc8a /test/ruby | |
parent | 18044f4fbbfdef27b1e41c109d63c276026008c5 (diff) |
Apply timescale configuration for tests of Regexp.timeout
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_regexp.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 4e840f23ad..4be6d7bec7 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1464,8 +1464,10 @@ class TestRegexp < Test::Unit::TestCase def test_s_timeout assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}") begin; - Regexp.timeout = 0.2 - assert_equal(0.2, Regexp.timeout) + timeout = EnvUtil.apply_timeout_scale(0.2) + + Regexp.timeout = timeout + assert_equal(timeout, Regexp.timeout) t = Time.now assert_raise_with_message(Regexp::TimeoutError, "regexp match timeout") do @@ -1474,16 +1476,19 @@ class TestRegexp < Test::Unit::TestCase end t = Time.now - t - assert_in_delta(0.2, t, 0.1) + assert_in_delta(timeout, t, timeout / 2) end; end def test_timeout assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}") begin; - Regexp.timeout = 3 # This should be ignored + dummy_timeout = EnvUtil.apply_timeout_scale(10) + timeout = EnvUtil.apply_timeout_scale(0.2) + + Regexp.timeout = dummy_timeout # This should be ignored - re = Regexp.new("^a*b?a*$", timeout: 0.2) + re = Regexp.new("^a*b?a*$", timeout: timeout) t = Time.now assert_raise_with_message(Regexp::TimeoutError, "regexp match timeout") do @@ -1491,7 +1496,7 @@ class TestRegexp < Test::Unit::TestCase end t = Time.now - t - assert_in_delta(0.2, t, 0.1) + assert_in_delta(timeout, t, timeout / 2) end; end end |