2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2013-02-01 17:06:07 -05:00
|
|
|
module Mutant
|
|
|
|
class Runner
|
|
|
|
# Subject specific runner
|
|
|
|
class Subject < self
|
2013-09-02 14:35:01 -04:00
|
|
|
include Equalizer.new(:config, :subject)
|
|
|
|
|
|
|
|
# Return subject
|
|
|
|
#
|
|
|
|
# @return [Subject]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
attr_reader :subject
|
2013-02-01 17:06:07 -05:00
|
|
|
|
2013-07-14 19:17:15 -04:00
|
|
|
register Mutant::Subject
|
2013-02-01 17:06:07 -05:00
|
|
|
|
|
|
|
# Initialize object
|
|
|
|
#
|
2013-03-27 10:52:02 -04:00
|
|
|
# @param [Config] config
|
2013-02-01 17:06:07 -05:00
|
|
|
# @param [Subject] subject
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def initialize(config, subject)
|
|
|
|
@subject = subject
|
|
|
|
super(config)
|
|
|
|
end
|
|
|
|
|
2013-03-27 10:52:02 -04:00
|
|
|
# Return mutation runners
|
|
|
|
#
|
|
|
|
# @return [Enumerable<Runner::Mutation>]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
attr_reader :mutations
|
|
|
|
|
|
|
|
# Return failed mutations
|
|
|
|
#
|
|
|
|
# @return [Enumerable<Mutation>]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def failed_mutations
|
2013-07-14 19:17:15 -04:00
|
|
|
mutations.reject(&:success?)
|
2013-03-27 10:52:02 -04:00
|
|
|
end
|
|
|
|
memoize :failed_mutations
|
|
|
|
|
|
|
|
# Test if subject was processed successful
|
|
|
|
#
|
|
|
|
# @return [true]
|
|
|
|
# if successful
|
|
|
|
#
|
|
|
|
# @return [false]
|
|
|
|
# otherwise
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def success?
|
|
|
|
failed_mutations.empty?
|
|
|
|
end
|
|
|
|
|
2013-02-01 17:06:07 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
# Perform operation
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def run
|
2014-05-12 09:48:15 -04:00
|
|
|
progress(subject)
|
2014-05-22 21:03:09 -04:00
|
|
|
tests = config.strategy.tests(subject)
|
2014-05-22 21:26:04 -04:00
|
|
|
@mutations = visit_collection(subject.mutations, tests)
|
2014-05-12 09:48:15 -04:00
|
|
|
progress(self)
|
2013-02-01 17:06:07 -05:00
|
|
|
end
|
|
|
|
|
2013-06-14 14:54:02 -04:00
|
|
|
end # Subject
|
|
|
|
end # Runner
|
|
|
|
end # Mutant
|