mirror of
https://github.com/ruby/ruby.git
synced 2026-10-29 00:46:26 +08:00
Replacing PATH with only the build directory breaks the spawned ruby.exe on MSYS2 UCRT64, where the Windows DLL loader needs PATH to resolve libgmp-10.dll linked into the ruby DLL. Prepend the directory instead so the build ruby is still found first. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
27 lines
753 B
Ruby
27 lines
753 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "test/unit"
|
|
require "rbconfig"
|
|
require "find_executable"
|
|
|
|
class TestFindExecutable < Test::Unit::TestCase
|
|
def test_find_executable_returns_command_and_arguments
|
|
ruby = RbConfig.ruby
|
|
command = File.basename(ruby, RbConfig::CONFIG["EXEEXT"])
|
|
original_path = ENV["PATH"]
|
|
ENV["PATH"] = File.dirname(ruby) + File::PATH_SEPARATOR + original_path
|
|
|
|
found = EnvUtil.find_executable(command, "--version") do |output|
|
|
output.start_with?("ruby ")
|
|
end
|
|
|
|
assert_equal([ruby, "--version"], found)
|
|
ensure
|
|
ENV["PATH"] = original_path
|
|
end
|
|
|
|
def test_find_executable_returns_nil_for_unknown_command
|
|
assert_nil(EnvUtil.find_executable("test-unit-ruby-core-missing") { true })
|
|
end
|
|
end
|