summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2023-10-19 13:41:38 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2023-10-19 15:14:20 -0400
commit9047fe5ea4e8c989c1081aa10f741a413c546534 (patch)
treec35e4e3e9bc5d2dbbcd01c511ccfa41c6c5a7203 /test/ruby
parentcdc2a18541a42e63a8a0a3c2c5b72978ace01afa (diff)
YJIT: Print exit reasons on failure in test_yjit.rb
For <https://bugs.ruby-lang.org/issues/19921>, I suspect the test is failing due to a timing related interrupt, which on paper could happen with slow-enough GC runs. In any case, it's helpful for debugging to have more information when tests fail. Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_yjit.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb
index fa357b4977..1fe9d68b30 100644
--- a/test/ruby/test_yjit.rb
+++ b/test/ruby/test_yjit.rb
@@ -10,6 +10,8 @@ require_relative '../lib/jit_support'
return unless JITSupport.yjit_supported?
+require 'stringio'
+
# Tests for YJIT with assertions on compilation and side exits
# insipired by the RJIT tests in test/ruby/test_rjit.rb
class TestYJIT < Test::Unit::TestCase
@@ -1470,8 +1472,15 @@ class TestYJIT < Test::Unit::TestCase
if exits != :any &&
exits != recorded_exits &&
(exits.keys != recorded_exits.keys || !exits.all? { |k, v| v === recorded_exits[k] }) # triple-equal checks range membership or integer equality
- flunk "Expected #{exits.empty? ? "no" : exits.inspect} exits" \
- ", but got\n#{recorded_exits.inspect}"
+ stats_reasons = StringIO.new
+ ::RubyVM::YJIT.send(:_print_stats_reasons, runtime_stats, stats_reasons)
+ stats_reasons = stats_reasons.string
+ flunk <<~EOM
+ Expected #{exits.empty? ? "no" : exits.inspect} exits, but got:
+ #{recorded_exits.inspect}
+ Reasons:
+ #{stats_reasons}
+ EOM
end
end