Class: RSpec::MultiprocessRunner::Coordinator
- Inherits:
-
Object
- Object
- RSpec::MultiprocessRunner::Coordinator
- Defined in:
- lib/rspec/multiprocess_runner/coordinator.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #exit_code ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(worker_count, files, options) ⇒ Coordinator
constructor
A new instance of Coordinator.
- #run ⇒ Object
- #shutdown(options = {}) ⇒ Object
Constructor Details
#initialize(worker_count, files, options) ⇒ Coordinator
Returns a new instance of Coordinator.
10 11 12 13 14 15 16 17 |
# File 'lib/rspec/multiprocess_runner/coordinator.rb', line 10 def initialize(worker_count, files, ) self. = @file_buffer = [] @workers = [] @stopped_workers = [] @worker_results = [] @file_coordinator = FileCoordinator.new(files, ) end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/rspec/multiprocess_runner/coordinator.rb', line 8 def @options end |
Instance Method Details
#exit_code ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/rspec/multiprocess_runner/coordinator.rb', line 41 def exit_code exit_code = 0 exit_code |= 1 if any_example_failed? exit_code |= 2 if failed_workers.any? || .any? exit_code |= 4 if work_left_to_do? || @file_coordinator.missing_files.any? exit_code end |
#failed? ⇒ Boolean
37 38 39 |
# File 'lib/rspec/multiprocess_runner/coordinator.rb', line 37 def failed? 0 < exit_code end |
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rspec/multiprocess_runner/coordinator.rb', line 19 def run @start_time = Time.now expected_worker_numbers.each do |n| create_and_start_worker_if_necessary(n) end run_loop quit_all_workers @file_coordinator.finished if @file_coordinator.remaining_files.any? run_loop quit_all_workers @file_coordinator.finished end print_summary exit_code end |
#shutdown(options = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rspec/multiprocess_runner/coordinator.rb', line 49 def shutdown(={}) if @shutting_down # Immediately kill the workers if shutdown is requested again end_workers_in_parallel(@workers.dup, :kill_now) else @shutting_down = true print "Shutting down #{pluralize(@workers.size, "worker")} …" if [:print_summary] # end_workers_in_parallel modifies @workers, so dup before sending in end_workers_in_parallel(@workers.dup, :shutdown_now) if [:print_summary] puts " done" print_summary end end end |