Fix #5872 for MJIT GitHub Actions

If you run tests with RUN_OPTS=--mjit, the test fixes in
https://github.com/ruby/ruby/pull/5872 don't work.
This commit is contained in:
Takashi Kokubun 2022-07-10 23:01:09 -07:00
parent da21a2c388
commit 203801566a
No known key found for this signature in database
GPG Key ID: 6FFC433B12EE23DD
3 changed files with 11 additions and 9 deletions

View File

@ -1,12 +1,14 @@
# frozen_string_literal: false # frozen_string_literal: false
require 'test/unit' require 'test/unit'
require 'tmpdir' require 'tmpdir'
require_relative '../../lib/jit_support'
class TestBugReporter < Test::Unit::TestCase class TestBugReporter < Test::Unit::TestCase
def test_bug_reporter_add def test_bug_reporter_add
omit if ENV['RUBY_ON_BUG'] omit if ENV['RUBY_ON_BUG']
description = RUBY_DESCRIPTION description = RUBY_DESCRIPTION
description = description.sub(/\+MJIT /, '') unless JITSupport.mjit_force_enabled?
expected_stderr = [ expected_stderr = [
:*, :*,
/\[BUG\]\sSegmentation\sfault.*\n/, /\[BUG\]\sSegmentation\sfault.*\n/,

View File

@ -96,4 +96,8 @@ module JITSupport
RbConfig::CONFIG['CC'].start_with?('gcc') && RbConfig::CONFIG['CC'].start_with?('gcc') &&
stderr.include?("error trying to exec 'cc1': execvp: No such file or directory") stderr.include?("error trying to exec 'cc1': execvp: No such file or directory")
end end
def mjit_force_enabled?
"#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?MJIT_FORCE_ENABLE\b/)
end
end end

View File

@ -10,9 +10,9 @@ class TestRubyOptions < Test::Unit::TestCase
def self.yjit_enabled? = defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled? def self.yjit_enabled? = defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled?
NO_JIT_DESCRIPTION = NO_JIT_DESCRIPTION =
if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
RUBY_DESCRIPTION.sub(/\+MJIT /, '') RUBY_DESCRIPTION.sub(/\+MJIT /, '')
elsif yjit_enabled? # checking -DYJIT_FORCE_ENABLE elsif yjit_enabled?
RUBY_DESCRIPTION.sub(/\+YJIT /, '') RUBY_DESCRIPTION.sub(/\+YJIT /, '')
else else
RUBY_DESCRIPTION RUBY_DESCRIPTION
@ -148,7 +148,7 @@ class TestRubyOptions < Test::Unit::TestCase
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|
assert_match(VERSION_PATTERN, r[0]) assert_match(VERSION_PATTERN, r[0])
if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? && !mjit_force_enabled? # checking -DMJIT_FORCE_ENABLE if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? && !JITSupport.mjit_force_enabled?
assert_equal(NO_JIT_DESCRIPTION, r[0]) assert_equal(NO_JIT_DESCRIPTION, r[0])
elsif self.class.yjit_enabled? && !yjit_force_enabled? # checking -DYJIT_FORCE_ENABLE elsif self.class.yjit_enabled? && !yjit_force_enabled? # checking -DYJIT_FORCE_ENABLE
assert_equal(NO_JIT_DESCRIPTION, r[0]) assert_equal(NO_JIT_DESCRIPTION, r[0])
@ -257,7 +257,7 @@ class TestRubyOptions < Test::Unit::TestCase
].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_JIT, r[0])
if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE if JITSupport.mjit_force_enabled?
assert_equal(RUBY_DESCRIPTION, r[0]) assert_equal(RUBY_DESCRIPTION, r[0])
else else
assert_equal(EnvUtil.invoke_ruby([env, '--mjit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0]) assert_equal(EnvUtil.invoke_ruby([env, '--mjit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
@ -740,7 +740,7 @@ class TestRubyOptions < Test::Unit::TestCase
-e:(?:1:)?\s\[BUG\]\sSegmentation\sfault.*\n -e:(?:1:)?\s\[BUG\]\sSegmentation\sfault.*\n
)x, )x,
%r( %r(
#{ Regexp.quote(RUBY_DESCRIPTION) }\n\n #{ Regexp.quote(JITSupport.mjit_force_enabled? ? RUBY_DESCRIPTION : NO_JIT_DESCRIPTION) }\n\n
)x, )x,
%r( %r(
(?:--\s(?:.+\n)*\n)? (?:--\s(?:.+\n)*\n)?
@ -1132,10 +1132,6 @@ class TestRubyOptions < Test::Unit::TestCase
private private
def mjit_force_enabled?
"#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?MJIT_FORCE_ENABLE\b/)
end
def yjit_force_enabled? def yjit_force_enabled?
"#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?YJIT_FORCE_ENABLE\b/) "#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?YJIT_FORCE_ENABLE\b/)
end end