From 0782bd2826eccd1b0d831dfa171bc45fa7687168 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Thu, 7 Aug 2025 15:33:08 -0400 Subject: [PATCH] ZJIT: Use OptionParser in bisect script --- tool/zjit_bisect.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tool/zjit_bisect.rb b/tool/zjit_bisect.rb index 39a302b2bd..fdf204b9f5 100755 --- a/tool/zjit_bisect.rb +++ b/tool/zjit_bisect.rb @@ -1,14 +1,26 @@ #!/usr/bin/env ruby require 'logger' require 'open3' +require 'optparse' require 'shellwords' require 'tempfile' require 'timeout' -RUBY = ARGV[0] || raise("Usage: ruby jit_bisect.rb ") +ARGS = {:timeout => 5} +OptionParser.new do |opts| + opts.banner += " -- " + opts.on("--timeout=TIMEOUT_SEC", "Seconds until child process is killed") do |timeout| + ARGS[:timeout] = Integer(timeout) + end + opts.on("-h", "--help", "Prints this help") do + puts opts + exit + end +end.parse! + +RUBY = ARGV[0] || raise("Usage: ruby jit_bisect.rb -- ") OPTIONS = ARGV[1..] raise("Usage: ruby jit_bisect.rb -- ") if OPTIONS.empty? -TIMEOUT_SEC = 5 LOGGER = Logger.new($stdout) # From https://github.com/tekknolagi/omegastar @@ -87,7 +99,7 @@ end LOGGER.info("Starting with JIT list of #{jit_list.length} items.") # Now narrow it down command = lambda do |items| - status = Timeout.timeout(TIMEOUT_SEC) do + status = Timeout.timeout(ARGS[:timeout]) do _, _, status = run_with_jit_list(RUBY, OPTIONS, items) status end