lib/parallel_tests/cli.rb in parallel_tests-0.16.7 vs lib/parallel_tests/cli.rb in parallel_tests-0.16.8

- old
+ new

@@ -32,14 +32,21 @@ def run_tests_in_parallel(num_processes, options) test_results = nil report_time_taken do groups = @runner.tests_in_groups(options[:files], num_processes, options) - report_number_of_tests(groups) - test_results = execute_in_parallel(groups, groups.size, options) do |group| - run_tests(group, groups.index(group), num_processes, options) + test_results = if options[:only_group] + group_to_run = groups[options[:only_group] - 1] + + [run_tests(group_to_run, 0, num_processes, options)] + else + report_number_of_tests(groups) + + execute_in_parallel(groups, groups.size, options) do |group| + run_tests(group, groups.index(group), num_processes, options) + end end report_results(test_results) end @@ -96,10 +103,11 @@ opts.on("--group-by [TYPE]", <<-TEXT group tests by: found - order of finding files steps - number of cucumber/spinach steps scenarios - individual cucumber scenarios + filesize - by size of the file default - runtime or filesize TEXT ) { |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 } @@ -114,10 +122,12 @@ "Do not run any other tests in the group used by --single(-s)") do |pattern| options[:isolate] = true end + opts.on("--only-group [INTEGER]", Integer) { |group| options[:only_group] = group } + 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 / spinach") do |type| begin @runner = load_runner(type) @@ -133,17 +143,21 @@ 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[:group_by] ||= :filesize if options[:only_group] + + raise "--group-by found and --single-process are not supported" if options[:group_by] == :found and options[:single_process] + raise "--group-by filesize is required for --only-group" if options[:group_by] != :filesize and options[:only_group] + options end def load_runner(type) require "parallel_tests/#{type}/runner"