Fix the current parser detection

Since `RUBY_DESCRIPTION` contains the branch name, `/prism/i` can
match unexpectedly.  Extract the feature lists between revision
and platform infos.
This commit is contained in:
Nobuyoshi Nakada 2025-07-29 19:35:25 +09:00
parent 7ee127d2d1
commit a6914c089d
No known key found for this signature in database
GPG key ID: 3582D74E1FEE4465
2 changed files with 9 additions and 2 deletions

View file

@ -78,7 +78,9 @@ jobs:
- run: make - run: make
- run: make TESTRUN_SCRIPT='-e "exit !RUBY_DESCRIPTION.include?(%[+PRISM])"' run - run: make TESTRUN_SCRIPT='-renvutil -v -e "exit EnvUtil.current_parser == %[parse.y]"' run
env:
RUNOPT0: -I$(tooldir)/lib
- name: make ${{ matrix.test_task }} - name: make ${{ matrix.test_task }}
run: make -s ${{ matrix.test_task }} RUN_OPTS="$RUN_OPTS" SPECOPTS="$SPECOPTS" run: make -s ${{ matrix.test_task }} RUN_OPTS="$RUN_OPTS" SPECOPTS="$SPECOPTS"

View file

@ -226,7 +226,6 @@ module EnvUtil
args = [args] if args.kind_of?(String) args = [args] if args.kind_of?(String)
# use the same parser as current ruby # use the same parser as current ruby
if args.none? { |arg| arg.start_with?("--parser=") } if args.none? { |arg| arg.start_with?("--parser=") }
current_parser = RUBY_DESCRIPTION =~ /prism/i ? "prism" : "parse.y"
args = ["--parser=#{current_parser}"] + args args = ["--parser=#{current_parser}"] + args
end end
pid = spawn(child_env, *precommand, rubybin, *args, opt) pid = spawn(child_env, *precommand, rubybin, *args, opt)
@ -276,6 +275,12 @@ module EnvUtil
end end
module_function :invoke_ruby module_function :invoke_ruby
def current_parser
features = RUBY_DESCRIPTION[%r{\)\K [-+*/%._0-9a-zA-Z ]*(?=\[[-+*/%._0-9a-zA-Z]+\]\z)}]
features&.split&.include?("+PRISM") ? "prism" : "parse.y"
end
module_function :current_parser
def verbose_warning def verbose_warning
class << (stderr = "".dup) class << (stderr = "".dup)
alias write concat alias write concat