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