Class: Test::Unit::TestSuiteThreadRunner
- Inherits:
-
TestSuiteRunner
- Object
- TestSuiteRunner
- Test::Unit::TestSuiteThreadRunner
- Defined in:
- lib/test/unit/test-suite-thread-runner.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from TestSuiteRunner
#initialize, n_workers, n_workers=
Constructor Details
This class inherits a constructor from Test::Unit::TestSuiteRunner
Class Method Details
.run_all_tests(result, options) {|run_context| ... } ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/test/unit/test-suite-thread-runner.rb', line 15 def run_all_tests(result, ) n_workers = TestSuiteRunner.n_workers test_suite = [:test_suite] queue = Thread::Queue.new run_context = TestThreadRunContext.new(self, queue) yield(run_context) run_context.progress_block.call(TestSuite::STARTED, test_suite.name) run_context.progress_block.call(TestSuite::STARTED_OBJECT, test_suite) run_context.parallel_unsafe_tests.each(&:call) n_workers.times do queue << nil end workers = [] sub_exceptions = [] n_workers.times do |i| workers << Thread.new(i + 1) do |worker_id| begin loop do task = queue.pop break if task.nil? catch do |stop_tag| task.call(stop_tag, worker_id) end end rescue Exception => exception sub_exceptions << exception end end end workers.each(&:join) run_context.progress_block.call(TestSuite::FINISHED, test_suite.name) run_context.progress_block.call(TestSuite::FINISHED_OBJECT, test_suite) sub_exceptions.each do |exception| raise exception end end |
Instance Method Details
#run(worker_context, &progress_block) ⇒ Object
57 58 59 60 |
# File 'lib/test/unit/test-suite-thread-runner.rb', line 57 def run(worker_context, &progress_block) worker_context.run_context.progress_block = progress_block run_tests_recursive(@test_suite, worker_context, &progress_block) end |