From 147365f4e2288a46359f6e8a34cf0f5c92a7a798 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 11 Apr 2014 01:31:00 +0000 Subject: [PATCH] envutil.rb: filter kwargs * test/ruby/envutil.rb (EnvUtil#invoke_ruby): add stdout_filter and stderr_filter optional keyword arguments, which filter stdout and stderr outputs respectively. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/envutil.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 0596676391..c072e7810e 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -31,7 +31,9 @@ module EnvUtil LANG_ENVS = %w"LANG LC_ALL LC_CTYPE" def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr = false, - encoding: nil, timeout: 10, reprieve: 1, **opt) + encoding: nil, timeout: 10, reprieve: 1, + stdout_filter: nil, stderr_filter: nil, + **opt) in_c, in_p = IO.pipe out_p, out_c = IO.pipe if capture_stdout err_p, err_c = IO.pipe if capture_stderr && capture_stderr != :merge_to_stdout @@ -85,6 +87,8 @@ module EnvUtil err_p.close if capture_stderr && capture_stderr != :merge_to_stdout Process.wait pid status = $? + stdout = stdout_filter.call(stdout) if stdout_filter + stderr = stderr_filter.call(stderr) if stderr_filter return stdout, stderr, status end ensure