From a5a459fe05f6bc82ba6e60838eed2bd694f9b96d Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Fri, 21 Nov 2025 11:02:20 +0900 Subject: [PATCH] test_dsl: fix test using pipe command (#5160) **Which issue(s) this PR fixes**: Fixes #5148 **What this PR does / why we need it**: Related to #5159 I overlooked the fact that there were also tests using pipe commands in another file. Since Ruby 4.0, When we give pipe command in `Kernel.open`, it causes an error. ``` $ ruby -w -v -e "Kernel.open('| uname -a'){|out| p out.read }" ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [x86_64-linux] -e:1: warning: Calling Kernel#open with a leading '|' is deprecated and will be removed in Ruby 4.0; use IO.popen instead "Linux UM890 6.17.1-0-MANJARO #1 SMP PREEMPT_DYNAMIC Tue, 07 Oct 2025 07:57:35 +0000 x86_64 GNU/Linux\n" $ ruby -w -v -e "Kernel.open('| uname -a'){|out| p out.read }" ruby 4.0.0dev (2025-11-20T00:03:23Z master 167c3dbaa0) +PRISM [x86_64-linux] -e:1:in 'File#initialize': No such file or directory @ rb_sysopen - | uname -a (Errno::ENOENT) from -e:1:in 'Kernel.open' from -e:1:in '
' ``` **Docs Changes**: N/A **Release Note**: N/A Signed-off-by: Shizuo Fujita --- test/config/test_dsl.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/config/test_dsl.rb b/test/config/test_dsl.rb index 34c67e1202..28ac1e91ec 100644 --- a/test/config/test_dsl.rb +++ b/test/config/test_dsl.rb @@ -1,6 +1,7 @@ require_relative '../helper' require 'fluent/config/element' require "fluent/config/dsl" +require 'tempfile' TMP_DIR = File.dirname(__FILE__) + "/tmp/config_dsl#{ENV['TEST_ENV_NUMBER']}" def write_config(path, data) @@ -358,9 +359,13 @@ def setup sub_test_case '.parse' do test 'can get result of Kernel.open() by ruby.open()' do uname_string = `uname -a` + tmpfile = Tempfile.create('fluentd-test') + tmpfile.write(uname_string) + tmpfile.close + root = Fluent::Config::DSL::Parser.parse(<