Sha256: 2f1a4ff5810024ff6e513d7f1a623b35026180a022e0e1af692fca32676e340d

Contents?: true

Size: 1.44 KB

Versions: 5

Compression:

Stored size: 1.44 KB

Contents

require 'test_queue/runner'

gem 'test-unit'
require 'test/unit'
require 'test/unit/collector/descendant'
require 'test/unit/testresult'
require 'test/unit/testsuite'
require 'test/unit/ui/console/testrunner'

class Test::Unit::TestSuite
  attr_accessor :iterator

  def run(result, &progress_block)
    @start_time = Time.now
    yield(STARTED, name)
    yield(STARTED_OBJECT, self)
    run_startup(result)
    (@iterator || @tests).each do |test|
      @n_tests += test.size
      run_test(test, result, &progress_block)
      @passed = false unless test.passed?
    end
    run_shutdown(result)
  ensure
    @elapsed_time = Time.now - @start_time
    yield(FINISHED, name)
    yield(FINISHED_OBJECT, self)
  end
end

module TestQueue
  class Runner
    class TestUnit < Runner
      def initialize
        @suite = Test::Unit::Collector::Descendant.new.collect
        tests = @suite.tests.sort_by{ |s| -(stats[s.to_s] || 0) }
        super(tests)
      end

      def run_worker(iterator)
        @suite.iterator = iterator
        res = Test::Unit::UI::Console::TestRunner.new(@suite).start
        res.run_count - res.pass_count
      end

      def summarize_worker(worker)
        worker.stats.each do |s, val|
          stats[s.to_s] = val
        end

        worker.summary = worker.output.split("\n").grep(/^\d+ tests?/).first
        worker.failure_output = worker.output.scan(/^Failure:\n(.*)\n=======================*/m).join("\n")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
test-queue-split-0.3.2 lib/test_queue/runner/testunit.rb
test-queue-split-0.3.1 lib/test_queue/runner/testunit.rb
test-queue-split-0.3.0 lib/test_queue/runner/testunit.rb
test-queue-0.2.13 lib/test_queue/runner/testunit.rb
test-queue-0.2.12 lib/test_queue/runner/testunit.rb