Sha256: 4ca664bf14bedfe5962769a950f22d80c9b2b32d9a750bb99cf8c3595856ca7b

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

# typed: true
# frozen_string_literal: true

require_relative './distributed'

module Minitest
  class << self
    extend T::Sig

    def plugin_distributed_options(opts, options)
      options[:distributed] = Minitest::Distributed::Configuration.from_env

      opts.on('--coordinator=URI', "The URI pointing to the coordinator") do |uri|
        options[:distributed].coordinator_uri = URI.parse(uri)
      end

      opts.on('--test-timeout=TIMEOUT', "The maximum run time for a single test in seconds") do |timeout|
        options[:distributed].test_timeout = Integer(timeout)
      end

      opts.on('--max-attempts=ATTEMPTS', "The maximum number of attempts to run a test") do |attempts|
        options[:distributed].max_attempts = Integer(attempts)
      end

      opts.on('--test-batch-size=NUMBER', "The number of tests to process per batch") do |batch_size|
        options[:distributed].test_batch_size = Integer(batch_size)
      end

      opts.on('--run-id=ID', "The ID for this run shared between coordinated workers") do |id|
        options[:distributed].run_id = id
      end

      opts.on('--worker-id=ID', "The unique ID for this worker") do |id|
        options[:distributed].worker_id = id
      end
    end

    def plugin_distributed_init(options)
      Minitest.singleton_class.prepend(Minitest::Distributed::TestRunnerPatch)
      options[:distributed].coordinator.register_reporters(reporter: reporter, options: options)

      if reporter.reporters.reject! { |reporter| reporter.is_a?(Minitest::ProgressReporter) }
        reporter << Minitest::Distributed::Reporters::DistributedPogressReporter.new(options[:io], options)
      end

      if reporter.reporters.reject! { |reporter| reporter.is_a?(Minitest::SummaryReporter) }
        reporter << Minitest::Distributed::Reporters::DistributedSummaryReporter.new(options[:io], options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minitest-distributed-0.1.0 lib/minitest/distributed_plugin.rb