diff options
Diffstat (limited to 'tool/lib/envutil.rb')
| -rw-r--r-- | tool/lib/envutil.rb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tool/lib/envutil.rb b/tool/lib/envutil.rb index ab5e8d84e9..b4c7d1d035 100644 --- a/tool/lib/envutil.rb +++ b/tool/lib/envutil.rb @@ -63,6 +63,14 @@ module EnvUtil end end + if RUBY_ENGINE == "truffleruby" + # Tests relying on timeout have high variance on TruffleRuby due to the highly-optimizing JIT, deoptimization, profiling interpreter, different GC, etc. + # Setting a default timeout scale helps avoid transient failures for tests relying on timeouts. + # We choose 10 because it is the same number used in CRuby CI on macOS: + # https://github.com/ruby/ruby/blob/9d46b0c735877f152a0b4b16b8153c6f395dee28/.github/workflows/macos.yml#L133 + self.timeout_scale = 10 + end + def apply_timeout_scale(t) if scale = EnvUtil.timeout_scale t * scale @@ -104,9 +112,11 @@ module EnvUtil else return unless dpid [[timeout, :TERM], [reprieve, :KILL]].find do |t, sig| - return EnvUtil.timeout(t) {Process.wait(dpid)} - rescue Timeout::Error - Process.kill(sig, dpid) + begin + return EnvUtil.timeout(t) {Process.wait(dpid)} + rescue Timeout::Error + Process.kill(sig, dpid) + end end true end @@ -225,7 +235,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) @@ -276,7 +287,7 @@ module EnvUtil module_function :invoke_ruby def current_parser - features = RUBY_DESCRIPTION[%r{\)\K [-+*/%._0-9a-zA-Z ]*(?=\[[-+*/%._0-9a-zA-Z]+\]\z)}] + 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 |
