Files
ruby/tool/test/test_find_executable.rb
Hiroshi SHIBATAandClaude Fable 5 9272524d00 Keep the original PATH in the EnvUtil.find_executable test
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>
2026-08-20 20:06:05 +09:00

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