Sha256: f67143ee5bc5809a2768df7f110295102a6cca39090383154367f5b1b8f475b7

Contents?: true

Size: 985 Bytes

Versions: 13

Compression:

Stored size: 985 Bytes

Contents

module Minitest
  module Parallel
    class Executor
      attr_reader :size

      def initialize size
        @size  = size
        @queue = Queue.new
        @pool  = size.times.map {
          Thread.new(@queue) do |queue|
          Thread.current.abort_on_exception = true
            while job = queue.pop
              klass, method, reporter = job
              result = Minitest.run_one_method klass, method
              reporter.synchronize { reporter.record result }
            end
          end
        }
      end

      def << work; @queue << work; end

      def shutdown
        size.times { @queue << nil }
        @pool.each(&:join)
      end
    end

    module Test
      def _synchronize; Test.io_lock.synchronize { yield }; end

      module ClassMethods
        def run_one_method klass, method_name, reporter
          Minitest.parallel_executor << [klass, method_name, reporter]
        end
        def test_order; :parallel; end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
minitest-5.4.2 lib/minitest/parallel.rb
nanumfont-rails-0.1 vendor/bundle/ruby/2.1.0/gems/minitest-5.4.1/lib/minitest/parallel.rb
minitest-5.4.1 lib/minitest/parallel.rb
minitest-5.4.0 lib/minitest/parallel.rb
whos_dated_who-0.1.0 vendor/bundle/gems/minitest-5.3.4/lib/minitest/parallel.rb
minitest-5.3.5 lib/minitest/parallel.rb
whos_dated_who-0.0.1 vendor/bundle/gems/minitest-5.3.4/lib/minitest/parallel.rb
minitest-5.3.4 lib/minitest/parallel.rb
spec-5.3.4 lib/minitest/parallel.rb
spec-5.3.3 lib/minitest/parallel.rb
minitest-5.3.3 lib/minitest/parallel.rb
minitest-5.3.2 lib/minitest/parallel.rb
minitest-5.3.1 lib/minitest/parallel.rb