1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/fiber/test_process.rb
Nobuyoshi Nakada d650b17686
rb_fiber_terminate must not return [Bug #18497]
In a forked process from a fiber, the fiber becomes the only
fiber, `fiber_switch` does nothing as there is no other fibers,
`rb_fiber_terminate` does not terminate the fiber.  In that case,
reaches the end of `fiber_entry` finaly, which is declared as
"COROUTINE" and should never return.
2022-01-19 19:57:16 +09:00

51 lines
1 KiB
Ruby

# frozen_string_literal: true
require 'test/unit'
require_relative 'scheduler'
class TestFiberProcess < Test::Unit::TestCase
def test_process_wait
Thread.new do
scheduler = Scheduler.new
Fiber.set_scheduler scheduler
Fiber.schedule do
pid = Process.spawn("true")
Process.wait(pid)
# TODO test that scheduler was invoked.
assert_predicate $?, :success?
end
end.join
end
def test_system
Thread.new do
scheduler = Scheduler.new
Fiber.set_scheduler scheduler
Fiber.schedule do
system("true")
# TODO test that scheduler was invoked (currently it's not).
assert_predicate $?, :success?
end
end.join
end
def test_fork
omit 'fork not supported' unless Process.respond_to?(:fork)
Thread.new do
scheduler = Scheduler.new
Fiber.set_scheduler scheduler
Fiber.schedule do
pid = Process.fork {}
Process.wait(pid)
assert_predicate $?, :success?
end
end.join
end
end