From 3ba667b46f3d0e7dcfaeed40b435a0a3b9cf0d85 Mon Sep 17 00:00:00 2001 From: Herwin Date: Sun, 18 Jan 2026 19:48:43 +0100 Subject: [PATCH 1/2] Add specs for IO.select with Float::INFINITY as timeout argument --- core/io/select_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/io/select_spec.rb b/core/io/select_spec.rb index 3893e7620f..3872bb4af2 100644 --- a/core/io/select_spec.rb +++ b/core/io/select_spec.rb @@ -162,3 +162,19 @@ t.join end end + +ruby_version_is "4.0" do + describe "IO.select when passed Float::INFINITY for timeout" do + it "sleeps forever and sets the thread status to 'sleep'" do + t = Thread.new do + IO.select(nil, nil, nil, Float::INFINITY) + end + + Thread.pass while t.status && t.status != "sleep" + t.join unless t.status + t.status.should == "sleep" + t.kill + t.join + end + end +end From a2d09e25bae3ce9f710246e3e28a292fb802c415 Mon Sep 17 00:00:00 2001 From: Herwin Date: Sun, 18 Jan 2026 19:53:02 +0100 Subject: [PATCH 2/2] Remove duplication from IO.select with infinite timeout --- core/io/select_spec.rb | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/core/io/select_spec.rb b/core/io/select_spec.rb index 3872bb4af2..9fdb7e12c9 100644 --- a/core/io/select_spec.rb +++ b/core/io/select_spec.rb @@ -149,25 +149,11 @@ end end -describe "IO.select when passed nil for timeout" do - it "sleeps forever and sets the thread status to 'sleep'" do - t = Thread.new do - IO.select(nil, nil, nil, nil) - end - - Thread.pass while t.status && t.status != "sleep" - t.join unless t.status - t.status.should == "sleep" - t.kill - t.join - end -end - -ruby_version_is "4.0" do - describe "IO.select when passed Float::INFINITY for timeout" do +describe "IO.select with infinite timeout" do + describe :io_select_infinite_timeout, shared: true do it "sleeps forever and sets the thread status to 'sleep'" do t = Thread.new do - IO.select(nil, nil, nil, Float::INFINITY) + IO.select(nil, nil, nil, @method) end Thread.pass while t.status && t.status != "sleep" @@ -177,4 +163,14 @@ t.join end end + + describe "IO.select when passed nil for timeout" do + it_behaves_like :io_select_infinite_timeout, nil + end + + ruby_version_is "4.0" do + describe "IO.select when passed Float::INFINITY for timeout" do + it_behaves_like :io_select_infinite_timeout, Float::INFINITY + end + end end