ruby / spec

The Ruby Spec Suite aka ruby/spec
MIT License
588 stars 384 forks source link

Add spec for `Socket#read_nonblock` with a provided buffer #1145

Closed casperisfine closed 3 months ago

casperisfine commented 4 months ago

When provided a buffer MRI preserves the original encoding but TruffleRuby sets the encoding to Encoding::BINARY

cc @eregon

Discovered as part of https://github.com/redis-rb/redis-client/pull/184

casperisfine commented 3 months ago

I augmented the spec a bit.

casperisfine commented 3 months ago

I also added a similar spec for #read and amusingly TruffleRuby's behavior match MRI's on read, just not on read_nonblock.

eregon commented 3 months ago

@casperisfine The CI fails on Windows for the new specs, could you exclude the problematic specs on Windows (platform_is_not :windows)?

eregon commented 3 months ago

It seems whether the encoding is changed depend on arguments for read, see https://bugs.ruby-lang.org/issues/20416

casperisfine commented 3 months ago

Ref: https://github.com/ruby/ruby/commit/0ca7036682dad1caea4e7a4fe8fd908d94c878e8

  • io.c (read_all): should associate default external encoding.
  • io.c (io_read): should NOT associate default external encoding.