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-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
|
2013-02-02 10:32:13 -05:00
|
|
|
@subjects = config.subjects.map do |subject|
|
2013-07-12 19:54:16 -04:00
|
|
|
Subject.run(config, subject)
|
2013-02-02 10:32:13 -05:00
|
|
|
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
|
2013-04-20 20:20:18 -04:00
|
|
|
@end = Time.now
|
|
|
|
report(self)
|
2013-02-02 10:32:13 -05:00
|
|
|
end
|
|
|
|
|
2013-06-14 14:54:02 -04:00
|
|
|
end # Config
|
|
|
|
end # Runner
|
|
|
|
end # Mutant
|