diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-14 04:55:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-14 04:55:03 +0000 |
commit | 299401542908ecc0d3a6182166198b222b6421d5 (patch) | |
tree | fbd12a6640270a7c6c4e145bf7768c064a8fcce4 /test | |
parent | 806b84dc3b6ef94e79551a2ac2a2a108f120d0cf (diff) | |
download | ruby-299401542908ecc0d3a6182166198b222b6421d5.tar.gz |
webrick/test_utils.rb: no timeout during assertion
* test/webrick/test_utils.rb (assert_expired): separate negated
assertion and block timeout excecptions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/webrick/test_utils.rb | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/test/webrick/test_utils.rb b/test/webrick/test_utils.rb index 9d135f7855..1b154db040 100644 --- a/test/webrick/test_utils.rb +++ b/test/webrick/test_utils.rb @@ -2,10 +2,15 @@ require "test/unit" require "webrick/utils" class TestWEBrickUtils < Test::Unit::TestCase - def assert_expired(flag, m) - if m == WEBrick::Utils - handler = WEBrick::Utils::TimeoutHandler.instance - assert_equal(flag, handler.instance_variable_get(:@timeout_info).empty?) + def assert_expired(m) + Thread.handle_interrupt(Timeout::Error => :never, EX => :never) do + assert_empty(m::TimeoutHandler.instance.instance_variable_get(:@timeout_info)) + end + end + + def assert_not_expired(m) + Thread.handle_interrupt(Timeout::Error => :never, EX => :never) do + assert_not_empty(m::TimeoutHandler.instance.instance_variable_get(:@timeout_info)) end end @@ -14,7 +19,7 @@ class TestWEBrickUtils < Test::Unit::TestCase def test_no_timeout m = WEBrick::Utils assert_equal(:foo, m.timeout(10){ :foo }) - assert_expired(true, m) + assert_expired(m) end def test_nested_timeout_outer @@ -23,26 +28,26 @@ class TestWEBrickUtils < Test::Unit::TestCase assert_raise(Timeout::Error){ m.timeout(0.02){ assert_raise(Timeout::Error){ m.timeout(0.01){ i += 1; sleep } } - assert_expired(false, m) + assert_not_expired(m) i += 1 sleep } } assert_equal(2, i) - assert_expired(true, m) + assert_expired(m) end def test_timeout_default_execption m = WEBrick::Utils assert_raise(Timeout::Error){ m.timeout(0.01){ sleep } } - assert_expired(true, m) + assert_expired(m) end def test_timeout_custom_exception m = WEBrick::Utils ex = EX assert_raise(ex){ m.timeout(0.01, ex){ sleep } } - assert_expired(true, m) + assert_expired(m) end def test_nested_timeout_inner_custom_exception @@ -56,7 +61,7 @@ class TestWEBrickUtils < Test::Unit::TestCase sleep } assert_equal(1, i) - assert_expired(true, m) + assert_expired(m) end def test_nested_timeout_outer_custom_exception @@ -70,7 +75,7 @@ class TestWEBrickUtils < Test::Unit::TestCase sleep } assert_equal(1, i) - assert_expired(true, m) + assert_expired(m) end def test_create_listeners |