Sha256: 2815ceb895ccebb33f6d2db84d5ed135580d273ab105a3609d59c0c6d8dcd603

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

require 'test_queue/runner'
require 'minitest/unit'
require 'stringio'

class MiniTestQueueRunner < MiniTest::Unit
  def _run_suites(*)
    self.class.output = $stdout
    super
  end

  def _run_anything(*)
    ret = super
    output.puts
    ret
  end

  def _run_suite(suite, type)
    output.print '    '
    output.print suite
    output.print ': '

    start = Time.now
    ret = super
    diff = Time.now - start

    output.puts("  <%.3f>" % diff)
    ret
  end

  self.runner = self.new
  self.output = StringIO.new
end

class MiniTest::Unit::TestCase
  class << self
    attr_accessor :test_suites

    def original_test_suites
      @@test_suites.keys.reject{ |s| s.test_methods.empty? }
    end
  end
end

module TestQueue
  class Runner
    class MiniTest < Runner
      def initialize
        tests = ::MiniTest::Unit::TestCase.original_test_suites.sort_by{ |s| -(stats[s.to_s] || 0) }
        super(tests)
      end

      def run_worker(iterator)
        ::MiniTest::Unit::TestCase.test_suites = iterator
        ::MiniTest::Unit.new.run
      end

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

        num_tests = worker.lines.grep(/ errors?, /).first
        failures  = worker.lines.select{ |line|
          line if (line =~ /^Finished/) ... (line =~ / errors?, /)
        }[1..-2]
        failures = failures.join("\n") if failures

        [ num_tests, failures ]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
test-queue-0.2.1 lib/test_queue/runner/minitest.rb
test-queue-0.2.0 lib/test_queue/runner/minitest.rb
test-queue-0.2.0.beta.1 lib/test_queue/runner/minitest.rb