summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2025-06-16 19:18:11 +0900
committerNobuyoshi Nakada <[email protected]>2025-06-16 19:18:11 +0900
commitf0371efbd87f72f140cbb6ea105a261ff1b23772 (patch)
treee8db9c710d28d9ec42f5c11c88dc9ff2592da7d5
parent85e61eac8579f09d76cd9a24f9c6fc23db80664c (diff)
Suppress stderr output in `TestRubyOptions#assert_segv`
It is checked against the given `list`, do not print the same output twice.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13624
-rw-r--r--test/ruby/test_rubyoptions.rb6
-rw-r--r--tool/lib/core_assertions.rb5
2 files changed, 9 insertions, 2 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index e2c3a687c4..69f30c1ce3 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -787,6 +787,12 @@ class TestRubyOptions < Test::Unit::TestCase
unless /mswin|mingw/ =~ RUBY_PLATFORM
opts[:rlimit_core] = 0
end
+ opts[:failed] = proc do |status, message = "", out = ""|
+ if (sig = status.termsig) && Signal.list["SEGV"] == sig
+ out = ""
+ end
+ Test::Unit::CoreAssertions::FailDesc[status, message]
+ end
ExecOptions = opts.freeze
# The regexp list that should match the entire stderr output.
diff --git a/tool/lib/core_assertions.rb b/tool/lib/core_assertions.rb
index 1900b7088d..ece6ca1dc8 100644
--- a/tool/lib/core_assertions.rb
+++ b/tool/lib/core_assertions.rb
@@ -97,11 +97,12 @@ module Test
end
def assert_in_out_err(args, test_stdin = "", test_stdout = [], test_stderr = [], message = nil,
- success: nil, **opt)
+ success: nil, failed: nil, **opt)
args = Array(args).dup
args.insert((Hash === args[0] ? 1 : 0), '--disable=gems')
stdout, stderr, status = EnvUtil.invoke_ruby(args, test_stdin, true, true, **opt)
- desc = FailDesc[status, message, stderr]
+ desc = failed[status, message, stderr] if failed
+ desc ||= FailDesc[status, message, stderr]
if block_given?
raise "test_stdout ignored, use block only or without block" if test_stdout != []
raise "test_stderr ignored, use block only or without block" if test_stderr != []