RJIT: Break up and enable test_version (#7495)
This commit is contained in:
parent
365fed6369
commit
ac5f983f7d
Notes:
git
2023-03-10 18:08:12 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>
@ -63,6 +63,12 @@ module JITSupport
|
|||||||
!UNSUPPORTED_ARCHITECTURES.include?(RUBY_PLATFORM.split('-', 2).first)
|
!UNSUPPORTED_ARCHITECTURES.include?(RUBY_PLATFORM.split('-', 2).first)
|
||||||
end
|
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 yjit_supported?
|
def yjit_supported?
|
||||||
return @yjit_supported if defined?(@yjit_supported)
|
return @yjit_supported if defined?(@yjit_supported)
|
||||||
# nil in mswin
|
# nil in mswin
|
||||||
|
@ -137,14 +137,14 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
private_constant :VERSION_PATTERN
|
private_constant :VERSION_PATTERN
|
||||||
|
|
||||||
VERSION_PATTERN_WITH_JIT =
|
VERSION_PATTERN_WITH_RJIT =
|
||||||
case RUBY_ENGINE
|
case RUBY_ENGINE
|
||||||
when 'ruby'
|
when 'ruby'
|
||||||
/^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+RJIT \[#{q[RUBY_PLATFORM]}\]$/
|
/^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+RJIT \[#{q[RUBY_PLATFORM]}\]$/
|
||||||
else
|
else
|
||||||
VERSION_PATTERN
|
VERSION_PATTERN
|
||||||
end
|
end
|
||||||
private_constant :VERSION_PATTERN_WITH_JIT
|
private_constant :VERSION_PATTERN_WITH_RJIT
|
||||||
|
|
||||||
def test_verbose
|
def test_verbose
|
||||||
assert_in_out_err([{'RUBY_YJIT_ENABLE' => nil}, "-vve", ""]) do |r, e|
|
assert_in_out_err([{'RUBY_YJIT_ENABLE' => nil}, "-vve", ""]) do |r, e|
|
||||||
@ -224,20 +224,17 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
assert_equal([], e)
|
assert_equal([], e)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
omit "This fails on some CIs for now. To be fixed in RJIT's side."
|
def test_rjit_disabled_version
|
||||||
return if RbConfig::CONFIG["RJIT_SUPPORT"] == 'no'
|
return unless JITSupport.rjit_supported?
|
||||||
return if yjit_force_enabled?
|
return if yjit_force_enabled?
|
||||||
|
|
||||||
|
env = { 'RUBY_YJIT_ENABLE' => nil } # unset in children
|
||||||
[
|
[
|
||||||
%w(--version --rjit --disable=rjit),
|
%w(--version --rjit --disable=rjit),
|
||||||
%w(--version --enable=rjit --disable=rjit),
|
%w(--version --enable=rjit --disable=rjit),
|
||||||
%w(--version --enable-rjit --disable-rjit),
|
%w(--version --enable-rjit --disable-rjit),
|
||||||
*([
|
|
||||||
%w(--version --jit --disable=jit),
|
|
||||||
%w(--version --enable=jit --disable=jit),
|
|
||||||
%w(--version --enable-jit --disable-jit),
|
|
||||||
] unless JITSupport.yjit_supported?),
|
|
||||||
].each do |args|
|
].each do |args|
|
||||||
assert_in_out_err([env] + args) do |r, e|
|
assert_in_out_err([env] + args) do |r, e|
|
||||||
assert_match(VERSION_PATTERN, r[0])
|
assert_match(VERSION_PATTERN, r[0])
|
||||||
@ -245,20 +242,20 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
assert_equal([], e)
|
assert_equal([], e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if JITSupport.supported?
|
def test_rjit_version
|
||||||
|
return unless JITSupport.rjit_supported?
|
||||||
|
return if yjit_force_enabled?
|
||||||
|
|
||||||
|
env = { 'RUBY_YJIT_ENABLE' => nil } # unset in children
|
||||||
[
|
[
|
||||||
%w(--version --rjit),
|
%w(--version --rjit),
|
||||||
%w(--version --enable=rjit),
|
%w(--version --enable=rjit),
|
||||||
%w(--version --enable-rjit),
|
%w(--version --enable-rjit),
|
||||||
*([
|
|
||||||
%w(--version --jit),
|
|
||||||
%w(--version --enable=jit),
|
|
||||||
%w(--version --enable-jit),
|
|
||||||
] unless JITSupport.yjit_supported?),
|
|
||||||
].each do |args|
|
].each do |args|
|
||||||
assert_in_out_err([env] + args) do |r, e|
|
assert_in_out_err([env] + args) do |r, e|
|
||||||
assert_match(VERSION_PATTERN_WITH_JIT, r[0])
|
assert_match(VERSION_PATTERN_WITH_RJIT, r[0])
|
||||||
if JITSupport.rjit_force_enabled?
|
if JITSupport.rjit_force_enabled?
|
||||||
assert_equal(RUBY_DESCRIPTION, r[0])
|
assert_equal(RUBY_DESCRIPTION, r[0])
|
||||||
else
|
else
|
||||||
@ -268,7 +265,6 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_eval
|
def test_eval
|
||||||
assert_in_out_err(%w(-e), "", [], /no code specified for -e \(RuntimeError\)/)
|
assert_in_out_err(%w(-e), "", [], /no code specified for -e \(RuntimeError\)/)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user