Class: Minitest::Parallel::Executor
Overview
The engine used to run multiple tests in parallel.
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
The size of the pool of workers.
Instance Method Summary collapse
-
#<<(work) ⇒ Object
Add a job to the queue.
-
#initialize(size) ⇒ Executor
constructor
Create a parallel test executor of with
size
workers. -
#shutdown ⇒ Object
Shuts down the pool of workers by signalling them to quit and waiting for them all to finish what they’re currently working on.
-
#start ⇒ Object
Start the executor.
Constructor Details
#initialize(size) ⇒ Executor
Create a parallel test executor of with size
workers.
17 18 19 20 21 |
# File 'lib/minitest/parallel.rb', line 17 def initialize size @size = size @queue = Queue.new @pool = nil end |
Instance Attribute Details
#size ⇒ Object (readonly)
The size of the pool of workers.
12 13 14 |
# File 'lib/minitest/parallel.rb', line 12 def size @size end |
Instance Method Details
#<<(work) ⇒ Object
Add a job to the queue
43 |
# File 'lib/minitest/parallel.rb', line 43 def << work; @queue << work; end |
#shutdown ⇒ Object
Shuts down the pool of workers by signalling them to quit and waiting for them all to finish what they’re currently working on.
50 51 52 53 |
# File 'lib/minitest/parallel.rb', line 50 def shutdown size.times { @queue << nil } @pool.each(&:join) end |
#start ⇒ Object
Start the executor
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/minitest/parallel.rb', line 26 def start @pool = size.times.map { Thread.new(@queue) do |queue| Thread.current.abort_on_exception = true while (job = queue.pop) klass, method, reporter = job reporter.synchronize { reporter.prerecord klass, method } result = Minitest.run_one_method klass, method reporter.synchronize { reporter.record result } end end } end |