module RSpec::Parallel::RSpec::Core::ExampleGroup

Public Class Methods

run_examples_parallel(reporter, threads, mutex) click to toggle source

@private Runs the examples in this group in a separate thread each

# File lib/rspec/parallel.rb, line 76
def run_examples_parallel(reporter, threads, mutex)
  filtered_examples.ordered.map do |example|
    next if RSpec.wants_to_quit
    instance = new
    set_ivars(instance, before_all_ivars)
    mutex.synchronize do
      threads.run(example, instance, reporter)
    end
    RSpec.wants_to_quit = true if fail_fast?
  end
end
run_parallel(reporter, num_threads, mutex, used_threads) click to toggle source

Runs all the examples in this group in a separate thread for each

# File lib/rspec/parallel.rb, line 51
def run_parallel(reporter, num_threads, mutex, used_threads)
  if RSpec.wants_to_quit
    RSpec.clear_remaining_example_groups if top_level?
    return
  end
  reporter.example_group_started(self)

  begin
    run_before_all_hooks(new)
    example_threads = RSpec::Parallel::ExampleThreadRunner.new(num_threads, used_threads)
    run_examples_parallel(reporter, example_threads, mutex)
    children.ordered.map {|child| child.run_parallel(reporter, num_threads, mutex, used_threads)}
    example_threads.wait_for_completion
  rescue Exception => ex
    RSpec.wants_to_quit = true if fail_fast?
    fail_filtered_examples(ex, reporter)
  ensure
    run_after_all_hooks(new)
    before_all_ivars.clear
    reporter.example_group_finished(self)
  end
end