Sha256: 4fe7eea3c869e1e6bf5898839e5d2865d3efec5b65eccbd8c698d5f1678075c5

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require 'test_queue/runner'

module MiniTest
  def self.__run reporter, options
    suites = Runnable.runnables

    # Run the serial tests first after they complete, run the parallels tests
    # We already sort suites based on its test_order at TestQueue::Runner::Minitest#initialize.
    suites.map { |suite| suite.run reporter, options }
  end

  class Test
    def self.runnables= runnables
      @@orig_runnables = @@runnables
      @@runnables = runnables
    end
    def self.orig_runnables
      @@orig_runnables
    end
  end

  class ProgressReporter
    # Override original method to make test-queue specific output
    def record result
      io.print '    '
      io.print result.class
      io.print ': '
      io.print result.result_code
      io.puts("  <%.3f>" % result.time)
    end
  end

  begin
    require 'minitest/minitest_reporter_plugin'

    class << self
      private
      def total_count(options)
        filter = options[:filter] || '/./'
        filter = Regexp.new $1 if filter =~ /\/(.*)\//

        Minitest::Test.orig_runnables.map(&:runnable_methods).flatten.find_all { |m|
          filter === m || filter === "#{self}##{m}"
        }.size
      end
    end
  rescue LoadError
  end
end

module TestQueue
  class Runner
    class MiniTest < Runner
      def initialize
        tests = ::MiniTest::Test.runnables.reject { |s|
          s.runnable_methods.empty?
        }.sort_by { |s|
          -(stats[s.to_s] || 0)
        }.partition { |s|
          s.test_order == :parallel
        }.reverse.flatten
        super(tests)
      end

      def run_worker(iterator)
        ::MiniTest::Test.runnables = iterator
        ::MiniTest.run ? 0 : 1
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
test-queue-0.2.10 lib/test_queue/runner/minitest5.rb