2012-08-14 16:45:34 -04:00
|
|
|
module Mutant
|
2013-04-20 14:50:36 -04:00
|
|
|
# Runner baseclass
|
2012-08-14 16:45:34 -04:00
|
|
|
class Runner
|
2013-04-20 14:50:36 -04:00
|
|
|
include Adamantium::Flat, AbstractType, Equalizer.new(:config)
|
2013-02-02 10:32:13 -05:00
|
|
|
extend MethodObject
|
2012-08-14 16:45:34 -04:00
|
|
|
|
2012-11-21 16:28:08 -05:00
|
|
|
# Return config
|
|
|
|
#
|
|
|
|
# @return [Mutant::Config]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
attr_reader :config
|
|
|
|
|
2012-09-15 18:51:47 -04:00
|
|
|
# Initialize object
|
2012-08-16 13:26:15 -04:00
|
|
|
#
|
2012-11-21 14:49:23 -05:00
|
|
|
# @param [Config] config
|
2012-08-16 13:26:15 -04:00
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2012-11-21 14:49:23 -05:00
|
|
|
def initialize(config)
|
2013-01-15 17:46:05 -05:00
|
|
|
@config = config
|
2013-04-20 20:20:18 -04:00
|
|
|
@start = Time.now
|
2012-08-14 16:45:34 -04:00
|
|
|
run
|
2013-04-20 20:20:18 -04:00
|
|
|
@end = Time.now
|
2013-01-15 17:46:05 -05:00
|
|
|
end
|
|
|
|
|
2013-04-20 20:20:18 -04:00
|
|
|
# Return runtime
|
|
|
|
#
|
|
|
|
# @return [Float]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def runtime
|
2013-06-14 14:54:02 -04:00
|
|
|
@end - @start
|
2013-04-20 20:20:18 -04:00
|
|
|
end
|
|
|
|
memoize :runtime
|
|
|
|
|
2013-03-27 10:52:02 -04:00
|
|
|
# Test if runner failed
|
|
|
|
#
|
|
|
|
# @return [true]
|
|
|
|
# if failed
|
|
|
|
#
|
|
|
|
# @return [false]
|
|
|
|
# otherwise
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def failed?
|
|
|
|
!success?
|
|
|
|
end
|
|
|
|
|
|
|
|
# Test if runner is successful
|
|
|
|
#
|
|
|
|
# @return [true]
|
|
|
|
# if successful
|
|
|
|
#
|
|
|
|
# @return [false]
|
|
|
|
# otherwise
|
|
|
|
#
|
|
|
|
# @api private
|
2013-04-17 23:31:21 -04:00
|
|
|
#
|
2013-03-27 10:52:02 -04:00
|
|
|
abstract_method :success?
|
|
|
|
|
2013-04-20 14:50:36 -04:00
|
|
|
# Return reporter
|
|
|
|
#
|
|
|
|
# @return [Reporter]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def reporter
|
|
|
|
config.reporter
|
|
|
|
end
|
|
|
|
|
2013-02-01 17:06:07 -05:00
|
|
|
private
|
2012-08-14 16:45:34 -04:00
|
|
|
|
2013-02-01 17:06:07 -05:00
|
|
|
# Perform operation
|
2012-08-16 13:26:15 -04:00
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-02-01 17:06:07 -05:00
|
|
|
abstract_method :run
|
2012-08-14 16:45:34 -04:00
|
|
|
|
2013-04-20 14:50:36 -04:00
|
|
|
# Return reporter
|
|
|
|
#
|
|
|
|
# @param [Object] object
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def report(object)
|
|
|
|
reporter.report(object)
|
|
|
|
end
|
|
|
|
|
2013-06-14 14:54:02 -04:00
|
|
|
end # Runner
|
|
|
|
end # Mutant
|