diff --git a/test/command/test_fluentd.rb b/test/command/test_fluentd.rb index 87c9d28d96..c6bd88d857 100644 --- a/test/command/test_fluentd.rb +++ b/test/command/test_fluentd.rb @@ -941,7 +941,7 @@ def multi_workers_ready? '-external-encoding' => '--external-encoding=utf-8', '-internal-encoding' => '--internal-encoding=utf-8', ) - test "-E option is set to RUBYOPT" do |opt| + test "-E option is set to RUBYOPT" do |base_opt| conf = < @type dummy @@ -952,6 +952,7 @@ def multi_workers_ready? CONF conf_path = create_conf_file('rubyopt_test.conf', conf) + opt = base_opt.dup opt << " #{ENV['RUBYOPT']}" if ENV['RUBYOPT'] assert_log_matches( create_cmdline(conf_path), @@ -991,9 +992,14 @@ def multi_workers_ready? CONF conf_path = create_conf_file('rubyopt_invalid_test.conf', conf) + if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('3.3.0') + expected_phrase = 'ruby: invalid switch in RUBYOPT' + else + expected_phrase = 'Invalid option is passed to RUBYOPT' + end assert_log_matches( create_cmdline(conf_path), - 'Invalid option is passed to RUBYOPT', + expected_phrase, env: { 'RUBYOPT' => 'a' }, ) end diff --git a/test/plugin/test_out_forward.rb b/test/plugin/test_out_forward.rb index 80557c5989..3a7f9a2e10 100644 --- a/test/plugin/test_out_forward.rb +++ b/test/plugin/test_out_forward.rb @@ -156,7 +156,14 @@ def try_write(chunk) normal_conf = config_element('match', '**', {}, [ config_element('server', '', {'name' => 'test', 'host' => 'unexisting.yaaaaaaaaaaaaaay.host.example.com'}) ]) - assert_raise SocketError do + + if Socket.const_defined?(:ResolutionError) # as of Ruby 3.3 + error_class = Socket::ResolutionError + else + error_class = SocketError + end + + assert_raise error_class do create_driver(normal_conf) end @@ -165,7 +172,7 @@ def try_write(chunk) ]) @d = d = create_driver(conf) expected_log = "failed to resolve node name when configured" - expected_detail = 'server="test" error_class=SocketError' + expected_detail = "server=\"test\" error_class=#{error_class.name}" logs = d.logs assert{ logs.any?{|log| log.include?(expected_log) && log.include?(expected_detail) } } end diff --git a/test/plugin_helper/test_child_process.rb b/test/plugin_helper/test_child_process.rb index 5d84a0fd06..b498b7a0eb 100644 --- a/test/plugin_helper/test_child_process.rb +++ b/test/plugin_helper/test_child_process.rb @@ -515,6 +515,9 @@ def configure(conf) end test 'can scrub characters without exceptions' do + if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('3.3.0') + pend "Behaviour of IO#set_encoding is changed as of Ruby 3.3 (#4058)" + end m = Mutex.new str = nil Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do @@ -529,19 +532,25 @@ def configure(conf) sleep TEST_WAIT_INTERVAL_FOR_BLOCK_RUNNING until m.locked? || ran m.lock assert_equal Encoding.find('utf-8'), str.encoding - expected = "\xEF\xBF\xBD\xEF\xBF\xBD\x00\xEF\xBF\xBD\xEF\xBF\xBD".force_encoding("utf-8") + replacement = "\uFFFD" # U+FFFD (REPLACEMENT CHARACTER) + nul = "\x00" # U+0000 (NUL) + expected = replacement * 2 + nul + replacement * 2 assert_equal expected, str @d.stop; @d.shutdown; @d.close; @d.terminate end end test 'can scrub characters without exceptions and replace specified chars' do + if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('3.3.0') + pend "Behaviour of IO#set_encoding is changed as of Ruby 3.3 (#4058)" + end m = Mutex.new str = nil + replacement = "?" Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do ran = false args = ['-e', 'STDOUT.set_encoding("ascii-8bit"); STDOUT.write "\xFF\xFF\x00\xF0\xF0"'] - @d.child_process_execute(:t13b, "ruby", arguments: args, mode: [:read], scrub: true, replace_string: '?') do |io| + @d.child_process_execute(:t13b, "ruby", arguments: args, mode: [:read], scrub: true, replace_string: replacement) do |io| m.lock ran = true str = io.read @@ -550,7 +559,8 @@ def configure(conf) sleep TEST_WAIT_INTERVAL_FOR_BLOCK_RUNNING until m.locked? || ran m.lock assert_equal Encoding.find('utf-8'), str.encoding - expected = "??\x00??".force_encoding("utf-8") + nul = "\x00" # U+0000 (NUL) + expected = replacement * 2 + nul + replacement * 2 assert_equal expected, str @d.stop; @d.shutdown; @d.close; @d.terminate end