2013-02-02 10:32:13 -05:00
|
|
|
module Mutant
|
|
|
|
class Runner
|
2013-04-20 14:50:36 -04:00
|
|
|
# Runner for object config
|
2013-02-02 10:32:13 -05:00
|
|
|
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
|
|
|
|
|
2013-02-02 10:32:13 -05:00
|
|
|
private
|
|
|
|
|
2013-03-27 10:52:02 -04:00
|
|
|
# Run config
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-02-02 10:32:13 -05:00
|
|
|
def run
|
2013-04-20 20:20:18 -04:00
|
|
|
report(config)
|
2013-04-20 14:50:36 -04:00
|
|
|
strategy = self.strategy
|
2013-03-27 10:52:02 -04:00
|
|
|
strategy.setup
|
2013-02-02 10:32:13 -05:00
|
|
|
@subjects = config.subjects.map do |subject|
|
2013-04-20 14:50:36 -04:00
|
|
|
Subject.run(self, subject)
|
2013-02-02 10:32:13 -05:00
|
|
|
end
|
2013-03-27 10:52:02 -04:00
|
|
|
strategy.teardown
|
2013-04-20 20:20:18 -04:00
|
|
|
@end = Time.now
|
|
|
|
report(self)
|
2013-02-02 10:32:13 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|