Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fail fast #767

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -8,7 +8,7 @@

### Added

- None
- `--fail-fast` options which stops all threads if one of them return not zero exit code. Which add possibility to stop whole suite if one test failed. Works if the option `--fail-fast` enabled for the rspec (passed to the test_options: `--test-options '--fail-fast'` or enabled at the .rspec_parallel file).

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions lib/parallel_tests/cli.rb
Expand Up @@ -44,6 +44,7 @@ def execute_in_parallel(items, num_processes, options)
simulate_output_for_ci options[:serialize_stdout] do
Parallel.map(items, :in_threads => num_processes) do |item|
result = yield(item)
ParallelTests.stop_all_processes if result[:exit_status] != 0 && options[:fail_fast]
reprint_output(result, lock.path) if options[:serialize_stdout]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • should go after the printing ?
  • parallel has raise Parallel::Kill, that should work too ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I will change the order

  • raise the exception doesn't seems to be right solution. I would expect that tests will shutdown softly after running they after hooks, where they could perform cleaning code.

result
end
Expand Down Expand Up @@ -220,6 +221,7 @@ def parse_options!(argv)
opts.on("--allowed-missing [INT]", Integer, "Allowed percentage of missing runtimes (default = 50)") { |percent| options[:allowed_missing_percent] = percent }
opts.on("--unknown-runtime [FLOAT]", Float, "Use given number as unknown runtime (otherwise use average time)") { |time| options[:unknown_runtime] = time }
opts.on("--first-is-1", "Use \"1\" as TEST_ENV_NUMBER to not reuse the default test environment") { options[:first_is_1] = true }
opts.on("--fail-fast", "Stop running the test suite on the first failed test") { options[:fail_fast] = true }
opts.on("--verbose", "Print debug output") { options[:verbose] = true }
opts.on("--verbose-process-command", "Displays only the command that will be executed by each process") { options[:verbose_process_command] = true }
opts.on("--verbose-rerun-command", "When there are failures, displays the command executed by each process that failed") { options[:verbose_rerun_command] = true }
Expand Down