10000 Fix exit locations test (#5995) · ruby/ruby@e69e47f · GitHub
[go: up one dir, main page]

Skip to content

Commit e69e47f

Browse files
authored
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
1 parent c2468fd commit e69e47f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

test/ruby/test_yjit_exit_locations.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
require 'tmpdir'
99
require_relative '../lib/jit_support'
1010

11-
return unless defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled? && RubyVM::YJIT.trace_exit_locations_enabled?
11+
return unless defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
1212

1313
# Tests for YJIT with assertions on tracing exits
1414
# insipired by the MJIT tests in test/ruby/test_yjit.rb
@@ -40,7 +40,10 @@ def test_trace_exits_opt_not
4040

4141
def assert_exit_locations(test_script)
4242
write_results = <<~RUBY
43-
IO.open(3).write Marshal.dump(RubyVM::YJIT.exit_locations)
43+
IO.open(3).write Marshal.dump({
44+
enabled: RubyVM::YJIT.trace_exit_locations_enabled?,
45+
exit_locations: RubyVM::YJIT.exit_locations
46+
})
4447
RUBY
4548

4649
script = <<~RUBY
@@ -51,7 +54,13 @@ def assert_exit_locations(test_script)
5154
#{write_results}
5255
RUBY
5356

54-
exit_locations = eval_with_jit(script)
57+
run_script = eval_with_jit(script)
58+
# If stats are disabled when configuring, --yjit-exit-locations
59+
# can't be true. We don't want to check if exit_locations hash
60+
# is not empty because that could indicate a bug in the exit
61+
# locations collection.
62+
return unless run_script[:enabled]
63+
exit_locations = run_script[:exit_locations]
5564

5665
assert exit_locations.key?(:raw)
5766
assert exit_locations.key?(:frames)

0 commit comments

Comments
 (0)
0