Skip to content

Commit a6914c0

Browse files
committed
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.
1 parent 7ee127d commit a6914c0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.github/workflows/parse_y.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ jobs:
7878

7979
- run: make
8080

81-
- run: make TESTRUN_SCRIPT='-e "exit !RUBY_DESCRIPTION.include?(%[+PRISM])"' run
81+
- run: make TESTRUN_SCRIPT='-renvutil -v -e "exit EnvUtil.current_parser == %[parse.y]"' run
82+
env:
83+
RUNOPT0: -I$(tooldir)/lib
8284

8385
- name: make ${{ matrix.test_task }}
8486
run: make -s ${{ matrix.test_task }} RUN_OPTS="$RUN_OPTS" SPECOPTS="$SPECOPTS"

tool/lib/envutil.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr =
226226
args = [args] if args.kind_of?(String)
227227
# use the same parser as current ruby
228228
if args.none? { |arg| arg.start_with?("--parser=") }
229-
current_parser = RUBY_DESCRIPTION =~ /prism/i ? "prism" : "parse.y"
230229
args = ["--parser=#{current_parser}"] + args
231230
end
232231
pid = spawn(child_env, *precommand, rubybin, *args, opt)
@@ -276,6 +275,12 @@ def invoke_ruby(args, stdin_data = "", capture_stdout = false, capture_stderr =
276275
end
277276
module_function :invoke_ruby
278277

278+
def current_parser
279+
features = RUBY_DESCRIPTION[%r{\)\K [-+*/%._0-9a-zA-Z ]*(?=\[[-+*/%._0-9a-zA-Z]+\]\z)}]
280+
features&.split&.include?("+PRISM") ? "prism" : "parse.y"
281+
end
282+
module_function :current_parser
283+
279284
def verbose_warning
280285
class << (stderr = "".dup)
281286
alias write concat

0 commit comments

Comments
 (0)