Skip to content

Commit a0f65fc

Browse files
Watson1978kenhys
andauthored
Backport(v1.16): test: use IO#popen instead of Kernel#open (#5182)
Backport #4369 **Which issue(s) this PR fixes**: N/A **What this PR does / why we need it**: 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 **Docs Changes**: N/A **Release Note**: N/A Signed-off-by: Kentaro Hayashi <[email protected]> Co-authored-by: Kentaro Hayashi <[email protected]>
1 parent 18fe509 commit a0f65fc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/plugin_helper/test_child_process.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def configure(conf)
569569
unless Fluent.windows?
570570
test 'can specify subprocess name' do
571571
io = IO.popen([["cat", "caaaaaaaaaaat"], '-'])
572-
process_naming_enabled = (open("|ps opid,cmd"){|_io| _io.readlines }.count{|line| line.include?("caaaaaaaaaaat") } > 0)
572+
process_naming_enabled = (IO.popen(["ps", "opid,cmd"]){|_io| _io.readlines }.count{|line| line.include?("caaaaaaaaaaat") } > 0)
573573
Process.kill(:TERM, io.pid) rescue nil
574574
io.close rescue nil
575575

@@ -586,7 +586,7 @@ def configure(conf)
586586
m.lock
587587
ran = true
588588
pids << @d.child_process_id
589-
proc_lines += open("|ps opid,cmd"){|_io| _io.readlines }
589+
proc_lines += IO.popen(["ps", "opid,cmd"]){|_io| _io.readlines }
590590
m.unlock
591591
readio.read
592592
end
@@ -645,8 +645,8 @@ def configure(conf)
645645
unless Fluent.windows?
646646
test 'can change working directory' do
647647
# check my real /tmp directory (for mac)
648-
cmd = %[|ruby -e 'Dir.chdir("/tmp"); puts Dir.pwd']
649-
mytmpdir = open(cmd){|io| io.read.chomp }
648+
cmd = ['ruby', '-e', 'Dir.chdir("/tmp"); puts Dir.pwd']
649+
mytmpdir = IO.popen(cmd){|io| io.read.chomp }
650650

651651
m = Mutex.new
652652
str = nil

0 commit comments

Comments
 (0)