Sha256: 04dc02e02b2dc0978010c2f08da5564bbb533bb36ea28db8fe72fd04af4af741

Contents?: true

Size: 1.73 KB

Versions: 6

Compression:

Stored size: 1.73 KB

Contents

module Mutant
  # Runner baseclass
  class Runner
    include Adamantium::Flat, Concord.new(:env), Procto.call(:result)

    # Initialize object
    #
    # @return [undefined]
    #
    # @api private
    #
    def initialize(*)
      super

      reporter.start(env)

      run_mutation_analysis
    end

    # Return result
    #
    # @return [Result::Env]
    #
    # @api private
    #
    attr_reader :result

  private

    # Run mutation analysis
    #
    #  @return [undefined]
    #
    #  @api private
    #
    def run_mutation_analysis
      config.integration.setup

      @result = run_driver(Parallel.async(mutation_test_config))
      reporter.report(@result)
    end

    # Run driver
    #
    # @param [Driver] driver
    #
    # @return [Object]
    #   the last returned status payload
    #
    # @api private
    #
    def run_driver(driver)
      status = nil

      loop do
        status = driver.status
        reporter.progress(status)
        break if status.done
        Kernel.sleep(reporter.delay)
      end

      driver.stop

      status.payload
    end

    # Return mutation test config
    #
    # @return [Parallell::Config]
    #
    # @api private
    #
    def mutation_test_config
      Parallel::Config.new(
        env:       env.actor_env,
        jobs:      config.jobs,
        source:    Parallel::Source::Array.new(env.mutations),
        sink:      Sink::Mutation.new(env),
        processor: env.method(:kill)
      )
    end

    # Return reporter
    #
    # @return [Reporter]
    #
    # @api private
    #
    def reporter
      env.config.reporter
    end

    # Return config
    #
    # @return [Config]
    #
    # @api private
    #
    def config
      env.config
    end

  end # Runner
end # Mutant

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.8.0 lib/mutant/runner.rb
mutant-0.7.9 lib/mutant/runner.rb
mutant-0.7.8 lib/mutant/runner.rb
mutant-0.7.7 lib/mutant/runner.rb
mutant-0.7.6 lib/mutant/runner.rb
mutant-0.7.5 lib/mutant/runner.rb