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)
|
2013-07-14 19:17:15 -04:00
|
|
|
|
2014-07-03 17:16:12 -04:00
|
|
|
# Initialize object
|
2013-07-14 19:17:15 -04:00
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
2014-10-23 07:37:53 -04:00
|
|
|
def initialize(*)
|
2014-07-03 17:16:12 -04:00
|
|
|
super
|
2013-07-14 19:17:15 -04:00
|
|
|
|
2014-10-07 19:47:28 -04:00
|
|
|
reporter.start(env)
|
2014-12-08 19:10:31 -05:00
|
|
|
|
|
|
|
run_mutation_analysis
|
|
|
|
end
|
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# 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-07-03 17:16:12 -04:00
|
|
|
|
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)
|
2014-10-07 19:47:28 -04:00
|
|
|
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
|
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# 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),
|
2014-12-22 11:27:10 -05:00
|
|
|
sink: Sink::Mutation.new(env),
|
2014-12-22 11:21:51 -05:00
|
|
|
processor: env.method(:kill)
|
2014-12-08 19:10:31 -05:00
|
|
|
)
|
|
|
|
end
|
2013-07-14 19:17:15 -04:00
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# Reporter to use
|
2014-07-14 09:55:18 -04:00
|
|
|
#
|
2014-10-23 07:37:53 -04:00
|
|
|
# @return [Reporter]
|
2014-07-14 09:55:18 -04:00
|
|
|
#
|
|
|
|
# @api private
|
2014-10-23 07:37:53 -04:00
|
|
|
def reporter
|
|
|
|
env.config.reporter
|
2014-07-14 09:55:18 -04:00
|
|
|
end
|
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# Config for this mutant execution
|
2013-04-20 20:20:18 -04:00
|
|
|
#
|
2014-07-03 17:16:12 -04:00
|
|
|
# @return [Config]
|
2013-04-20 20:20:18 -04:00
|
|
|
#
|
|
|
|
# @api private
|
2014-07-03 17:16:12 -04:00
|
|
|
def config
|
|
|
|
env.config
|
2013-04-20 20:20:18 -04:00
|
|
|
end
|
|
|
|
|
2013-06-14 14:54:02 -04:00
|
|
|
end # Runner
|
|
|
|
end # Mutant
|