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)
|
2013-07-15 01:17:15 +02:00
|
|
|
|
2014-07-03 21:16:12 +00:00
|
|
|
# Initialize object
|
2013-07-15 01:17:15 +02:00
|
|
|
#
|
|
|
|
# @return [undefined]
|
2014-10-23 11:37:53 +00:00
|
|
|
def initialize(*)
|
2014-07-03 21:16:12 +00:00
|
|
|
super
|
2013-07-15 01:17:15 +02:00
|
|
|
|
2014-10-07 23:47:28 +00:00
|
|
|
reporter.start(env)
|
2014-12-09 00:10:31 +00:00
|
|
|
|
|
|
|
run_mutation_analysis
|
|
|
|
end
|
|
|
|
|
2015-07-03 15:21:39 +00:00
|
|
|
# Final result
|
2014-12-09 00:10:31 +00:00
|
|
|
#
|
|
|
|
# @return [Result::Env]
|
|
|
|
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
|
|
|
def run_mutation_analysis
|
|
|
|
@result = run_driver(Parallel.async(mutation_test_config))
|
2015-11-15 22:18:18 +00:00
|
|
|
reporter.report(result)
|
2014-12-09 00:10:31 +00:00
|
|
|
end
|
2014-07-03 21:16:12 +00:00
|
|
|
|
2014-12-09 00:10:31 +00:00
|
|
|
# Run driver
|
|
|
|
#
|
|
|
|
# @param [Driver] driver
|
|
|
|
#
|
|
|
|
# @return [Object]
|
|
|
|
# the last returned status payload
|
|
|
|
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)
|
2014-10-07 23:47:28 +00:00
|
|
|
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
|
|
|
|
|
2015-11-18 15:06:22 -08:00
|
|
|
# Configuration for parallel execution engine
|
2014-07-17 13:59:25 +00:00
|
|
|
#
|
2015-07-06 21:36:39 +03:00
|
|
|
# @return [Parallel::Config]
|
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,
|
2015-11-15 20:13:48 +00:00
|
|
|
processor: env.method(:kill),
|
2015-11-15 22:18:18 +00:00
|
|
|
sink: Sink.new(env),
|
2015-11-15 20:13:48 +00:00
|
|
|
source: Parallel::Source::Array.new(env.mutations)
|
2014-12-09 00:10:31 +00:00
|
|
|
)
|
|
|
|
end
|
2013-07-15 01:17:15 +02:00
|
|
|
|
2015-07-03 15:21:39 +00:00
|
|
|
# Reporter to use
|
2014-07-14 13:55:18 +00:00
|
|
|
#
|
2014-10-23 11:37:53 +00:00
|
|
|
# @return [Reporter]
|
|
|
|
def reporter
|
|
|
|
env.config.reporter
|
2014-07-14 13:55:18 +00:00
|
|
|
end
|
|
|
|
|
2015-07-03 15:21:39 +00:00
|
|
|
# Config for this mutant execution
|
2013-04-21 02:20:18 +02:00
|
|
|
#
|
2014-07-03 21:16:12 +00:00
|
|
|
# @return [Config]
|
|
|
|
def config
|
|
|
|
env.config
|
2013-04-21 02:20:18 +02:00
|
|
|
end
|
|
|
|
|
2013-06-14 20:54:02 +02:00
|
|
|
end # Runner
|
|
|
|
end # Mutant
|