fluentd icon indicating copy to clipboard operation
fluentd copied to clipboard

Behaviour of `IO#set_encoding` has been changed as of Ruby 3.3

Open ashie opened this issue 1 year ago • 8 comments

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 <class:ChildProcessTest>'
     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 <class:ChildProcessTest>'
<#<Encoding:UTF-8>> expected but was
<#<Encoding:ASCII-8BIT>>

diff:
? #<Encoding:UTF  -8   >
?            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 <class:ChildProcessTest>'
     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 <class:ChildProcessTest>'
<#<Encoding:UTF-8>> expected but was
<#<Encoding:ASCII-8BIT>>

diff:
? #<Encoding:UTF  -8   >
?            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

- Fluentd version: 8bb38b5c5cb13d2d9446f94708940f83f56a4b6f
- TD Agent version: N/A
- Operating system: Ubuntu 22.04, Windows 10
- Kernel version: 5.15.0-60-generic

Your Configuration

N/A

Your Error Log

Described in `Describe the bug` section.

Additional context

No response

ashie avatar Feb 16 '23 01:02 ashie