From 7a3a98e2be69fd3fa68e6ee1afa43c3160f22254 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 17 Oct 2023 17:47:13 -0700 Subject: [PATCH] YJIT: Use RbConfig.ruby instead of EnvUtil.rubybin (#8689) Some people encounter an issue that test_yjit uses the installed Ruby instead of the currently-running Ruby. It's fixed when they remove the installed Ruby. However, test_yjit should run the currently-running Ruby for testing YJIT in subprocesses. EnvUtil is unfortunately used outside tests as well, so for compatibility reasons, this commit only changes the argument given to EnvUtil.invoke_ruby to always use RbConfig.ruby. Co-authored-by: Alan Wu --- test/ruby/test_yjit.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index d820b052b1..4066664600 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -75,7 +75,7 @@ class TestYJIT < Test::Unit::TestCase end def test_yjit_stats_and_v_no_error - _stdout, stderr, _status = EnvUtil.invoke_ruby(%w(-v --yjit-stats), '', true, true) + _stdout, stderr, _status = invoke_ruby(%w(-v --yjit-stats), '', true, true) refute_includes(stderr, "NoMethodError") end @@ -1504,9 +1504,7 @@ class TestYJIT < Test::Unit::TestCase stats = stats_r.read stats_r.close end - out, err, status = EnvUtil.invoke_ruby(args, - '', true, true, timeout: timeout, ios: {3 => stats_w} - ) + out, err, status = invoke_ruby(args, '', true, true, timeout: timeout, ios: { 3 => stats_w }) stats_w.close stats_reader.join(timeout) stats = Marshal.load(stats) if !stats.empty? @@ -1517,4 +1515,10 @@ class TestYJIT < Test::Unit::TestCase stats_r&.close stats_w&.close end + + # A wrapper of EnvUtil.invoke_ruby that uses RbConfig.ruby instead of EnvUtil.ruby + # that might use a wrong Ruby depending on your environment. + def invoke_ruby(*args, **kwargs) + EnvUtil.invoke_ruby(*args, rubybin: RbConfig.ruby, **kwargs) + end end