[前][次][番号順一覧][スレッド一覧]

ruby-changes:72115

From: Eileen <ko1@a...>
Date: Fri, 10 Jun 2022 07:00:07 +0900 (JST)
Subject: [ruby-changes:72115] e69e47f8d6 (master): Fix exit locations test (#5995)

https://git.ruby-lang.org/ruby.git/commit/?id=e69e47f8d6

From e69e47f8d62456f85f70d52f736a23eab504f8b4 Mon Sep 17 00:00:00 2001
From: "Eileen M. Uchitelle" <eileencodes@u...>
Date: Thu, 9 Jun 2022 17:59:41 -0400
Subject: Fix exit locations test (#5995)

I originally added the check for
RubyVM::YJIT.trace_exit_locations_enabled? to fix errors when these
tests run without the stats feature enabled. However I forgot that this
will never be true when this test is booting, so nothing was running
when the stats feature is turned on.

Instead I've decided to make a new hash in the dump file and check if
exit locations are enabled there. If they aren't enabled we return early
to avoid checking for keys that won't exit in the dumped exit locations.
I chose to add this additional enabled check because empty exit
locations might not indicate that stats isn't enabled, it could mean the
feature is entirely broken. I do want these tests to fail if stats are
on and nothing was collected.

Followup to #5970
---
 test/ruby/test_yjit_exit_locations.rb | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/test/ruby/test_yjit_exit_locations.rb b/test/ruby/test_yjit_exit_locations.rb
index d708bed5e9..7ad98cb109 100644
--- a/test/ruby/test_yjit_exit_locations.rb
+++ b/test/ruby/test_yjit_exit_locations.rb
@@ -8,7 +8,7 @@ require 'envutil' https://github.com/ruby/ruby/blob/trunk/test/ruby/test_yjit_exit_locations.rb#L8
 require 'tmpdir'
 require_relative '../lib/jit_support'
 
-return unless defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled? && RubyVM::YJIT.trace_exit_locations_enabled?
+return unless defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
 
 # Tests for YJIT with assertions on tracing exits
 # insipired by the MJIT tests in test/ruby/test_yjit.rb
@@ -40,7 +40,10 @@ class TestYJITExitLocations < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_yjit_exit_locations.rb#L40
 
   def assert_exit_locations(test_script)
     write_results = <<~RUBY
-      IO.open(3).write Marshal.dump(RubyVM::YJIT.exit_locations)
+      IO.open(3).write Marshal.dump({
+        enabled: RubyVM::YJIT.trace_exit_locations_enabled?,
+        exit_locations: RubyVM::YJIT.exit_locations
+      })
     RUBY
 
     script = <<~RUBY
@@ -51,7 +54,13 @@ class TestYJITExitLocations < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_yjit_exit_locations.rb#L54
       #{write_results}
     RUBY
 
-    exit_locations = eval_with_jit(script)
+    run_script = eval_with_jit(script)
+    # If stats are disabled when configuring, --yjit-exit-locations
+    # can't be true. We don't want to check if exit_locations hash
+    # is not empty because that could indicate a bug in the exit
+    # locations collection.
+    return unless run_script[:enabled]
+    exit_locations = run_script[:exit_locations]
 
     assert exit_locations.key?(:raw)
     assert exit_locations.key?(:frames)
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]