Skip to content

Commit

Permalink
Fix #5872 for MJIT GitHub Actions
Browse files Browse the repository at this point in the history
If you run tests with RUN_OPTS=--mjit, the test fixes in
#5872 don't work.
  • Loading branch information
k0kubun committed Jul 11, 2022
1 parent da21a2c commit 2038015
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions test/-ext-/bug_reporter/test_bug_reporter.rb
@@ -1,12 +1,14 @@
# frozen_string_literal: false
require 'test/unit'
require 'tmpdir'
require_relative '../../lib/jit_support'

class TestBugReporter < Test::Unit::TestCase
def test_bug_reporter_add
omit if ENV['RUBY_ON_BUG']

description = RUBY_DESCRIPTION
description = description.sub(/\+MJIT /, '') unless JITSupport.mjit_force_enabled?
expected_stderr = [
:*,
/\[BUG\]\sSegmentation\sfault.*\n/,
Expand Down
4 changes: 4 additions & 0 deletions test/lib/jit_support.rb
Expand Up @@ -96,4 +96,8 @@ def retried_stderr?(stderr)
RbConfig::CONFIG['CC'].start_with?('gcc') &&
stderr.include?("error trying to exec 'cc1': execvp: No such file or directory")
end

def mjit_force_enabled?
"#{RbConfig::CONFIG['CFLAGS']} #{RbConfig::CONFIG['CPPFLAGS']}".match?(/(\A|\s)-D ?MJIT_FORCE_ENABLE\b/)
end
end
14 changes: 5 additions & 9 deletions test/ruby/test_rubyoptions.rb
Expand Up @@ -10,9 +10,9 @@ class TestRubyOptions < Test::Unit::TestCase
def self.yjit_enabled? = defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled?

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 /, '')
elsif yjit_enabled? # checking -DYJIT_FORCE_ENABLE
elsif yjit_enabled?
RUBY_DESCRIPTION.sub(/\+YJIT /, '')
else
RUBY_DESCRIPTION
Expand Down Expand Up @@ -148,7 +148,7 @@ def test_debug
def test_verbose
assert_in_out_err([{'RUBY_YJIT_ENABLE' => nil}, "-vve", ""]) do |r, e|
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])
elsif self.class.yjit_enabled? && !yjit_force_enabled? # checking -DYJIT_FORCE_ENABLE
assert_equal(NO_JIT_DESCRIPTION, r[0])
Expand Down Expand Up @@ -257,7 +257,7 @@ def test_version
].each do |args|
assert_in_out_err([env] + args) do |r, e|
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])
else
assert_equal(EnvUtil.invoke_ruby([env, '--mjit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
Expand Down Expand Up @@ -740,7 +740,7 @@ module SEGVTest
-e:(?:1:)?\s\[BUG\]\sSegmentation\sfault.*\n
)x,
%r(
#{ Regexp.quote(RUBY_DESCRIPTION) }\n\n
#{ Regexp.quote(JITSupport.mjit_force_enabled? ? RUBY_DESCRIPTION : NO_JIT_DESCRIPTION) }\n\n
)x,
%r(
(?:--\s(?:.+\n)*\n)?
Expand Down Expand Up @@ -1132,10 +1132,6 @@ def test_mjit_debug

private

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

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

0 comments on commit 2038015

Please sign in to comment.