test_timeout.rb: shorten waiting times
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d5e810dbd2
commit
765ec40120
@ -6,22 +6,22 @@ class TestTimeout < Test::Unit::TestCase
|
|||||||
def test_queue
|
def test_queue
|
||||||
q = Queue.new
|
q = Queue.new
|
||||||
assert_raise(Timeout::Error, "[ruby-dev:32935]") {
|
assert_raise(Timeout::Error, "[ruby-dev:32935]") {
|
||||||
timeout(0.1) { q.pop }
|
timeout(0.01) { q.pop }
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_timeout
|
def test_timeout
|
||||||
@flag = true
|
flag = true
|
||||||
Thread.start {
|
Thread.start {
|
||||||
sleep 0.1
|
sleep 0.01
|
||||||
@flag = false
|
flag = false
|
||||||
}
|
}
|
||||||
assert_nothing_raised("[ruby-dev:38319]") do
|
assert_nothing_raised("[ruby-dev:38319]") do
|
||||||
Timeout.timeout(1) {
|
Timeout.timeout(1) {
|
||||||
nil while @flag
|
Thread.pass while flag
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
assert !@flag, "[ruby-dev:38319]"
|
assert !flag, "[ruby-dev:38319]"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_cannot_convert_into_time_interval
|
def test_cannot_convert_into_time_interval
|
||||||
@ -34,7 +34,7 @@ class TestTimeout < Test::Unit::TestCase
|
|||||||
bug8730 = '[Bug #8730]'
|
bug8730 = '[Bug #8730]'
|
||||||
e = nil
|
e = nil
|
||||||
assert_raise_with_message(Timeout::Error, /execution expired/, bug8730) do
|
assert_raise_with_message(Timeout::Error, /execution expired/, bug8730) do
|
||||||
timeout 0.1 do
|
timeout 0.01 do
|
||||||
begin
|
begin
|
||||||
sleep 3
|
sleep 3
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@ -48,7 +48,7 @@ class TestTimeout < Test::Unit::TestCase
|
|||||||
exc = Class.new(RuntimeError)
|
exc = Class.new(RuntimeError)
|
||||||
e = nil
|
e = nil
|
||||||
assert_nothing_raised(exc) do
|
assert_nothing_raised(exc) do
|
||||||
timeout 0.1, exc do
|
timeout 0.01, exc do
|
||||||
begin
|
begin
|
||||||
sleep 3
|
sleep 3
|
||||||
rescue exc => e
|
rescue exc => e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user