free_mutant/lib/mutant/runner/config.rb

83 lines
1.4 KiB
Ruby
Raw Normal View History

module Mutant
class Runner
2013-04-20 14:50:36 -04:00
# Runner for object config
class Config < self
# Return subject runners
#
# @return [Enumerable<Runner::Subject>]
#
# @api private
#
attr_reader :subjects
2013-03-27 10:52:02 -04:00
# Return failed subjects
#
# @return [Enumerable<Subject>]
#
# @api private
#
def failed_subjects
subjects.select(&:failed?)
end
memoize :failed_subjects
# Test if run was successful
#
# @return [true]
# if run was successful
#
# @return [false]
# otherwise
#
# @api private
#
def success?
failed_subjects.empty?
end
memoize :success?
2013-04-20 14:50:36 -04:00
# Return strategy
#
# @return [Strategy]
#
# @api private
#
def strategy
config.strategy
end
private
2013-03-27 10:52:02 -04:00
# Run config
#
# @return [undefined]
#
# @api private
#
2013-04-20 20:48:58 -04:00
def run_subjects
2013-04-20 14:50:36 -04:00
strategy = self.strategy
2013-03-27 10:52:02 -04:00
strategy.setup
@subjects = config.subjects.map do |subject|
2013-04-20 14:50:36 -04:00
Subject.run(self, subject)
end
2013-03-27 10:52:02 -04:00
strategy.teardown
2013-04-20 20:48:58 -04:00
end
# Run with strategy management
#
# @return [undefined]
#
# @api private
#
def run
report(config)
run_subjects
@end = Time.now
report(self)
end
2013-06-14 14:54:02 -04:00
end # Config
end # Runner
end # Mutant