[前][次][番号順一覧][スレッド一覧]

ruby-changes:72499

From: Takashi <ko1@a...>
Date: Mon, 11 Jul 2022 15:10:57 +0900 (JST)
Subject: [ruby-changes:72499] 203801566a (master): Fix #5872 for MJIT GitHub Actions

https://git.ruby-lang.org/ruby.git/commit/?id=203801566a

From 203801566a186b7b1cbe899a06d0832923a1bdf9 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Sun, 10 Jul 2022 23:01:09 -0700
Subject: 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.
---
 test/-ext-/bug_reporter/test_bug_reporter.rb |  2 ++
 test/lib/jit_support.rb                      |  4 ++++
 test/ruby/test_rubyoptions.rb                | 14 +++++---------
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/test/-ext-/bug_reporter/test_bug_reporter.rb b/test/-ext-/bug_reporter/test_bug_reporter.rb
index 6e955e2cbd..8e1121f908 100644
--- a/test/-ext-/bug_reporter/test_bug_reporter.rb
+++ b/test/-ext-/bug_reporter/test_bug_reporter.rb
@@ -1,12 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/test/-ext-/bug_reporter/test_bug_reporter.rb#L1
 # 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/,
diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb
index c7618e03a0..e607df4cab 100644
--- a/test/lib/jit_support.rb
+++ b/test/lib/jit_support.rb
@@ -96,4 +96,8 @@ module JITSupport https://github.com/ruby/ruby/blob/trunk/test/lib/jit_support.rb#L96
     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
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 757cbcf41f..93ad73bccd 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -10,9 +10,9 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L10
   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
@@ -148,7 +148,7 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L148
   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])
@@ -257,7 +257,7 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L257
       ].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])
@@ -740,7 +740,7 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L740
         -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)?
@@ -1132,10 +1132,6 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L1132
 
   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
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]