summaryrefslogtreecommitdiff
path: root/test/fiber/test_io.rb
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2022-10-15 19:59:04 +1300
committerGitHub <noreply@github.com>2022-10-15 19:59:04 +1300
commit8a420670a29a7c78c7201f678eb26528621bf39f (patch)
tree817a970087e36934979a4c9d4747f310b6224e42 /test/fiber/test_io.rb
parent1acc1a5c6d5d01b2822d7aa4356208095481724b (diff)
downloadruby-8a420670a29a7c78c7201f678eb26528621bf39f.tar.gz
Introduce `Fiber::Scheduler#io_select` hook for non-blocking `IO.select`. (#6559)
Diffstat (limited to 'test/fiber/test_io.rb')
-rw-r--r--test/fiber/test_io.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/fiber/test_io.rb b/test/fiber/test_io.rb
index 4252641cde..821a169e44 100644
--- a/test/fiber/test_io.rb
+++ b/test/fiber/test_io.rb
@@ -172,4 +172,26 @@ class TestFiberIO < Test::Unit::TestCase
assert_predicate(i, :closed?)
assert_predicate(o, :closed?)
end
+
+ def test_io_select
+ omit "UNIXSocket is not defined!" unless defined?(UNIXSocket)
+
+ UNIXSocket.pair do |r, w|
+ result = nil
+
+ thread = Thread.new do
+ scheduler = Scheduler.new
+ Fiber.set_scheduler scheduler
+
+ Fiber.schedule do
+ w.write("Hello World")
+ result = IO.select([r], [w])
+ end
+ end
+
+ thread.join
+
+ assert_equal [[r], [w], []], result
+ end
+ end
end