mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
This reverts commit 13f8521c63.
http://rubyci.s3.amazonaws.com/solaris11-gcc/ruby-master/log/20210727T230009Z.fail.html.gz
http://rubyci.s3.amazonaws.com/solaris11-sunc/ruby-master/log/20210728T000009Z.fail.html.gz
This revert is to confirm whether the commit is the cause.
If the failures consistently occur after this revert, I'll
reintroduce the commit.
69 lines
1.3 KiB
Ruby
69 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
require "test/unit"
|
|
require_relative 'scheduler'
|
|
|
|
class TestFiberThread < Test::Unit::TestCase
|
|
def test_thread_join
|
|
thread = Thread.new do
|
|
scheduler = Scheduler.new
|
|
Fiber.set_scheduler scheduler
|
|
|
|
result = nil
|
|
Fiber.schedule do
|
|
result = Thread.new{:done}.value
|
|
end
|
|
|
|
scheduler.run
|
|
result
|
|
end
|
|
|
|
assert_equal :done, thread.value
|
|
end
|
|
|
|
def test_thread_join_blocking
|
|
thread = Thread.new do
|
|
scheduler = Scheduler.new
|
|
Fiber.set_scheduler scheduler
|
|
|
|
result = nil
|
|
Fiber.schedule do
|
|
Fiber.new(blocking: true) do
|
|
# This can deadlock if the blocking state is not taken into account:
|
|
Thread.new do
|
|
sleep(0)
|
|
result = :done
|
|
end.join
|
|
end.resume
|
|
end
|
|
|
|
scheduler.run
|
|
result
|
|
end
|
|
|
|
assert_equal :done, thread.value
|
|
end
|
|
|
|
def test_broken_unblock
|
|
thread = Thread.new do
|
|
Thread.current.report_on_exception = false
|
|
|
|
scheduler = BrokenUnblockScheduler.new
|
|
|
|
Fiber.set_scheduler scheduler
|
|
|
|
Fiber.schedule do
|
|
Thread.new{
|
|
Thread.current.report_on_exception = false
|
|
}.join
|
|
end
|
|
|
|
scheduler.run
|
|
ensure
|
|
scheduler.close
|
|
end
|
|
|
|
assert_raise(RuntimeError) do
|
|
thread.join
|
|
end
|
|
end
|
|
end
|