free_mutant/lib/mutant/runner/mutation.rb

79 lines
1.5 KiB
Ruby
Raw Normal View History

module Mutant
class Runner
# Mutation runner
class Mutation < self
include Equalizer.new(:config, :mutation, :tests)
register Mutant::Mutation
# Return mutation
#
# @return [Mutation]
#
# @api private
#
attr_reader :mutation
# Return killers
#
# @return [Enumerable<Runner::Killer>]
#
# @api private
#
attr_reader :killers
# Initialize object
#
2013-03-27 15:52:02 +01:00
# @param [Config] config
# @param [Mutation] mutation
# @param [Enumerable<Test>] tests
#
# @return [undefined]
#
# @api private
#
def initialize(config, mutation, tests)
@mutation, @tests = mutation, tests
super(config)
@stop = config.fail_fast && !success?
end
2013-03-27 15:52:02 +01:00
# Test if mutation was handeled successfully
#
2014-06-15 19:27:57 +00:00
# @return [Boolean]
2013-03-27 15:52:02 +01:00
#
# @api private
#
def success?
killers.any?(&:success?)
2013-03-27 15:52:02 +01:00
end
private
# Perform operation
#
# @return [undefined]
#
# @api private
#
def run
2014-05-27 16:43:16 +00:00
@killers = []
killers = @tests.map do |test|
Mutant::Killer.new(
mutation: mutation,
test: test
)
2014-05-27 16:43:16 +00:00
end
killers.each do |killer|
runner = visit(killer)
@killers << runner
return if runner.mutation_dead?
end
end
2013-06-14 20:54:02 +02:00
end # Mutation
end # Runner
end # Mutant