free_mutant/lib/mutant/runner.rb

96 lines
1.7 KiB
Ruby
Raw Normal View History

2012-08-14 16:45:34 -04:00
module Mutant
2013-04-20 14:50:36 -04:00
# Runner baseclass
2012-08-14 16:45:34 -04:00
class Runner
2014-07-17 09:59:25 -04:00
include Adamantium::Flat, Concord.new(:env), Procto.call(:result)
# Initialize object
#
# @return [undefined]
#
# @api private
2014-10-23 07:37:53 -04:00
def initialize(*)
super
reporter.start(env)
2014-12-08 19:10:31 -05:00
run_mutation_analysis
end
# Final result
2014-12-08 19:10:31 -05:00
#
# @return [Result::Env]
#
# @api private
attr_reader :result
private
# Run mutation analysis
#
2015-07-03 11:24:31 -04:00
# @return [undefined]
2014-12-08 19:10:31 -05:00
#
2015-07-03 11:24:31 -04:00
# @api private
2014-12-08 19:10:31 -05:00
def run_mutation_analysis
@result = run_driver(Parallel.async(mutation_test_config))
reporter.report(@result)
end
2014-12-08 19:10:31 -05:00
# Run driver
#
# @param [Driver] driver
#
# @return [Object]
# the last returned status payload
#
# @api private
def run_driver(driver)
2014-10-23 07:37:53 -04:00
status = nil
2014-07-17 09:59:25 -04:00
2014-10-23 07:37:53 -04:00
loop do
2014-12-08 19:10:31 -05:00
status = driver.status
2014-10-23 07:37:53 -04:00
reporter.progress(status)
2014-12-08 19:10:31 -05:00
break if status.done
2014-12-08 13:13:49 -05:00
Kernel.sleep(reporter.delay)
end
2014-12-08 19:10:31 -05:00
driver.stop
2014-07-17 09:59:25 -04:00
2014-12-08 19:10:31 -05:00
status.payload
2014-07-17 09:59:25 -04:00
end
# Confiugation for paralell execution engine
2014-07-17 09:59:25 -04:00
#
2015-07-06 14:36:39 -04:00
# @return [Parallel::Config]
2014-07-17 09:59:25 -04:00
#
# @api private
2014-12-08 19:10:31 -05:00
def mutation_test_config
Parallel::Config.new(
2014-12-22 13:04:41 -05:00
env: env.actor_env,
2014-12-08 19:10:31 -05:00
jobs: config.jobs,
source: Parallel::Source::Array.new(env.mutations),
sink: Sink::Mutation.new(env),
processor: env.method(:kill)
2014-12-08 19:10:31 -05:00
)
end
# Reporter to use
#
2014-10-23 07:37:53 -04:00
# @return [Reporter]
#
# @api private
2014-10-23 07:37:53 -04:00
def reporter
env.config.reporter
end
# Config for this mutant execution
#
# @return [Config]
#
# @api private
def config
env.config
end
2013-06-14 14:54:02 -04:00
end # Runner
end # Mutant