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

ruby-changes:56399

From: Hiroshi <ko1@a...>
Date: Tue, 9 Jul 2019 21:06:55 +0900 (JST)
Subject: [ruby-changes:56399] Hiroshi SHIBATA: f9a2440866 (master): Restore support library for only test files.

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

From f9a2440866a2df05fcbacf31c4f4e5e18b996e15 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Tue, 9 Jul 2019 21:04:07 +0900
Subject: Restore support library for only test files.


diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb
new file mode 100644
index 0000000..c1624cc
--- /dev/null
+++ b/test/lib/jit_support.rb
@@ -0,0 +1,68 @@ https://github.com/ruby/ruby/blob/trunk/test/lib/jit_support.rb#L1
+require 'rbconfig'
+
+module JITSupport
+  JIT_TIMEOUT = 600 # 10min for each...
+  JIT_SUCCESS_PREFIX = 'JIT success \(\d+\.\dms\)'
+  UNSUPPORTED_COMPILERS = [
+    %r[\Aicc\b],
+    %r[\A/opt/developerstudio\d+\.\d+/bin/cc\z],
+  ]
+
+  module_function
+  # Run Ruby script with --jit-wait (Synchronous JIT compilation).
+  # Returns [stdout, stderr]
+  def eval_with_jit(env = nil, script, **opts)
+    stdout, stderr = nil, nil
+    # retry 3 times while cc1 error happens.
+    3.times do |i|
+      stdout, stderr, status = eval_with_jit_without_retry(env, script, **opts)
+      assert_equal(true, status.success?, "Failed to run script with JIT:\n#{code_block(script)}\nstdout:\n#{code_block(stdout)}\nstderr:\n#{code_block(stderr)}")
+      break unless retried_stderr?(stderr)
+    end
+    [stdout, stderr]
+  end
+
+  def eval_with_jit_without_retry(env = nil, script, verbose: 0, min_calls: 5, save_temps: false, max_cache: 1000, wait: true, timeout: JIT_TIMEOUT)
+    args = [
+      '--disable-gems', "--jit-verbose=#{verbose}",
+      "--jit-min-calls=#{min_calls}", "--jit-max-cache=#{max_cache}",
+    ]
+    args << '--jit-wait' if wait
+    args << '--jit-save-temps' if save_temps
+    args << '-e' << script
+    base_env = { 'MJIT_SEARCH_BUILD_DIR' => 'true' } # workaround to skip requiring `make install` for `make test-all`
+    if preloadenv = RbConfig::CONFIG['PRELOADENV'] and !preloadenv.empty?
+      so = "mjit_build_dir.#{RbConfig::CONFIG['SOEXT']}"
+      base_env[preloadenv] = File.realpath(so) rescue nil
+    end
+    args.unshift(env ? base_env.merge!(env) : base_env)
+    EnvUtil.invoke_ruby(args,
+      '', true, true, timeout: timeout,
+    )
+  end
+
+  def supported?
+    return @supported if defined?(@supported)
+    @supported = UNSUPPORTED_COMPILERS.all? do |regexp|
+      !regexp.match?(RbConfig::CONFIG['CC'])
+    end
+  end
+
+  def remove_mjit_logs(stderr)
+    if RubyVM::MJIT.enabled? # utility for -DFORCE_MJIT_ENABLE
+      stderr.gsub(/^MJIT warning: Skipped to compile unsupported instruction: \w+\n/m, '')
+    else
+      stderr
+    end
+  end
+
+  def code_block(code)
+    %Q["""\n#{code}\n"""\n\n]
+  end
+
+  # We're retrying cc1 not found error on gcc, which should be solved in the future but ignored for now.
+  def retried_stderr?(stderr)
+    RbConfig::CONFIG['CC'].start_with?('gcc') &&
+      stderr.include?("error trying to exec 'cc1': execvp: No such file or directory")
+  end
+end
diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb
index 08494cb..0cfc980 100644
--- a/test/ruby/test_jit.rb
+++ b/test/ruby/test_jit.rb
@@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L1
 # frozen_string_literal: true
 require 'test/unit'
 require 'tmpdir'
-require_relative '../../tool/lib/jit_support'
+require_relative '../lib/jit_support'
 
 return if RbConfig::CONFIG["MJIT_SUPPORT"] == 'no'
 
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 0d22ba2..c92d0e8 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -4,7 +4,7 @@ require 'test/unit' https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L4
 require 'timeout'
 require 'tmpdir'
 require 'tempfile'
-require_relative '../../tool/lib/jit_support'
+require_relative '../lib/jit_support'
 
 class TestRubyOptions < Test::Unit::TestCase
   NO_JIT_DESCRIPTION =
