Class: Minitest::Parallel::Executor
- Defined in:
- opal/stdlib/minitest/parallel.rb
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.
Constructor Details
#initialize(size) ⇒ Executor
Create a parallel test executor of with +size+ workers.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'opal/stdlib/minitest/parallel.rb', line 17 def initialize size @size = size @queue = Queue.new # @pool = size.times.map { # Thread.new(@queue) do |queue| # Thread.current.abort_on_exception = true # while job = queue.pop # klass, method, reporter = job # result = Minitest.run_one_method klass, method # reporter.synchronize { reporter.record result } # end # end # } end |
Instance Attribute Details
#size ⇒ Object (readonly)
The size of the pool of workers.
12 13 14 |
# File 'opal/stdlib/minitest/parallel.rb', line 12 def size @size end |
Instance Method Details
#<<(work) ⇒ Object
Add a job to the queue
35 |
# File 'opal/stdlib/minitest/parallel.rb', line 35 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.
42 43 44 45 46 47 48 49 50 51 |
# File 'opal/stdlib/minitest/parallel.rb', line 42 def shutdown # size.times { @queue << nil } # @pool.each(&:join) @queue.each do |job| klass, method, reporter = job result = Minitest.run_one_method klass, method reporter.record result # reporter.synchronize { reporter.record result } end end |