diff --git a/.document b/.document index f7b50c8..f9b3f9f 100644 --- a/.document +++ b/.document @@ -1,6 +1,2 @@ COPYING -ChangeLog README.md -_doc/ -ext/ -logs/ChangeLog-* diff --git a/.github/workflows/push_gem.yml b/.github/workflows/push_gem.yml index 86fcb44..ffbe50f 100644 --- a/.github/workflows/push_gem.yml +++ b/.github/workflows/push_gem.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [ ruby, jruby ] + ruby: [ ruby ] environment: name: rubygems.org diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a98abe8..c714198 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,18 +16,8 @@ jobs: runs-on: ${{ matrix.os }}-latest strategy: matrix: - ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }} - os: [ ubuntu, macos, windows ] - include: - - ruby: 'jruby' - os: 'ubuntu' - platform: 'java' - continue-on-error: true - upload: true - - ruby: 'jruby-head' - os: 'ubuntu' - platform: 'java' - continue-on-error: true + ruby: [ '${{ needs.ruby-versions.outputs.latest }}' ] + os: [ ubuntu ] steps: - uses: actions/checkout@v7 - name: Set up Ruby ${{ matrix.ruby }} @@ -38,7 +28,6 @@ jobs: run: bundle install - name: Run test run: bundle exec rake - continue-on-error: ${{ matrix.continue-on-error }} - id: build run: | rake build:sha512 @@ -46,8 +35,8 @@ jobs: gem=${GITHUB_REPOSITORY#*/} echo "pkg=$gem-${RUNNING_OS%-*}" >> $GITHUB_OUTPUT env: - RUNNING_OS: ${{matrix.platform || matrix.os}} - if: ${{matrix.ruby == needs.ruby-versions.outputs.latest || matrix.upload}} + RUNNING_OS: ${{matrix.os}} + if: ${{matrix.ruby == needs.ruby-versions.outputs.latest}} shell: bash - name: Upload package uses: actions/upload-artifact@v7 diff --git a/.gitignore b/.gitignore index b69ecaa..4aaf566 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,4 @@ /.bundle/ -/.yardoc -/_yardoc/ -/coverage/ /doc/ -/logs/ /pkg/ -/spec/reports/ /tmp/ -*.bundle -*.dll -*.so -*.jar -ChangeLog diff --git a/Gemfile b/Gemfile index c38b903..ccdcd72 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,4 @@ gemspec group :development do gem "rake" - gem "test-unit" - gem "test-unit-ruby-core" end diff --git a/README.md b/README.md index dca9f48..c60c65d 100644 --- a/README.md +++ b/README.md @@ -3,29 +3,3 @@ This gem provides the feature for waiting until IO is readable or writable without blocking. **Note:** This gem is empty and deprecated. All functionality was moved into core Ruby as of version 3.2. - -## Installation - -Add this line to your application's Gemfile: - -```ruby -gem 'io-wait' -``` - -And then execute: - - $ bundle install - -Or install it yourself as: - - $ gem install io-wait - -## Development - -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. - -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). - -## Contributing - -Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/io-wait. diff --git a/Rakefile b/Rakefile index 12996aa..3cd7edc 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,3 @@ require "bundler/gem_tasks" -require "rake/testtask" -Rake::TestTask.new(:test) do |t| - t.libs = ["lib", "test/lib"] - t.ruby_opts << "-rhelper" - t.options = "--ignore-name=/ungetc_in_text/" - t.test_files = FileList["test/**/test_*.rb"] -end - -task :default => :test +task :default => :build diff --git a/_doc/io.rb b/_doc/io.rb deleted file mode 100644 index da9f79e..0000000 --- a/_doc/io.rb +++ /dev/null @@ -1,3 +0,0 @@ -# See {IO}[https://docs.ruby-lang.org/en/master/IO.html] -class IO -end diff --git a/rakelib/changelogs.rake b/rakelib/changelogs.rake deleted file mode 100644 index df72f9d..0000000 --- a/rakelib/changelogs.rake +++ /dev/null @@ -1,34 +0,0 @@ -task "build" => "changelogs" - -changelog = proc do |output, ver = nil, prev = nil| - ver &&= Gem::Version.new(ver) - range = [[prev], [ver, "HEAD"]].map {|ver, branch| ver ? "v#{ver.to_s}" : branch}.compact.join("..") - IO.popen(%W[git log --format=fuller --topo-order --no-merges #{range}]) do |log| - line = log.gets - FileUtils.mkpath(File.dirname(output)) - File.open(output, "wb") do |f| - f.print "-*- coding: utf-8 -*-\n\n", line - log.each_line do |line| - line.sub!(/^(?!:)(?:Author|Commit)?(?:Date)?: /, ' \&') - line.sub!(/ +$/, '') - f.print(line) - end - end - end -end - -tags = IO.popen(%w[git tag -l v[0-9]*]).grep(/v(.*)/) {$1} -tags.sort_by! {|tag| tag.scan(/\d+/).map(&:to_i)} -tags.inject(nil) do |prev, tag| - task("logs/ChangeLog-#{tag}") {|t| changelog[t.name, tag, prev]} - tag -end - -desc "Make ChangeLog" -task "ChangeLog", [:ver, :prev] do |t, ver: nil, prev: tags.last| - changelog[t.name, ver, prev] -end - -changelogs = ["ChangeLog", *tags.map {|tag| "logs/ChangeLog-#{tag}"}] -task "changelogs" => changelogs -CLOBBER.concat(changelogs) << "logs" diff --git a/rakelib/sync_tool.rake b/rakelib/sync_tool.rake deleted file mode 100644 index a687938..0000000 --- a/rakelib/sync_tool.rake +++ /dev/null @@ -1,6 +0,0 @@ -task :sync_tool do - require 'fileutils' - FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib" - FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib" - FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib" -end diff --git a/test/io/wait/test_io_wait.rb b/test/io/wait/test_io_wait.rb deleted file mode 100644 index c532638..0000000 --- a/test/io/wait/test_io_wait.rb +++ /dev/null @@ -1,180 +0,0 @@ -# -*- coding: us-ascii -*- -# frozen_string_literal: false -require 'test/unit' -require 'timeout' -require 'socket' - -class TestIOWait < Test::Unit::TestCase - - def setup - if /mswin|mingw/ =~ RUBY_PLATFORM - @r, @w = Socket.pair(Socket::AF_INET, Socket::SOCK_STREAM, 0) - else - @r, @w = IO.pipe - end - end - - def teardown - @r.close unless @r.closed? - @w.close unless @w.closed? - end - - def test_wait - omit 'unstable on MinGW' if /mingw/ =~ RUBY_PLATFORM - assert_nil @r.wait(0) - @w.syswrite "." - IO.select([@r]) - assert_equal @r, @r.wait(0) - end - - def test_wait_buffered - @w.syswrite ".\n!" - assert_equal ".\n", @r.gets - assert_equal true, @r.wait(0) - end - - def test_wait_forever - q = Thread::Queue.new - th = Thread.new { q.pop; @w.syswrite "." } - q.push(true) - assert_equal @r, @r.wait - ensure - th.join - end - - def test_wait_eof - q = Thread::Queue.new - th = Thread.new { q.pop; @w.close } - ret = nil - assert_nothing_raised(Timeout::Error) do - q.push(true) - t = EnvUtil.apply_timeout_scale(1) - Timeout.timeout(t) { ret = @r.wait } - end - assert_equal @r, ret - ensure - th.join - end - - def test_wait_readable - assert_nil @r.wait_readable(0) - @w.syswrite "." - IO.select([@r]) - assert_equal @r, @r.wait_readable(0) - end - - def test_wait_readable_buffered - @w.syswrite ".\n!" - assert_equal ".\n", @r.gets - assert_equal true, @r.wait_readable(0) - end - - def test_wait_readable_forever - q = Thread::Queue.new - th = Thread.new { q.pop; @w.syswrite "." } - q.push(true) - assert_equal @r, @r.wait_readable - ensure - th.join - end - - def test_wait_readable_eof - q = Thread::Queue.new - th = Thread.new { q.pop; @w.close } - ret = nil - assert_nothing_raised(Timeout::Error) do - q.push(true) - t = EnvUtil.apply_timeout_scale(1) - Timeout.timeout(t) { ret = @r.wait_readable } - end - assert_equal @r, ret - ensure - th.join - end - - def test_wait_writable - assert_equal @w, @w.wait_writable - end - - def test_wait_writable_timeout - assert_equal @w, @w.wait_writable(0.01) - written = fill_pipe - assert_nil @w.wait_writable(0.01) - @r.read(written) - assert_equal @w, @w.wait_writable(0.01) - end - - def test_wait_writable_EPIPE - fill_pipe - @r.close - assert_equal @w, @w.wait_writable - end - - def test_wait_writable_closed - @w.close - assert_raise(IOError) { @w.wait_writable } - end - - def test_wait_readwrite - assert_equal @r.wait(0, :write), @r.wait(0, :read_write) - end - - def test_wait_readwrite_timeout - assert_equal @w, @w.wait(0.01, :read_write) - written = fill_pipe - if /aix/ =~ RUBY_PLATFORM - # IO#wait internally uses select(2) on AIX. - # AIX's select(2) returns "readable" for the write-side fd - # of a pipe, so @w.wait(0.01, :read_write) does not return nil. - assert_equal @w, @w.wait(0.01, :read_write) - else - assert_nil @w.wait(0.01, :read_write) - end - @r.read(written) - assert_equal @w, @w.wait(0.01, :read_write) - end - - def test_wait_mask_writable - omit("Missing IO::WRITABLE!") unless IO.const_defined?(:WRITABLE) - assert_equal IO::WRITABLE, @w.wait(IO::WRITABLE, 0) - end - - def test_wait_mask_readable - omit("Missing IO::READABLE!") unless IO.const_defined?(:READABLE) - @w.write("Hello World\n" * 3) - assert_equal IO::READABLE, @r.wait(IO::READABLE, 0) - - @r.gets - assert_equal IO::READABLE, @r.wait(IO::READABLE, 0) - end - - def test_wait_mask_zero - omit("Missing IO::WRITABLE!") unless IO.const_defined?(:WRITABLE) - assert_raise(ArgumentError) do - @w.wait(0, 0) - end - end - - def test_wait_mask_negative - omit("Missing IO::WRITABLE!") unless IO.const_defined?(:WRITABLE) - assert_raise(ArgumentError) do - @w.wait(-6, 0) - end - end - -private - - def fill_pipe - written = 0 - buf = " " * 4096 - begin - written += @w.write_nonblock(buf) - rescue Errno::EAGAIN, Errno::EWOULDBLOCK - return written - end while true - end - - def sleep(time) - super EnvUtil.apply_timeout_scale(time) - end -end if IO.method_defined?(:wait) diff --git a/test/io/wait/test_io_wait_uncommon.rb b/test/io/wait/test_io_wait_uncommon.rb deleted file mode 100644 index 15b13b5..0000000 --- a/test/io/wait/test_io_wait_uncommon.rb +++ /dev/null @@ -1,92 +0,0 @@ -# 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 -class TestIOWaitUncommon < Test::Unit::TestCase - def test_tty_wait - check_dev('/dev/tty', mode: 'w+') do |tty| - assert_include [ nil, tty ], tty.wait_readable(0) - assert_equal tty, tty.wait_writable(1), 'portability test' - end - end - - def test_fifo_wait - omit 'no mkfifo' unless File.respond_to?(:mkfifo) && IO.const_defined?(:NONBLOCK) - require 'tmpdir' - Dir.mktmpdir('rubytest-fifo') do |dir| - fifo = "#{dir}/fifo" - assert_equal 0, File.mkfifo(fifo) - rd = Thread.new { File.open(fifo, IO::RDONLY|IO::NONBLOCK) } - begin - wr = File.open(fifo, IO::WRONLY|IO::NONBLOCK) - rescue Errno::ENXIO - Thread.pass - end until wr - assert_instance_of File, rd.value - assert_instance_of File, wr - rd = rd.value - assert_nil rd.wait_readable(0) - assert_same wr, wr.wait_writable(0) - wr.syswrite 'hi' - assert_same rd, rd.wait_readable(1) - wr.close - assert_equal 'hi', rd.gets - rd.close - end - end - - # used to find portability problems because some ppoll implementations - # are incomplete and do not work for certain "file" types - def check_dev(dev, m = :wait_readable, mode: m == :wait_readable ? 'r' : 'w', &block) - begin - fp = File.open(dev, mode) - rescue Errno::ENOENT - return # Ignore silently - rescue SystemCallError => e - omit "#{dev} could not be opened #{e.message} (#{e.class})" - end - if block - yield fp - else - assert_same fp, fp.__send__(m) - end - ensure - fp&.close - end - - def test_wait_readable_urandom - check_dev('/dev/urandom') - end - - def test_wait_readable_random - check_dev('/dev/random') do |fp| - assert_nothing_raised do - fp.wait_readable(0) - end - end - end - - def test_wait_readable_zero - check_dev('/dev/zero') - end - - def test_wait_writable_null - check_dev(IO::NULL, :wait_writable) - end - - def test_after_ungetc_wait_readable - check_dev(IO::NULL, mode: "r") {|fp| - fp.ungetc(?a) - assert_predicate fp, :wait_readable - } - end - - def test_after_ungetc_in_text_wait_readable - check_dev(IO::NULL, mode: "rt") {|fp| - fp.ungetc(?a) - assert_predicate fp, :wait_readable - } - end -end diff --git a/test/io/wait/test_ractor.rb b/test/io/wait/test_ractor.rb deleted file mode 100644 index c77a29b..0000000 --- a/test/io/wait/test_ractor.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true -require 'test/unit' -require 'rbconfig' - -class TestIOWaitInRactor < Test::Unit::TestCase - def test_ractor - ext = "/io/wait.#{RbConfig::CONFIG['DLEXT']}" - path = $".find {|path| path.end_with?(ext)} - assert_in_out_err(%W[-r#{path}], <<-"end;", ["true"], []) - class Ractor - alias value take - end unless Ractor.method_defined? :value # compat with Ruby 3.4 and olders - - $VERBOSE = nil - r = Ractor.new do - $stdout.equal?($stdout.wait_writable) - end - puts r.value - end; - end -end if defined? Ractor diff --git a/test/lib/helper.rb b/test/lib/helper.rb deleted file mode 100644 index bef8234..0000000 --- a/test/lib/helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "test/unit" -require "core_assertions" - -Test::Unit::TestCase.include Test::Unit::CoreAssertions