diff options
author | nagachika <[email protected]> | 2025-05-18 13:32:52 +0900 |
---|---|---|
committer | nagachika <[email protected]> | 2025-05-18 13:32:52 +0900 |
commit | 1f226f1efeeae3a5091c60e2f51e027d0598f394 (patch) | |
tree | dfbf969ffb5e1b9a101639e02c129f4027027686 /test/ruby/test_exception.rb | |
parent | 74f46982ebfbec4d21b6fc8aff47f2e290307d36 (diff) |
merge revision(s) b959263b58e26ef630c085f9f7ddc04373a998c7: [Backport #21344]
Fix Exception#detailed_message for GC compaction
Before this commit, the test fails with RGENGC_CHECK_MODE enabled:
TestException#test_detailed_message_under_gc_compact_stress [test/ruby/test_exception.rb:1466]:
<"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" +
"\e[1mbar\e[m\n" +
"\e[1mbaz\e[m"> expected but was
<"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" +
"\e[1m\x00\x00\x00\x00\x00\x00\x00\e[m">.
Diffstat (limited to 'test/ruby/test_exception.rb')
-rw-r--r-- | test/ruby/test_exception.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 07b39d1217..b3951c7e51 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1459,6 +1459,14 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| assert_equal("\e[1mRuntimeError (\e[1;4mRuntimeError\e[m\e[1m)\e[m", e.detailed_message(highlight: true)) end + def test_detailed_message_under_gc_compact_stress + EnvUtil.under_gc_compact_stress do + e = RuntimeError.new("foo\nbar\nbaz") + assert_equal("foo (RuntimeError)\nbar\nbaz", e.detailed_message) + assert_equal("\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n\e[1mbar\e[m\n\e[1mbaz\e[m", e.detailed_message(highlight: true)) + end + end + def test_full_message_with_custom_detailed_message e = RuntimeError.new("message") opt_ = nil |