mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Improve timeout tests.
This commit is contained in:
parent
511acba4ae
commit
af1c587546
Notes:
git
2021-03-30 14:39:03 +09:00
1 changed files with 20 additions and 1 deletions
|
@ -14,7 +14,7 @@ class TestFiberTimeout < Test::Unit::TestCase
|
|||
|
||||
Fiber.schedule do
|
||||
begin
|
||||
Timeout.timeout(0.01) do
|
||||
Timeout.timeout(0.001) do
|
||||
sleep(1)
|
||||
end
|
||||
rescue
|
||||
|
@ -27,4 +27,23 @@ class TestFiberTimeout < Test::Unit::TestCase
|
|||
|
||||
assert_kind_of(Timeout::Error, error)
|
||||
end
|
||||
|
||||
MESSAGE = "Hello World"
|
||||
|
||||
def test_timeout_on_main_fiber
|
||||
message = nil
|
||||
|
||||
thread = Thread.new do
|
||||
scheduler = Scheduler.new
|
||||
Fiber.set_scheduler scheduler
|
||||
|
||||
Timeout.timeout(1) do
|
||||
message = MESSAGE
|
||||
end
|
||||
end
|
||||
|
||||
thread.join
|
||||
|
||||
assert_equal MESSAGE, message
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue