class ParallelTests::CLI
def run_tests_in_parallel(num_processes, options)
def run_tests_in_parallel(num_processes, options) test_results = nil run_tests_proc = -> do groups = @runner.tests_in_groups(options[:files], num_processes, options) groups.reject!(&:empty?) test_results = if options[:only_group] groups_to_run = options[:only_group].map { |i| groups[i - 1] }.compact report_number_of_tests(groups_to_run) unless options[:quiet] execute_in_parallel(groups_to_run, groups_to_run.size, options) do |group| run_tests(group, groups_to_run.index(group), 1, options) end else report_number_of_tests(groups) unless options[:quiet] execute_in_parallel(groups, groups.size, options) do |group| run_tests(group, groups.index(group), num_processes, options) end end report_results(test_results, options) unless options[:quiet] end if options[:quiet] run_tests_proc.call else report_time_taken(&run_tests_proc) end if any_test_failed?(test_results) warn final_fail_message # return the highest exit status to allow sub-processes to send things other than 1 exit_status = if options[:highest_exit_status] test_results.map { |data| data.fetch(:exit_status) }.max else 1 end exit exit_status end end