summaryrefslogtreecommitdiff
path: root/test/ruby/test_io.rb
AgeCommit message (Collapse)Author
2023-09-28Move IO#readline to RubyAaron Patterson
This commit moves IO#readline to Ruby. In order to call C functions, keyword arguments must be converted to hashes. Prior to this commit, code like `io.readline(chomp: true)` would allocate a hash. This commits moves the keyword "denaturing" to Ruby, allowing us to send positional arguments to the C API and avoiding the hash allocation. Here is an allocation benchmark for the method: ``` x = GC.stat(:total_allocated_objects) File.open("/usr/share/dict/words") do |f| f.readline(chomp: true) until f.eof? end p ALLOCATIONS: GC.stat(:total_allocated_objects) - x ``` Before this commit, the output was this: ``` $ make run ./miniruby -I./lib -I. -I.ext/common -r./arm64-darwin22-fake ./test.rb {:ALLOCATIONS=>707939} ``` Now it is this: ``` $ make run ./miniruby -I./lib -I. -I.ext/common -r./arm64-darwin22-fake ./test.rb {:ALLOCATIONS=>471962} ``` [Bug #19890] [ruby-core:114803]
2023-08-10Deprecate Kernel#open and IO support for subprocess creation/forkingMike Dalessio
Deprecate Kernel#open and IO support for subprocess creation and forking. This deprecates subprocess creation and forking in - Kernel#open - URI.open - IO.binread - IO.foreach - IO.readlines - IO.read - IO.write This behavior is slated to be removed in Ruby 4.0 [Feature #19630] Notes: Merged: https://github.com/ruby/ruby/pull/7915
2023-05-27Improve `read`/`write`/`pread`/`pwrite` consistency. (#7860)Samuel Williams
* Documentation consistency. * Improve consistency of `pread`/`pwrite` implementation when given length. * Remove HAVE_PREAD / HAVE_PWRITE - it is no longer optional. Notes: Merged-By: ioquatix <[email protected]>
2023-05-26Remvoe very high timeout on test_race_gets_and_closeKJ Tsanaktsidis
This test should be fixed and fast now because the closing thread sleeps appropriately waiting for the file descriptor to be unused. Notes: Merged: https://github.com/ruby/ruby/pull/7865
2023-03-24Raise ArgumentError if IO.read is provided negative offsetJeremy Evans
Fixes [Bug #19380] Notes: Merged: https://github.com/ruby/ruby/pull/7289
2023-03-06s/mjit/rjit/Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/7462
2023-03-06s/MJIT/RJIT/Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/7462
2022-12-08Introduce `IO.new(..., path:)` and promote `File#path` to `IO#path`. (#6867)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
2022-11-17Add support for `sockaddr_un` on Windows. (#6513)Samuel Williams
* Windows: Fix warning about undefined if_indextoname() * Windows: Fix UNIXSocket on MINGW and make .pair more reliable * Windows: Use nonblock=true for read tests with scheduler * Windows: Move socket detection from File.socket? to File.stat Add S_IFSOCK to Windows and interpret reparse points accordingly. Enable tests that work now. * Windows: Use wide-char functions to UNIXSocket This fixes behaviour with non-ASCII characters. It also fixes deletion of temporary UNIXSocket.pair files. * Windows: Add UNIXSocket tests for specifics of Windows impl. * Windows: fix VC build due to missing _snwprintf Avoid usage of _snwprintf, since it fails linking ruby.dll like so: linking shared-library x64-vcruntime140-ruby320.dll x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol snwprintf x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol vsnwprintf_l whereas linking miniruby.exe succeeds. This patch uses snprintf on the UTF-8 string instead. Also remove branch GetWindowsDirectoryW, since it doesn't work. * Windows: Fix dangling symlink test failures Co-authored-by: Lars Kanis <[email protected]> Notes: Merged-By: ioquatix <[email protected]>
2022-10-15Add missing `#close` call to `test_dup_timeout` test. (#6560)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
2022-10-15Copy `IO#timeout` on `IO#dup`. (#6546)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
2022-10-11Ignore failure to set nonblock mode. (#6524)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
2022-10-07Add IO#timeout attribute and use it for blocking IO operations. (#5653)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
2022-09-11[Win32] Negative length `IO#sysread`Jeremy Bopp
Raise `ArgumentError` in `IO#sysread` on Windows when given a negative length. Fixes [Bug #18880] Notes: Merged: https://github.com/ruby/ruby/pull/6354 Merged-By: nobu <[email protected]>
2022-08-25Raise ArgumentError for IO.foreach with limit of 0Jeremy Evans
Makes behavior consistent with IO.readlines. Fixes [Bug #18767] Notes: Merged: https://github.com/ruby/ruby/pull/5954
2022-07-28Skip randomly failing tests with FreeBSD 12Hiroshi SHIBATA
2022-07-21Do not chomp trailing line separator IO#each with nil separator and chompJeremy Evans
nil separator means no sepator, so chomp should not remove a line separator. Partially Fixes [Bug #18770] Notes: Merged: https://github.com/ruby/ruby/pull/6164
2022-07-21Revert "Do not chomp trailing line separator IO#each with nil separator and ↵Jeremy Evans
chomp" This reverts commit 04f86ad0b5d2fe4711ff300d855228a6aed55f33. This is causing CI issues, reverting for now.
2022-07-21Do not chomp trailing line separator IO#each with nil separator and chompJeremy Evans
nil separator means no sepator, so chomp should not remove a line separator. Partially Fixes [Bug #18770] Notes: Merged: https://github.com/ruby/ruby/pull/5959
2022-06-09Stop ignoring 4th positional argument to IO.#{foreach,readlines}Jeremy Evans
Fixes [Bug #18771] Notes: Merged: https://github.com/ruby/ruby/pull/5953
2022-01-04Use omit instead of skip: test/ruby/**/*.rbHiroshi SHIBATA
2021-12-22Empty and return the buffer if zero size is given [Bug #18421]Nobuyoshi Nakada
In `IO#readpartial` and `IO#read_nonblock`, as well as `IO#read`. Notes: Merged: https://github.com/ruby/ruby/pull/5323
2021-12-13Prepare for removing RubyVM::JIT (#5262)Takashi Kokubun
Notes: Merged-By: k0kubun <[email protected]>
2021-12-05Do not use `fcopyfile` if appending to non-empty file [Bug #18388]Nobuyoshi Nakada
`fcopyfile` appends `src` to `to` and then truncates `to` to it's original size.
2021-11-08[Feature #18290] Remove tests that test use of rb_gc_force_recyclePeter Zhu
Remove tests that assume objects get force recycled. Notes: Merged: https://github.com/ruby/ruby/pull/5096
2021-08-22Fix Marshal.dump(closed_io) to raise TypeError and allow encoding on closed IOLars Kanis
Mashalling a closed IO object raised "closed stream (IOError)" before instead of TypeError. This changes IO#(in|ex)ternal_encoding to still return the encoding even if the underlying FD is closed. Fixes bug #18077 Notes: Merged: https://github.com/ruby/ruby/pull/4758
2021-06-29Prefer qualified names under ThreadNobuyoshi Nakada
2021-06-27Check if closed after each yield [Bug #17661]Nobuyoshi Nakada
2021-06-22Rework `sysread` to use blocking `read_internal_locktmp`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4592
2021-01-13Rename RubyVM::MJIT to RubyVM::JITTakashi Kokubun
because the name "MJIT" is an internal code name, it's inconsistent with --jit while they are related to each other, and I want to discourage future JIT implementation-specific (e.g. MJIT-specific) APIs by this rename. [Feature #17490]
2020-12-18Use category: :deprecated in warnings that are related to deprecationJeremy Evans
Also document that both :deprecated and :experimental are supported :category option values. The locations where warnings were marked as deprecation warnings was previously reviewed by shyouhei. Comment a couple locations where deprecation warnings should probably be used but are not currently used because deprecation warning enablement has not occurred at the time they are called (RUBY_FREE_MIN, RUBY_HEAP_MIN_SLOTS, -K). Add assert_deprecated_warn to test assertions. Use this to simplify some tests, and fix failing tests after marking some warnings with deprecated category. Notes: Merged: https://github.com/ruby/ruby/pull/3917
2020-12-04Guard all accesses to RubyVM::MJIT with defined?(RubyVM::MJIT) &&Benoit Daloze
* Otherwise those tests, etc cannot run on alternative Ruby implementations.
2020-12-03test/ruby/test_io.rb: some test methods had been overwrittenYusuke Endoh
http://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20201203T123002Z.log.html.gz ``` /home/chkbuild/chkbuild/tmp/build/20201203T123002Z/ruby/test/ruby/test_io.rb:1830: warning: method redefined; discarding old test_each_byte /home/chkbuild/chkbuild/tmp/build/20201203T123002Z/ruby/test/ruby/test_io.rb:376: warning: previous definition of test_each_byte was here test/unit warning: method TestIO#test_each_byte is redefined /home/chkbuild/chkbuild/tmp/build/20201203T123002Z/ruby/test/ruby/test_io.rb:1849: warning: method redefined; discarding old test_each_char /home/chkbuild/chkbuild/tmp/build/20201203T123002Z/ruby/test/ruby/test_io.rb:1799: warning: previous definition of test_each_char was here test/unit warning: method TestIO#test_each_char is redefined ```
2020-12-03delete deprecated IO-like methods卜部昌平
This commit deletes {IO,ARGF,StringIO,Zib::GZipReader}#{bytes,chars,lines,codepoints}, which have been deprecated since c47c095b9740e7c19d6fdca29ab661c1089221d4. Note that String also has those methods. They are neither depreacted nor deleted because they are not aliases of counterpart each_something.
2020-09-27Revert the first diff of "Use Tempfile.create instead of Tempfile.open in ↵Benoit Daloze
test_io.rb" * This partially reverts commit dead7478748a828c45e16134fca812bc7771344e. * Windows will not allow a file to be unlinked if any file handles exist, see https://github.com/ruby/ruby/pull/3597
2020-09-26Use Tempfile.create instead of Tempfile.open in test_io.rbBenoit Daloze
2020-09-25Disable deprecation warning by the default [Feature #16345]Nobuyoshi Nakada
And `-w` option turns it on. Notes: Merged: https://github.com/ruby/ruby/pull/3481
2020-09-09Revert the related commits about `Tempfile.open` change.Hiroshi SHIBATA
Start with https://github.com/ruby/ruby/commit/fa21985a7a2f8f52a8bd82bd12a724e9dca74934 to https://github.com/ruby/ruby/commit/d7492a0be885ea9f2b9f71e3e95582f9a859c439
2020-08-29Simplify Tempfile.open calls with a block as they now unlink the file ↵Benoit Daloze
automatically
2020-08-27[stringio] fix stringio codepoint enumerator off by one errorYoann Lecuyer
Notes: Merged: https://github.com/ruby/ruby/pull/3460
2020-08-17Ensure the shortcut cached in the classNobuyoshi Nakada
As well as the other places using RCLASS_IV_INDEX_TBL. `IO#reopen` seems the only case that the class of an object can be changed.
2020-05-07Suffixed memory leak tests as "memory_leak"Nobuyoshi Nakada
So that `TEST_EXCLUDES` option in common.mk works.
2020-04-11Silence broken pipe error messages on STDOUT [Feature #14413]Nobuyoshi Nakada
Raise `SignalException` for SIGPIPE to abort when EPIPE occurs. Notes: Merged: https://github.com/ruby/ruby/pull/3013 Merged-By: nobu <[email protected]>
2020-03-27Set external encoding correctly for File.open('f', FILE::BINARY) on WindowsJeremy Evans
Previously, the external encoding was only set correctly for File::BINARY if keyword arguments were provided. This copies the logic for the keyword arguments case to the no keyword arguments case. Possibly it should be refactored into a separate function. Fixes [Bug #16737] Notes: Merged: https://github.com/ruby/ruby/pull/2985
2020-03-02Revert "show debug info."Koichi Sasada
This reverts commit 0bfee2397ba59112902d2b49f08461db3a637b46.
2020-03-02show debug info.Koichi Sasada
https://gist.github.com/ko1/a71f7cbcfbd61ba004bffdfedab9f5f2#file-brlog-trunk-random0-20200302-020213-L2127
2020-02-23Warn non-nil `$\` [Feature #14240]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2920
2020-02-23Warn non-nil `$,` in `IO#print` tooNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2920
2020-01-02Update tests for full keyword argument separationJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2794
2019-12-23Reword keyword arguments warning messages to convey these are deprecation ↵Marc-Andre Lafortune
warnings