lib/parallel_tests/cli.rb in parallel_tests-4.6.1 vs lib/parallel_tests/cli.rb in parallel_tests-4.7.0

- old
+ new

@@ -94,12 +94,13 @@ 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] + exit_status = if options[:failure_exit_code] + options[:failure_exit_code] + elsif options[:highest_exit_status] test_results.map { |data| data.fetch(:exit_status) }.max else 1 end @@ -221,25 +222,32 @@ end opts.on( "--isolate-n [PROCESSES]", Integer, - "Use 'isolate' singles with number of processes, default: 1." + "Use 'isolate' singles with number of processes, default: 1" ) { |n| options[:isolate_count] = n } - opts.on("--highest-exit-status", "Exit with the highest exit status provided by test run(s)") do - options[:highest_exit_status] = true - end + opts.on( + "--highest-exit-status", + "Exit with the highest exit status provided by test run(s)" + ) { options[:highest_exit_status] = true } opts.on( + "--failure-exit-code [INT]", + Integer, + "Specify the exit code to use when tests fail" + ) { |code| options[:failure_exit_code] = code } + + opts.on( "--specify-groups [SPECS]", <<~TEXT.rstrip.split("\n").join("\n#{newline_padding}") Use 'specify-groups' if you want to specify multiple specs running in multiple processes in a specific formation. Commas indicate specs in the same process, pipes indicate specs in a new process. Cannot use with --single, --isolate, or --isolate-n. Ex. - $ parallel_test -n 3 . --specify-groups '1_spec.rb,2_spec.rb|3_spec.rb' + $ parallel_tests -n 3 . --specify-groups '1_spec.rb,2_spec.rb|3_spec.rb' Process 1 will contain 1_spec.rb and 2_spec.rb Process 2 will contain 3_spec.rb Process 3 will contain all other specs TEXT ) { |groups| options[:specify_groups] = groups } @@ -327,9 +335,13 @@ raise "--group-by #{allowed.join(" or ")} is required for --only-group" end if options[:specify_groups] && (options.keys & [:single_process, :isolate, :isolate_count]).any? raise "Can't pass --specify-groups with any of these keys: --single, --isolate, or --isolate-n" + end + + if options[:failure_exit_code] && options[:highest_exit_status] + raise "Can't pass --failure-exit-code and --highest-exit-status" end options end