exe/benchmark-driver in benchmark_driver-0.4.5 vs exe/benchmark-driver in benchmark_driver-0.5.0

- old
+ new

@@ -1,24 +1,27 @@ #!/usr/bin/env ruby $:.unshift File.expand_path('../lib', __dir__) require 'benchmark/driver' +require 'benchmark/driver/bundle_installer' require 'benchmark/driver/yaml_parser' require 'optparse' require 'yaml' options = {} -args = OptionParser.new do |o| +parser = OptionParser.new do |o| o.banner = "Usage: #{File.basename($0, '.*')} [options] [YAML]" o.on('-e', '--executables [EXECS]', 'Ruby executables (e1::path1,arg1,...; e2::path2,arg2;...)') do |e| + abort '-e, --executable must take argument but not given' if e.nil? options[:execs] ||= [] e.split(';').each do |name_path| name, path = name_path.split('::', 2) options[:execs] << Benchmark::Driver::Configuration::Executable.new(name, path ? path.split(',') : [name]) end end o.on('--rbenv [VERSIONS]', 'Ruby executables in rbenv (x.x.x,arg1,...;y.y.y,arg2,...;...)') do |r| + abort '--rbenv must take argument but not given' if r.nil? options[:execs] ||= [] r.split(';').each do |spec| version, *args = spec.split(',') path = `RBENV_VERSION='#{version}' rbenv which ruby`.rstrip abort "Failed to execute 'rbenv which ruby'" unless $?.success? @@ -37,18 +40,21 @@ end o.on('--filter [REGEXP]', 'Filter out benchmarks with given regexp') do |v| abort '--filter can be used only once' if options.key?(:filter) options[:filter] = v end - o.on('--bundler', 'Use gems specified in Gemfile (append -rbundler/setup)') do |v| + o.on('--bundler', 'Install and use gems specified in Gemfile') do |v| options[:bundler] = v end o.on('--dir', 'Override __dir__ from "/tmp" to actual directory of YAML') do |v| options[:dir] = v end -end.parse!(ARGV) -abort "No YAML file is specified" if args.empty? +end +args = parser.parse!(ARGV) +if args.empty? + abort "No YAML file is specified!\n\n#{parser.help}" +end args.each do |path| yaml = YAML.load(File.read(path)) Benchmark::Driver::Configuration.symbolize_keys!(yaml) @@ -68,9 +74,10 @@ options.each do |key, value| case key when :bundler config.runner_options.executables.each do |executable| + Benchmark::Driver::BundleInstaller.bundle_install_for(executable) executable.command << '-rbundler/setup' end when :compare config.output_options.compare = value when :dir