diff --git a/test/ruby/test_rubyvm_mjit.rb b/test/ruby/test_rubyvm_mjit.rb
index ae55d58..1277232 100644
--- a/test/ruby/test_rubyvm_mjit.rb
+++ b/test/ruby/test_rubyvm_mjit.rb
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyvm_mjit.rb#L1
 # frozen_string_literal: true
 require 'test/unit'
-require_relative '../../tool/lib/jit_support'
+require_relative '../lib/jit_support'
 
 return if RbConfig::CONFIG["MJIT_SUPPORT"] == 'no'
 
diff --git a/test/test_open3.rb b/test/test_open3.rb
index c3a4e0a..24bd08e 100644
--- a/test/test_open3.rb
+++ b/test/test_open3.rb
@@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/test/test_open3.rb#L2
 
 require 'test/unit'
 require 'open3'
-require_relative '../tool/lib/jit_support'
+require_relative 'lib/jit_support'
 
 class TestOpen3 < Test::Unit::TestCase
   RUBY = EnvUtil.rubybin
diff --git a/tool/lib/jit_support.rb b/tool/lib/jit_support.rb
deleted file mode 100644
index c1624cc..0000000
--- a/tool/lib/jit_support.rb
+++ /dev/null
@@ -1,68 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/test/test_open3.rb#L0
-require 'rbconfig'
-
-module JITSupport
-  JIT_TIMEOUT = 600 # 10min for each...
-  JIT_SUCCESS_PREFIX = 'JIT success \(\d+\.\dms\)'
-  UNSUPPORTED_COMPILERS = [
-    %r[\Aicc\b],
-    %r[\A/opt/developerstudio\d+\.\d+/bin/cc\z],
-  ]
-
-  module_function
-  # Run Ruby script with --jit-wait (Synchronous JIT compilation).
-  # Returns [stdout, stderr]
-  def eval_with_jit(env = nil, script, **opts)
-    stdout, stderr = nil, nil
-    # retry 3 times while cc1 error happens.
-    3.times do |i|
-      stdout, stderr, status = eval_with_jit_without_retry(env, script, **opts)
-      assert_equal(true, status.success?, "Failed to run script with JIT:\n#{code_block(script)}\nstdout:\n#{code_block(stdout)}\nstderr:\n#{code_block(stderr)}")
-      break unless retried_stderr?(stderr)
-    end
-    [stdout, stderr]
-  end
-
-  def eval_with_jit_without_retry(env = nil, script, verbose: 0, min_calls: 5, save_temps: false, max_cache: 1000, wait: true, timeout: JIT_TIMEOUT)
-    args = [
-      '--disable-gems', "--jit-verbose=#{verbose}",
-      "--jit-min-calls=#{min_calls}", "--jit-max-cache=#{max_cache}",
-    ]
-    args << '--jit-wait' if wait
-    args << '--jit-save-temps' if save_temps
-    args << '-e' << script
-    base_env = { 'MJIT_SEARCH_BUILD_DIR' => 'true' } # workaround to skip requiring `make install` for `make test-all`
-    if preloadenv = RbConfig::CONFIG['PRELOADENV'] and !preloadenv.empty?
-      so = "mjit_build_dir.#{RbConfig::CONFIG['SOEXT']}"
-      base_env[preloadenv] = File.realpath(so) rescue nil
-    end
-    args.unshift(env ? base_env.merge!(env) : base_env)
-    EnvUtil.invoke_ruby(args,
-      '', true, true, timeout: timeout,
-    )
-  end
-
-  def supported?
-    return @supported if defined?(@supported)
-    @supported = UNSUPPORTED_COMPILERS.all? do |regexp|
-      !regexp.match?(RbConfig::CONFIG['CC'])
-    end
-  end
-
-  def remove_mjit_logs(stderr)
-    if RubyVM::MJIT.enabled? # utility for -DFORCE_MJIT_ENABLE
-      stderr.gsub(/^MJIT warning: Skipped to compile unsupported instruction: \w+\n/m, '')
-    else
-      stderr
-    end
-  end
-
-  def code_block(code)
-    %Q["""\n#{code}\n"""\n\n]
-  end
-
-  # We're retrying cc1 not found error on gcc, which should be solved in the future but ignored for now.
-  def retried_stderr?(stderr)
-    RbConfig::CONFIG['CC'].start_with?('gcc') &&
-      stderr.include?("error trying to exec 'cc1': execvp: No such file or directory")
-  end
-end
-- 
cgit v0.10.2


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

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