Set Ruby parser if the given ruby accepts --parser

Now envutil.rb is a part of test-unit-ruby-core gem, which still
supports old versions, 2.3 or later.
This commit is contained in:
Nobuyoshi Nakada 2025-10-03 21:27:03 +09:00
parent 5b2ec0eb1b
commit 52287c68ab
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465

View File

@ -225,7 +225,8 @@ module EnvUtil
args = [args] if args.kind_of?(String)
# use the same parser as current ruby
if args.none? { |arg| arg.start_with?("--parser=") }
if (args.none? { |arg| arg.start_with?("--parser=") } and
/^ +--parser=/ =~ IO.popen([rubybin, "--help"], &:read))
args = ["--parser=#{current_parser}"] + args
end
pid = spawn(child_env, *precommand, rubybin, *args, opt)