From 6d7637029b88745ea64716fc0a836fa9b8d50013 Mon Sep 17 00:00:00 2001 From: Kentaro Hayashi Date: Wed, 27 Dec 2023 18:43:34 +0900 Subject: [PATCH] test: use IO#popen instead of Kernel#open open("|command") spawns command and create pipes for processing pipeline. This feature of Kernel#open is deprecated, replace it with IO#popen. It fixes the following warning: warning: Calling Kernel#open with a leading '|' is deprecated and will be removed in Ruby 4.0; use IO.popen instead Signed-off-by: Kentaro Hayashi --- test/plugin_helper/test_child_process.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/plugin_helper/test_child_process.rb b/test/plugin_helper/test_child_process.rb index 5d84a0fd06..171e2fbee1 100644 --- a/test/plugin_helper/test_child_process.rb +++ b/test/plugin_helper/test_child_process.rb @@ -559,7 +559,7 @@ def configure(conf) unless Fluent.windows? test 'can specify subprocess name' do io = IO.popen([["cat", "caaaaaaaaaaat"], '-']) - process_naming_enabled = (open("|ps opid,cmd"){|_io| _io.readlines }.count{|line| line.include?("caaaaaaaaaaat") } > 0) + process_naming_enabled = (IO.popen(["ps", "opid,cmd"]){|_io| _io.readlines }.count{|line| line.include?("caaaaaaaaaaat") } > 0) Process.kill(:TERM, io.pid) rescue nil io.close rescue nil @@ -576,7 +576,7 @@ def configure(conf) m.lock ran = true pids << @d.child_process_id - proc_lines += open("|ps opid,cmd"){|_io| _io.readlines } + proc_lines += IO.popen(["ps", "opid,cmd"]){|_io| _io.readlines } m.unlock readio.read end @@ -635,8 +635,8 @@ def configure(conf) unless Fluent.windows? test 'can change working directory' do # check my real /tmp directory (for mac) - cmd = %[|ruby -e 'Dir.chdir("/tmp"); puts Dir.pwd'] - mytmpdir = open(cmd){|io| io.read.chomp } + cmd = ['ruby', '-e', 'Dir.chdir("/tmp"); puts Dir.pwd'] + mytmpdir = IO.popen(cmd){|io| io.read.chomp } m = Mutex.new str = nil