123456789_123456789_123456789_123456789_123456789_

Class: Test::Unit::TestSuiteThreadRunner

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Test::Unit::TestSuiteRunner
Defined in: lib/test/unit/test-suite-thread-runner.rb

Class Attribute Summary

Class Method Summary

Instance Method Summary

Constructor Details

This class inherits a constructor from Test::Unit::TestSuiteRunner

Class Method Details

.run_all_tests

[ GitHub ]

  
# File '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

[ GitHub ]

  
# File 'lib/test/unit/test-suite-thread-runner.rb', line 15

def task_queue
  @task_queue
end

Instance Method Details

#run_tests(result, &progress_block) (private)

[ GitHub ]

  
# File '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