free_mutant/lib/mutant/runner.rb

96 lines
1.7 KiB
Ruby
Raw Normal View History

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