free_mutant/lib/mutant/runner/config.rb

83 lines
1.4 KiB
Ruby
Raw Normal View History

module Mutant
class Runner
2013-04-20 20:50:36 +02:00
# Runner for object config
class Config < self
# Return subject runners
#
# @return [Enumerable<Runner::Subject>]
#
# @api private
#
attr_reader :subjects
2013-03-27 15:52:02 +01: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 20:50:36 +02:00
# Return strategy
#
# @return [Strategy]
#
# @api private
#
def strategy
config.strategy
end
private
2013-03-27 15:52:02 +01:00
# Run config
#
# @return [undefined]
#
# @api private
#
2013-04-21 02:48:58 +02:00
def run_subjects
2013-04-20 20:50:36 +02:00
strategy = self.strategy
2013-03-27 15:52:02 +01:00
strategy.setup
@subjects = config.subjects.map do |subject|
2013-04-20 20:50:36 +02:00
Subject.run(self, subject)
end
2013-03-27 15:52:02 +01:00
strategy.teardown
2013-04-21 02:48:58 +02:00
end
# Run with strategy management
#
# @return [undefined]
#
# @api private
#
def run
report(config)
run_subjects
@end = Time.now
report(self)
end
end
end
end