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

ruby-changes:69296

From: Takashi <ko1@a...>
Date: Thu, 21 Oct 2021 12:53:11 +0900 (JST)
Subject: [ruby-changes:69296] 66a64e6f16 (master): Fix tests with cppflags=-DYJIT_FORCE_ENABLE

https://git.ruby-lang.org/ruby.git/commit/?id=66a64e6f16

From 66a64e6f16c0db8d6c049d5885e63a3c61f9bc18 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Wed, 20 Oct 2021 20:44:20 -0700
Subject: Fix tests with cppflags=-DYJIT_FORCE_ENABLE

https://github.com/ko1/build-ruby/commit/0dbd95c6250594b6ddadc3c4424b071704083187
---
 spec/ruby/command_line/dash_v_spec.rb |  2 +-
 test/ruby/test_rubyoptions.rb         | 13 ++++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/spec/ruby/command_line/dash_v_spec.rb b/spec/ruby/command_line/dash_v_spec.rb
index 04d684fdad..4090abb63d 100644
--- a/spec/ruby/command_line/dash_v_spec.rb
+++ b/spec/ruby/command_line/dash_v_spec.rb
@@ -7,6 +7,6 @@ describe "The -v command line option" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_v_spec.rb#L7
   describe "when used alone" do
     it "prints version and ends" do
       ruby_exe(nil, args: '-v').should include(RUBY_DESCRIPTION)
-    end
+    end unless defined?(YJIT) && YJIT.enabled? # pending. not sure why MJIT doesn't need anything to fix this.
   end
 end
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index ce59302447..4c06c74974 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -10,7 +10,7 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L10
   NO_JIT_DESCRIPTION =
     if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE
       RUBY_DESCRIPTION.sub(/\+JIT /, '')
-    elsif defined?(YJIT.enabled?) && YJIT.enabled?
+    elsif defined?(YJIT.enabled?) && YJIT.enabled? # checking -DYJIT_FORCE_ENABLE
       RUBY_DESCRIPTION.sub(/\+YJIT /, '')
     else
       RUBY_DESCRIPTION
@@ -146,7 +146,7 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L146
       assert_match(VERSION_PATTERN, r[0])
       if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? && !mjit_force_enabled? # checking -DMJIT_FORCE_ENABLE
         assert_equal(NO_JIT_DESCRIPTION, r[0])
-      elsif defined?(YJIT.enabled?) && YJIT.enabled?
+      elsif defined?(YJIT.enabled?) && YJIT.enabled? && !yjit_force_enabled? # checking -DYJIT_FORCE_ENABLE
         assert_equal(NO_JIT_DESCRIPTION, r[0])
       else
         assert_equal(RUBY_DESCRIPTION, r[0])
@@ -210,10 +210,8 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L210
     env = {'RUBY_YJIT_ENABLE' => nil} # unset in children
     assert_in_out_err([env, '--version']) do |r, e|
       assert_match(VERSION_PATTERN, r[0])
-      if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE
+      if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? || defined?(YJIT.enabled?) && YJIT.enabled? # checking -D*JIT_FORCE_ENABLE
         assert_equal(EnvUtil.invoke_ruby(['-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
-      elsif defined?(YJIT.enabled?) && YJIT.enabled?
-        assert_equal(NO_JIT_DESCRIPTION, r[0])
       else
         assert_equal(RUBY_DESCRIPTION, r[0])
       end
@@ -221,6 +219,7 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L219
     end
 
     return if RbConfig::CONFIG["MJIT_SUPPORT"] == 'no'
+    return if yjit_force_enabled?
 
     [
       %w(--version --jit --disable=jit),
@@ -1119,4 +1118,8 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L1118
   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
 end
-- 
cgit v1.2.1


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

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