class ParallelTests::CLI
def parse_options!(argv)
def parse_options!(argv) options = {} OptionParser.new do |opts| opts.banner = <<BANNER all tests in parallel, giving each process ENV['TEST_ENV_NUMBER'] ('', '2', '3', ...) ional] Only run selected files & folders: parallel_test test/bar test/baz/xxx_text.rb ons are: ER opts.on("-n [PROCESSES]", Integer, "How many processes to use, default: available CPUs") { |n| options[:count] = n } opts.on("-p", "--pattern [PATTERN]", "run tests matching this pattern") { |pattern| options[:pattern] = /#{pattern}/ } opts.on("--group-by [TYPE]", <<-TEXT p tests by: found - order of finding files steps - number of cucumber steps default - runtime or filesize |type| options[:group_by] = type.to_sym } opts.on("-m [FLOAT]", "--multiply-processes [FLOAT]", Float, "use given number as a multiplier of processes to run") { |multiply| options[:multiply] = multiply } opts.on("-s [PATTERN]", "--single [PATTERN]", "Run all matching files in the same process") do |pattern| options[:single_process] ||= [] options[:single_process] << /#{pattern}/ end opts.on("-i", "--isolate", "Do not run any other tests in the group used by --single(-s)") do |pattern| options[:isolate] = true end opts.on("-e", "--exec [COMMAND]", "execute this code parallel and with ENV['TEST_ENV_NUM']") { |path| options[:execute] = path } opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = arg } opts.on("-t", "--type [TYPE]", "test(default) / rspec / cucumber") do |type| begin @runner = load_runner(type) rescue NameError, LoadError => e puts "Runner for `#{type}` type has not been found! (#{e})" abort end end opts.on("--serialize-stdout", "Serialize stdout output, nothing will be written until everything is done") { options[:serialize_stdout] = true } opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec") { options[:non_parallel] = true } opts.on("--no-symlinks", "Do not traverse symbolic links to find test files") { options[:symlinks] = false } opts.on('--ignore-tags [PATTERN]', 'When counting steps ignore scenarios with tags that match this pattern') { |arg| options[:ignore_tag_pattern] = arg } opts.on("--nice", "execute test commands with low priority.") { options[:nice] = true } opts.on("-v", "--version", "Show Version") { puts ParallelTests::VERSION; exit } opts.on("-h", "--help", "Show this.") { puts opts; exit } end.parse!(argv) raise "--group-by found and --single-process are not supported" if options[:group_by] == :found and options[:single_process] if options[:count] == 0 options.delete(:count) options[:non_parallel] = true end options[:files] = argv options end