Behaviour of `IO#set_encoding` has been changed as of Ruby 3.3
- Dominant language
- Ruby
- Stars
- 13.6k
- Forks
- 1.4k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 20
Description
### Describe the bug
2 tests of child_process helper always fail in Ruby 3.3.0-dev after https://redmine.ruby-lang.org/issues/18899 is landed.
```
===============================================================================================================================================================
Failure: test: can scrub characters without exceptions(ChildProcessTest)
/home/aho/Projects/Fluentd/fluentd/test/plugin_helper/test_child_process.rb:531:in `block (2 levels) in '
528: end
529: sleep TEST_WAIT_INTERVAL_FOR_BLOCK_RUNNING until m.locked? || ran
530: m.lock
=> 531: assert_equal Encoding.find('utf-8'), str.encoding
532: expected = "\xEF\xBF\xBD\xEF\xBF\xBD\x00\xEF\xBF\xBD\xEF\xBF\xBD".force_encoding("utf-8")
533: assert_equal expected, str
534: @d.stop; @d.shutdown; @d.close; @d.terminate
/home/aho/.rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/timeout.rb:189:in `block in timeout'
/home/aho/.rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/timeout.rb:36:in `block in catch'
/home/aho/.rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/timeout.rb:36:in `catch'
/home/aho/.rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/timeout.rb:36:in `catch'
/home/aho/.rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/timeout.rb:198:in `timeout'
/home/aho/Projects/Fluentd/fluentd/test/plugin_helper/test_child_process.rb:520:in `block in '
<#> expected but was
<#>
diff:
? #
? ASCII BIT
? ??? +++
===============================================================================================================================================================
F
===============================================================================================================================================================
Failure: test: can scrub characters without exceptions and replace specified chars(ChildProcessTest)
/home/aho/Projects/Fluentd/fluentd/test/plugin_helper/test_child_process.rb:552:in `block (2 levels) in '
549: end
550: sleep TEST_WAIT_INTERVAL_FOR_BLOCK_RUNNING until m.locked? || ran
551: m.lock
=> 552: assert_equal Encoding.find('utf-8'), str.encoding
553: expected = "??\x00??".force_encoding("utf-8")
554: assert_equal expected, str
555: @d.stop; @d.shutdown; @d.close; @d.terminate
/home/aho/.rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/timeout.rb:189:in `block in timeout'
/home/aho/.rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/timeout.rb:36:in `block in catch'
/home/aho/.rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/timeout.rb:36:in `catch'
/home/aho/.rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/timeout.rb:36:in `catch'
/home/aho/.rbenv/versions/3.3.0-dev/lib/ruby/3.3.0+0/timeout.rb:198:in `timeout'
/home/aho/Projects/Fluentd/fluentd/test/plugin_helper/test_child_process.rb:541:in `block in '
<#> expected but was
<#>
diff:
? #
? ASCII BIT
? ??? +++
===============================================================================================================================================================
```
### To Reproduce
```
$ rbenv install 3.3.0-dev
$ rbenv local 3.3.0-dev
$ bundle exec rake test TEST=test/plugin_helper/test_child_process.rb
```
### Expected behavior
These tests shouldn't fail.
### Your Environment
```markdown
- Fluentd version: 8bb38b5c5cb13d2d9446f94708940f83f56a4b6f
- TD Agent version: N/A
- Operating system: Ubuntu 22.04, Windows 10
- Kernel version: 5.15.0-60-generic
```
### Your Configuration
```apache
N/A
```
### Your Error Log
```shell
Described in `Describe the bug` section.
```
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.