lib/test_queue/runner/minitest5.rb in test-queue-0.7.0 vs lib/test_queue/runner/minitest5.rb in test-queue-0.8.0

- old
+ new

@@ -1,9 +1,11 @@ +# frozen_string_literal: true + require_relative '../runner' -module MiniTest - def self.__run reporter, options +module Minitest + def self.__run(reporter, options) suites = Runnable.runnables suites.map { |suite| suite.run reporter, options } end class Runnable @@ -11,11 +13,11 @@ failures.length end end class Test - def self.runnables= runnables + def self.runnables=(runnables) @@runnables = runnables end # Synchronize all tests, even serial ones. # @@ -23,72 +25,85 @@ # unsynchronized serial tests don't overlap the parallel tests. But since # the test-queue master hands out tests without actually loading their # code, there's no way to know which are parallel and which are serial. # Synchronizing serial tests does add some overhead, but hopefully this is # outweighed by the speed benefits of using test-queue. - def _synchronize; Test.io_lock.synchronize { yield }; end + def _synchronize + Test.io_lock.synchronize { yield } + end end class ProgressReporter # Override original method to make test-queue specific output - def record result + def record(result) io.print ' ' io.print result.class io.print ': ' io.print result.result_code - io.puts(" <%.3f>" % result.time) + io.puts(' <%.3f>' % result.time) end end begin require 'minitest/minitest_reporter_plugin' class << self private - def total_count(options) + + def total_count(_options) 0 end end rescue LoadError + # noop end end module TestQueue class Runner - class MiniTest < Runner + class Minitest < Runner def initialize - options = Minitest.process_args ARGV + @options = ::Minitest.process_args ARGV - if Minitest.respond_to?(:seed) - Minitest.seed = options[:seed] - srand Minitest.seed + if ::Minitest.respond_to?(:seed) + ::Minitest.seed = @options[:seed] + srand ::Minitest.seed end - if ::MiniTest::Test.runnables.any? { |r| r.runnable_methods.any? } - fail "Do not `require` test files. Pass them via ARGV instead and they will be required as needed." + if ::Minitest::Test.runnables.any? { |r| r.runnable_methods.any? } + raise 'Do not `require` test files. Pass them via ARGV instead and they will be required as needed.' end - super(TestFramework::MiniTest.new) + + super(TestFramework::Minitest.new) end + def start_master + puts "Run options: #{@options[:args]}\n\n" + + super + end + def run_worker(iterator) - ::MiniTest::Test.runnables = iterator - ::MiniTest.run ? 0 : 1 + ::Minitest::Test.runnables = iterator + ::Minitest.run ? 0 : 1 end end + MiniTest = Minitest # For compatibility with test-queue 0.7.0 and earlier. end class TestFramework - class MiniTest < TestFramework + class Minitest < TestFramework def all_suite_files ARGV end def suites_from_file(path) - ::MiniTest::Test.reset + ::Minitest::Test.reset require File.absolute_path(path) - ::MiniTest::Test.runnables - .reject { |s| s.runnable_methods.empty? } - .map { |s| [s.name, s] } + ::Minitest::Test.runnables + .reject { |s| s.runnable_methods.empty? } + .map { |s| [s.name, s] } end end + MiniTest = Minitest # For compatibility with test-queue 0.7.0 and earlier. end end