Class: Loupe::ProcessExecutor
- Defined in:
- lib/loupe/process_executor.rb
Overview
ProcessExecutor
This class is responsible for executing tests in process mode.
Instance Method Summary collapse
-
#initialize(options) ⇒ Loupe::Executor
constructor
Create a new ProcessExecutor.
-
#run ⇒ Integer
run.
Constructor Details
#initialize(options) ⇒ Loupe::Executor
Create a new ProcessExecutor
This will create a new server object that will be shared with child processes using DRb
16 17 18 19 20 21 |
# File 'lib/loupe/process_executor.rb', line 16 def initialize() super @server = QueueServer.new(populate_queue, @reporter) @url = DRb.start_service("drbunix:", @server).uri end |
Instance Method Details
#run ⇒ Integer
run
Fork each one of the process workers and connect with the server object coming from DRb. Run until the queue is clear
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/loupe/process_executor.rb', line 28 def run @workers = (0...[Etc.nprocessors, @server.length].min).map do fork do DRb.start_service server = DRbObject.new_with_uri(@url) until server.empty? klass, method_name = server.pop server.add_reporter(klass.run(method_name, @options)) if klass && method_name end end end shutdown @reporter.print_summary @reporter.exit_status end |