Minitest::Parallel::Executor

class Minitest::Parallel::Executor

Parent:
Object

The engine used to run multiple tests in parallel.

Attributes

size[R]

The size of the pool of workers.

Public Class Methods

new(size) Show source

Create a parallel test executor of with size workers.

# File lib/minitest/parallel.rb, line 17
def initialize size
  @size  = size
  @queue = Queue.new
  @pool  = nil
end

Public Instance Methods

<<(work;) Show source

Add a job to the queue

# File lib/minitest/parallel.rb, line 42
def << work; @queue << work; end
shutdown() Show source

Shuts down the pool of workers by signalling them to quit and waiting for them all to finish what they're currently working on.

# File lib/minitest/parallel.rb, line 49
def shutdown
  size.times { @queue << nil }
  @pool.each(&:join)
end
start() Show source

Start the executor

# 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
        result = Minitest.run_one_method klass, method
        reporter.synchronize { reporter.record result }
      end
    end
  }
end

© Ryan Davis, seattle.rb
Licensed under the MIT License.

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部