summaryrefslogtreecommitdiff
path: root/test/ruby/envutil.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-11 01:31:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-11 01:31:00 +0000
commit147365f4e2288a46359f6e8a34cf0f5c92a7a798 (patch)
tree7c5416e812578128ee3e3981b2fa6471204a7cf2 /test/ruby/envutil.rb
parent35803abd1c62ac7166c4d073eb91092e2730f5c9 (diff)
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
Diffstat (limited to 'test/ruby/envutil.rb')
-rw-r--r--test/ruby/envutil.rb6
1 files changed, 5 insertions, 1 deletions
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