Skip to content

Commit 72ddfc1

Browse files
authored
ZJIT: Fix tests for ZJIT (ruby#14460)
1 parent 8aa885c commit 72ddfc1

File tree

7 files changed

+16
-22
lines changed

7 files changed

+16
-22
lines changed

test/-ext-/bug_reporter/test_bug_reporter.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def test_bug_reporter_add
2020

2121
no_core = "Process.setrlimit(Process::RLIMIT_CORE, 0); " if defined?(Process.setrlimit) && defined?(Process::RLIMIT_CORE)
2222
args = ["-r-test-/bug_reporter", "-C", tmpdir]
23-
args.push("--yjit") if JITSupport.yjit_enabled? # We want the printed description to match this process's RUBY_DESCRIPTION
23+
# We want the printed description to match this process's RUBY_DESCRIPTION
24+
args.push("--yjit") if JITSupport.yjit_enabled?
25+
args.push("--zjit") if JITSupport.zjit_enabled?
2426
args.unshift({"RUBY_ON_BUG" => nil})
2527
stdin = "#{no_core}register_sample_bug_reporter(12345); Process.kill :SEGV, $$"
2628
assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT")

test/.excludes-zjit/TestBugReporter.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/.excludes-zjit/TestGc.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/.excludes-zjit/TestProc.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/.excludes-zjit/TestRubyOptions.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/lib/jit_support.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def yjit_supported?
1010
end
1111

1212
def yjit_enabled?
13-
defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled?
13+
defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
1414
end
1515

1616
def yjit_force_enabled?
@@ -22,4 +22,8 @@ def zjit_supported?
2222
# nil in mswin
2323
@zjit_supported = ![nil, 'no'].include?(RbConfig::CONFIG['ZJIT_SUPPORT'])
2424
end
25+
26+
def zjit_enabled?
27+
defined?(RubyVM::ZJIT) && RubyVM::ZJIT.enabled?
28+
end
2529
end

test/ruby/test_rubyoptions.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
require_relative '../lib/parser_support'
99

1010
class TestRubyOptions < Test::Unit::TestCase
11-
def self.yjit_enabled? = defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
12-
1311
# Here we're defining our own RUBY_DESCRIPTION without "+PRISM". We do this
1412
# here so that the various tests that reference RUBY_DESCRIPTION don't have to
1513
# worry about it. The flag itself is tested in its own test.
@@ -22,8 +20,10 @@ def self.yjit_enabled? = defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
2220

2321
NO_JIT_DESCRIPTION =
2422
case
25-
when yjit_enabled?
26-
RUBY_DESCRIPTION.sub(/\+YJIT( (dev|dev_nodebug|stats))? /, '')
23+
when JITSupport.yjit_enabled?
24+
RUBY_DESCRIPTION.sub(/\+YJIT( \w+)? /, '')
25+
when JITSupport.zjit_enabled?
26+
RUBY_DESCRIPTION.sub(/\+ZJIT( \w+)? /, '')
2727
else
2828
RUBY_DESCRIPTION
2929
end
@@ -181,7 +181,7 @@ def test_debug
181181
def test_verbose
182182
assert_in_out_err([{'RUBY_YJIT_ENABLE' => nil}, "-vve", ""]) do |r, e|
183183
assert_match(VERSION_PATTERN, r[0])
184-
if self.class.yjit_enabled? && !JITSupport.yjit_force_enabled?
184+
if (JITSupport.yjit_enabled? && !JITSupport.yjit_force_enabled?) || JITSupport.zjit_enabled?
185185
assert_equal(NO_JIT_DESCRIPTION, r[0])
186186
else
187187
assert_equal(RUBY_DESCRIPTION, r[0])
@@ -247,7 +247,7 @@ def test_version
247247
assert_match(VERSION_PATTERN, r[0])
248248
if ENV['RUBY_YJIT_ENABLE'] == '1'
249249
assert_equal(NO_JIT_DESCRIPTION, r[0])
250-
elsif self.class.yjit_enabled? # checking -DYJIT_FORCE_ENABLE
250+
elsif JITSupport.yjit_enabled? || JITSupport.zjit_enabled? # checking -DYJIT_FORCE_ENABLE
251251
assert_equal(EnvUtil.invoke_ruby(['-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
252252
else
253253
assert_equal(RUBY_DESCRIPTION, r[0])
@@ -852,7 +852,8 @@ def assert_segv(args, message=nil, list: SEGVTest::ExpectedStderrList, **opt, &b
852852
# We want YJIT to be enabled in the subprocess if it's enabled for us
853853
# so that the Ruby description matches.
854854
env = Hash === args.first ? args.shift : {}
855-
args.unshift("--yjit") if self.class.yjit_enabled?
855+
args.unshift("--yjit") if JITSupport.yjit_enabled?
856+
args.unshift("--zjit") if JITSupport.zjit_enabled?
856857
env.update({'RUBY_ON_BUG' => nil})
857858
# ASAN registers a segv handler which prints out "AddressSanitizer: DEADLYSIGNAL" when
858859
# catching sigsegv; we don't expect that output, so suppress it.

0 commit comments

Comments
 (0)