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
sizeworkers. -
#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.
19 20 21 22 23 |
# File 'lib/minitest/parallel.rb', line 19 def initialize size @size = size @queue = Thread::Queue.new @pool = nil end |
Instance Attribute Details
#size ⇒ Object (readonly)
The size of the pool of workers.
14 15 16 |
# File 'lib/minitest/parallel.rb', line 14 def size @size end |
Instance Method Details
#<<(work) ⇒ Object
Add a job to the queue
45 |
# File 'lib/minitest/parallel.rb', line 45 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.
52 53 54 55 |
# File 'lib/minitest/parallel.rb', line 52 def shutdown size.times { @queue << nil } @pool.each(&:join) end |
#start ⇒ Object
Start the executor
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/minitest/parallel.rb', line 28 def start @pool = Array.new(size) { Thread.new @queue do |queue| Thread.current.abort_on_exception = true while job = queue.pop do 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 |