Skip to content

Commit

Permalink
Move yjit_force_enabled? to JITSupport
Browse files Browse the repository at this point in the history
for consistency
  • Loading branch information
k0kubun committed Mar 12, 2023
1 parent 4445b9e commit e4caf59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
16 changes: 10 additions & 6 deletions test/lib/jit_support.rb
Expand Up @@ -3,18 +3,22 @@
module JITSupport
module_function

def rjit_supported?
return @rjit_supported if defined?(@rjit_supported)
# nil in mswin
@rjit_supported = ![nil, 'no'].include?(RbConfig::CONFIG['RJIT_SUPPORT'])
end

def yjit_supported?
return @yjit_supported if defined?(@yjit_supported)
# nil in mswin
@yjit_supported = ![nil, 'no'].include?(RbConfig::CONFIG['YJIT_SUPPORT'])
end

def yjit_force_enabled?
"#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?YJIT_FORCE_ENABLE\b/)
end

def rjit_supported?
return @rjit_supported if defined?(@rjit_supported)
# nil in mswin
@rjit_supported = ![nil, 'no'].include?(RbConfig::CONFIG['RJIT_SUPPORT'])
end

def rjit_force_enabled?
"#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?RJIT_FORCE_ENABLE\b/)
end
Expand Down
12 changes: 3 additions & 9 deletions test/ruby/test_rubyoptions.rb
Expand Up @@ -151,7 +151,7 @@ def test_verbose
assert_match(VERSION_PATTERN, r[0])
if self.class.rjit_enabled? && !JITSupport.rjit_force_enabled?
assert_equal(NO_JIT_DESCRIPTION, r[0])
elsif self.class.yjit_enabled? && !yjit_force_enabled? # checking -DYJIT_FORCE_ENABLE
elsif self.class.yjit_enabled? && !JITSupport.yjit_force_enabled?
assert_equal(NO_JIT_DESCRIPTION, r[0])
else
assert_equal(RUBY_DESCRIPTION, r[0])
Expand Down Expand Up @@ -228,7 +228,7 @@ def test_version

def test_rjit_disabled_version
return unless JITSupport.rjit_supported?
return if yjit_force_enabled?
return if JITSupport.yjit_force_enabled?

env = { 'RUBY_YJIT_ENABLE' => nil } # unset in children
[
Expand All @@ -246,7 +246,7 @@ def test_rjit_disabled_version

def test_rjit_version
return unless JITSupport.rjit_supported?
return if yjit_force_enabled?
return if JITSupport.yjit_force_enabled?

env = { 'RUBY_YJIT_ENABLE' => nil } # unset in children
[
Expand Down Expand Up @@ -1124,10 +1124,4 @@ def test_null_script
omit "#{IO::NULL} is not a character device" unless File.chardev?(IO::NULL)
assert_in_out_err([IO::NULL], success: true)
end

private

def yjit_force_enabled?
"#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?YJIT_FORCE_ENABLE\b/)
end
end

0 comments on commit e4caf59

Please sign in to comment.