spec
spec copied to clipboard
Add many tests for core/io components
These tests cover more corner cases of various IO methods and fix several invalid tests. They have been tested against all stable versions of MRI since version 2.7.0.
A single case for failures was discovered in IO#readpartial behavior for all but the latest version of each of the 2.7 and 3.0 series (2.7.6 and 3.0.4). The affected older versions truncate a given buffer to zero bytes when told to read zero bytes. Versions 2.7.6, 3.0.4, and all 3.1 versions return the given buffer unmodified, which makes sense since the method can simply short circuit when told to read zero bytes.
I left those failures in place since it appears that the MRI developers have addressed the behavior in recent versions. It appears they decided that the short circuit behavior is correct. I can augment this patch to make the broken versions succeed if desired.
The failure on macos with version 3.0.4 doesn't appear related to my changes. The windows failures on 3.1.2 may be up for debate.
On macos and ubuntu, IO#sysread(-1) raise an ArgumentError, which seems sensible, but it looks like the windows implementation doesn't check the arguments before passing them on to the system libraries, resulting in Errno::EINVAL. This feels like a bug in MRI's implementation on windows which should be addressed.
Again on macos and ubuntu, IO#read_nonblock called after IO#ungetc just works. On windows we get an error about byte oriented operations on character oriented streams. I think that this is something that could be addressed in MRI.
I could add guards for both windows failures, but what do the rubyspec maintainers think?
I'll try to review soon. Could you rebase on latest master?
This feels like a bug in MRI's implementation on windows which should be addressed.
Could you report it to https://bugs.ruby-lang.org/ ?
And then use platform_is_not :windows do around those specs?
The patch set has been rebased, and the specs that fail on Windows have been skipped for that platform. I included comments that point to the issues I opened in the Ruby issue tracker.
ruby/ruby#6354 will fix the sysread test that I disabled for Windows. I don't know yet if it will be backported. If it is not, what is the process to keep the test disabled only for Windows on older Ruby versions?
what is the process to keep the test disabled only for Windows on older Ruby versions?
Something like:
guard_not -> { platform_is :windows and ruby_version_is ""..."3.2" } do