Skip to content

Commit

Permalink
Remove require 'io/wait' where it's no longer necessary. (#6932)
Browse files Browse the repository at this point in the history
* Remove `require 'io/wait'` as it's part of core now.

* Update ruby specs using version gates.

* Add note about why it's conditional.
  • Loading branch information
ioquatix committed Dec 14, 2022
1 parent 55f56eb commit d20bd06
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 12 deletions.
6 changes: 5 additions & 1 deletion ext/socket/lib/socket.rb
@@ -1,7 +1,11 @@
# frozen_string_literal: true

require 'socket.so'
require 'io/wait' unless ::IO.method_defined?(:wait_readable, false)

unless IO.method_defined?(:wait_writable, false)
# It's only required on older Rubies < v3.2:
require 'io/wait'
end

class Addrinfo
# creates an Addrinfo object from the arguments.
Expand Down
4 changes: 3 additions & 1 deletion spec/ruby/library/io-wait/wait_readable_spec.rb
@@ -1,6 +1,8 @@
require_relative '../../spec_helper'

require 'io/wait'
ruby_version_is ''...'3.2' do
require 'io/wait'
end

describe "IO#wait_readable" do
before :each do
Expand Down
4 changes: 3 additions & 1 deletion spec/ruby/library/io-wait/wait_writable_spec.rb
@@ -1,6 +1,8 @@
require_relative '../../spec_helper'

require 'io/wait'
ruby_version_is ''...'3.2' do
require 'io/wait'
end

describe "IO#wait_writable" do
it "waits for the IO to become writable with no timeout" do
Expand Down
1 change: 0 additions & 1 deletion test/-ext-/thread_fd/test_thread_fd_close.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'test/unit'
require '-test-/thread_fd'
require 'io/wait'

class TestThreadFdClose < Test::Unit::TestCase

Expand Down
7 changes: 3 additions & 4 deletions test/io/wait/test_io_wait.rb
Expand Up @@ -3,10 +3,9 @@
require 'test/unit'
require 'timeout'
require 'socket'
begin
require 'io/wait'
rescue LoadError
end

# For `IO#ready?` and `IO#nread`:
require 'io/wait'

class TestIOWait < Test::Unit::TestCase

Expand Down
1 change: 0 additions & 1 deletion test/io/wait/test_io_wait_uncommon.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
require 'test/unit'
require 'io/wait'

# test uncommon device types to check portability problems
# We may optimize IO#wait_*able for non-Linux kernels in the future
Expand Down
1 change: 0 additions & 1 deletion test/io/wait/test_ractor.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'test/unit'
require 'rbconfig'
require 'io/wait'

class TestIOWaitInRactor < Test::Unit::TestCase
def test_ractor
Expand Down
1 change: 0 additions & 1 deletion test/ruby/test_process.rb
Expand Up @@ -3,7 +3,6 @@
require 'test/unit'
require 'tempfile'
require 'timeout'
require 'io/wait'
require 'rbconfig'

class TestProcess < Test::Unit::TestCase
Expand Down
1 change: 0 additions & 1 deletion tool/lib/webrick/httpserver.rb
Expand Up @@ -9,7 +9,6 @@
#
# $IPR: httpserver.rb,v 1.63 2002/10/01 17:16:32 gotoyuzo Exp $

require 'io/wait'
require_relative 'server'
require_relative 'httputils'
require_relative 'httpstatus'
Expand Down

0 comments on commit d20bd06

Please sign in to comment.