lib/parallel_tests/cli.rb in parallel_tests-1.6.0 vs lib/parallel_tests/cli.rb in parallel_tests-1.6.1

- old
+ new

@@ -33,13 +33,14 @@ 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) + groups.reject! &:empty? test_results = if options[:only_group] - groups_to_run = options[:only_group].collect{|i| groups[i - 1]} + groups_to_run = options[:only_group].collect{|i| groups[i - 1]}.compact report_number_of_tests(groups_to_run) 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 @@ -90,11 +91,12 @@ end def report_number_of_tests(groups) name = @runner.test_file_name num_processes = groups.size - num_tests = groups.map(&:size).inject(:+) - puts "#{num_processes} processes for #{num_tests} #{name}s, ~ #{num_tests / groups.size} #{name}s per process" + num_tests = groups.map(&:size).inject(0, :+) + tests_per_process = (num_processes == 0 ? 0 : num_tests / num_processes) + puts "#{num_processes} processes for #{num_tests} #{name}s, ~ #{tests_per_process} #{name}s per process" end #exit with correct status code so rake parallel:test && echo 123 works def any_test_failed?(test_results) test_results.any? { |result| result[:exit_status] != 0 }