[前][次][番号順一覧][スレッド一覧]

ruby-changes:71626

From: Yusuke <ko1@a...>
Date: Tue, 5 Apr 2022 14:08:35 +0900 (JST)
Subject: [ruby-changes:71626] 1ac839dc3a (master): Apply timescale configuration for tests of Regexp.timeout

https://git.ruby-lang.org/ruby.git/commit/?id=1ac839dc3a

From 1ac839dc3a70fa5dd18e67a37026234514b04b83 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Tue, 5 Apr 2022 14:07:25 +0900
Subject: Apply timescale configuration for tests of Regexp.timeout

---
 test/ruby/test_regexp.rb | 17 +++++++++++------
 1 file 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L1464
   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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L1476
       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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L1496
       end
       t = Time.now - t
 
-      assert_in_delta(0.2, t, 0.1)
+      assert_in_delta(timeout, t, timeout / 2)
     end;
   end
 end
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]