class Test::Unit::TestSuiteThreadRunner

Public Class Methods

run_all_tests() { || ... } click to toggle source
# File test-unit-3.6.4/lib/test/unit/test-suite-thread-runner.rb, line 19
def run_all_tests
  n_consumers = TestSuiteRunner.n_workers

  consumers = []
  sub_exceptions = []
  n_consumers.times do |i|
    consumers << Thread.new(i) do |worker_id|
      begin
        loop do
          task = @task_queue.pop
          break if task.nil?
          catch do |stop_tag|
            task.call(stop_tag)
          end
        end
      rescue Exception => exception
        sub_exceptions << exception
      end
    end
  end

  yield

  n_consumers.times do
    @task_queue << nil
  end
  consumers.each(&:join)
  sub_exceptions.each do |exception|
    raise exception
  end
end
task_queue() click to toggle source
# File test-unit-3.6.4/lib/test/unit/test-suite-thread-runner.rb, line 15
def task_queue
  @task_queue
end

Private Instance Methods

run_tests(result, &progress_block) click to toggle source
# File test-unit-3.6.4/lib/test/unit/test-suite-thread-runner.rb, line 53
def run_tests(result, &progress_block)
  @test_suite.tests.each do |test|
    if test.is_a?(TestSuite) or not @test_suite.parallel_safe?
      run_test(test, result, &progress_block)
    else
      task = lambda do |stop_tag|
        sub_result = SubTestResult.new(result)
        sub_result.stop_tag = stop_tag
        run_test(test, sub_result, &progress_block)
      end
      self.class.task_queue << task
    end
  end
end