Skip to content

Commit 0782bd2

Browse files
committed
ZJIT: Use OptionParser in bisect script
1 parent fd6d6a4 commit 0782bd2

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tool/zjit_bisect.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
#!/usr/bin/env ruby
22
require 'logger'
33
require 'open3'
4+
require 'optparse'
45
require 'shellwords'
56
require 'tempfile'
67
require 'timeout'
78

8-
RUBY = ARGV[0] || raise("Usage: ruby jit_bisect.rb <path_to_ruby> <options>")
9+
ARGS = {:timeout => 5}
10+
OptionParser.new do |opts|
11+
opts.banner += " <path_to_ruby> -- <options>"
12+
opts.on("--timeout=TIMEOUT_SEC", "Seconds until child process is killed") do |timeout|
13+
ARGS[:timeout] = Integer(timeout)
14+
end
15+
opts.on("-h", "--help", "Prints this help") do
16+
puts opts
17+
exit
18+
end
19+
end.parse!
20+
21+
RUBY = ARGV[0] || raise("Usage: ruby jit_bisect.rb <path_to_ruby> -- <options>")
922
OPTIONS = ARGV[1..]
1023
raise("Usage: ruby jit_bisect.rb <path_to_ruby> -- <options>") if OPTIONS.empty?
11-
TIMEOUT_SEC = 5
1224
LOGGER = Logger.new($stdout)
1325

1426
# From https://github.com/tekknolagi/omegastar
@@ -87,7 +99,7 @@ def run_with_jit_list(ruby, options, jit_list)
8799
LOGGER.info("Starting with JIT list of #{jit_list.length} items.")
88100
# Now narrow it down
89101
command = lambda do |items|
90-
status = Timeout.timeout(TIMEOUT_SEC) do
102+
status = Timeout.timeout(ARGS[:timeout]) do
91103
_, _, status = run_with_jit_list(RUBY, OPTIONS, items)
92104
status
93105
end

0 commit comments

Comments
 (0)