2012-11-21 18:10:50 -05:00
|
|
|
module Mutant
|
2013-01-04 16:16:03 -05:00
|
|
|
|
2014-06-28 19:04:18 -04:00
|
|
|
# Abstract base class mutant test framework integrations
|
|
|
|
class Integration
|
2015-06-28 22:10:04 -04:00
|
|
|
include AbstractType, Adamantium::Flat, Concord.new(:config)
|
2012-12-10 18:17:19 -05:00
|
|
|
|
2014-01-17 18:15:42 -05:00
|
|
|
REGISTRY = {}
|
|
|
|
|
2014-08-17 12:22:20 -04:00
|
|
|
# Setup integration
|
|
|
|
#
|
|
|
|
# @param [String] name
|
|
|
|
#
|
|
|
|
# @return [Integration]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
def self.setup(name)
|
|
|
|
require "mutant/integration/#{name}"
|
|
|
|
lookup(name)
|
|
|
|
end
|
|
|
|
|
2014-06-28 19:04:18 -04:00
|
|
|
# Lookup integration for name
|
2014-01-17 18:15:42 -05:00
|
|
|
#
|
|
|
|
# @param [String] name
|
|
|
|
#
|
2014-06-28 19:04:18 -04:00
|
|
|
# @return [Integration]
|
2014-01-17 18:15:42 -05:00
|
|
|
# if found
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
def self.lookup(name)
|
2015-06-28 22:10:04 -04:00
|
|
|
REGISTRY.fetch(name)
|
2014-01-17 18:15:42 -05:00
|
|
|
end
|
|
|
|
|
2014-06-28 19:04:18 -04:00
|
|
|
# Register integration
|
2014-01-17 18:15:42 -05:00
|
|
|
#
|
|
|
|
# @param [String] name
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
def self.register(name)
|
|
|
|
REGISTRY[name] = self
|
|
|
|
end
|
|
|
|
private_class_method :register
|
|
|
|
|
2014-06-28 19:04:18 -04:00
|
|
|
# Perform integration setup
|
2012-12-10 18:17:19 -05:00
|
|
|
#
|
2013-01-15 17:46:05 -05:00
|
|
|
# @return [self]
|
2012-12-10 18:17:19 -05:00
|
|
|
#
|
|
|
|
# @api private
|
2013-07-17 13:59:44 -04:00
|
|
|
def setup
|
2013-09-02 16:02:51 -04:00
|
|
|
self
|
2012-12-10 18:17:19 -05:00
|
|
|
end
|
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# Run a collection of tests
|
2014-11-27 11:34:08 -05:00
|
|
|
#
|
|
|
|
# @param [Enumerable<Test>] tests
|
|
|
|
#
|
|
|
|
# @return [Result::Test]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
abstract_method :call
|
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# Available tests for integration
|
2014-04-28 15:17:25 -04:00
|
|
|
#
|
|
|
|
# @return [Enumerable<Test>]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
abstract_method :all_tests
|
|
|
|
|
2015-06-21 10:44:33 -04:00
|
|
|
private
|
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# Expression parser
|
2015-06-21 10:44:33 -04:00
|
|
|
#
|
|
|
|
# @return [Expression::Parser]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
def expression_parser
|
|
|
|
config.expression_parser
|
|
|
|
end
|
|
|
|
|
2014-06-28 19:04:18 -04:00
|
|
|
# Null integration that never kills a mutation
|
2014-01-17 18:15:42 -05:00
|
|
|
class Null < self
|
|
|
|
|
2014-04-28 15:17:25 -04:00
|
|
|
register('null')
|
2014-01-17 18:15:42 -05:00
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# Available tests for integration
|
2014-04-28 15:17:25 -04:00
|
|
|
#
|
|
|
|
# @return [Enumerable<Test>]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
def all_tests
|
2014-05-22 21:03:09 -04:00
|
|
|
EMPTY_ARRAY
|
2014-04-28 15:17:25 -04:00
|
|
|
end
|
2014-01-17 18:15:42 -05:00
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# Run a collection of tests
|
2015-01-24 18:12:15 -05:00
|
|
|
#
|
|
|
|
# @param [Enumerable<Mutant::Test>] tests
|
|
|
|
#
|
|
|
|
# @return [Result::Test]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
def call(tests)
|
|
|
|
Result::Test.new(
|
|
|
|
tests: tests,
|
|
|
|
output: '',
|
|
|
|
runtime: 0.0,
|
|
|
|
passed: true
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-01-17 18:15:42 -05:00
|
|
|
end # Null
|
|
|
|
|
2014-06-28 19:04:18 -04:00
|
|
|
end # Integration
|
2013-06-14 14:54:02 -04:00
|
|
|
end # Mutant
|