Sha256: 32113d839637895d31bac237517c034aceb9a7263a22000abe1df2967acc0f5c

Contents?: true

Size: 1.37 KB

Versions: 22

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module Mutant
  # Runner
  module Runner
    # Run against env
    #
    # @return [Either<String, Result>]
    def self.apply(env)
      reporter(env).start(env)

      Either::Right.new(run_mutation_analysis(env))
    end

    def self.run_mutation_analysis(env)
      reporter = reporter(env)

      run_driver(
        reporter,
        Parallel.async(mutation_test_config(env))
      ).tap do |result|
        reporter.report(result)
      end
    end
    private_class_method :run_mutation_analysis

    def self.run_driver(reporter, driver)
      loop do
        status = driver.wait_timeout(reporter.delay)
        break status.payload if status.done?
        reporter.progress(status)
      end
    end
    private_class_method :run_driver

    def self.mutation_test_config(env)
      world = env.world

      Parallel::Config.new(
        condition_variable: world.condition_variable,
        jobs:               env.config.jobs,
        mutex:              world.mutex,
        processor:          env.method(:kill),
        sink:               Sink.new(env),
        source:             Parallel::Source::Array.new(env.mutations),
        thread:             world.thread
      )
    end
    private_class_method :mutation_test_config

    def self.reporter(env)
      env.config.reporter
    end
    private_class_method :reporter

  end # Runner
end # Mutant

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
mutant-0.10.17 lib/mutant/runner.rb
mutant-0.10.16 lib/mutant/runner.rb
mutant-0.10.15 lib/mutant/runner.rb
mutant-0.10.14 lib/mutant/runner.rb
mutant-0.10.13 lib/mutant/runner.rb
mutant-0.10.12 lib/mutant/runner.rb
mutant-0.10.11 lib/mutant/runner.rb
mutant-0.10.10 lib/mutant/runner.rb
mutant-0.10.9 lib/mutant/runner.rb
mutant-0.10.8 lib/mutant/runner.rb
mutant-0.10.7 lib/mutant/runner.rb
mutant-0.10.6 lib/mutant/runner.rb
mutant-0.10.5 lib/mutant/runner.rb
mutant-0.10.4 lib/mutant/runner.rb
mutant-0.10.1 lib/mutant/runner.rb
mutant-0.10.0 lib/mutant/runner.rb
mutant-0.9.14 lib/mutant/runner.rb
mutant-0.9.13 lib/mutant/runner.rb
mutant-0.9.12 lib/mutant/runner.rb
mutant-0.9.11 lib/mutant/runner.rb