free_mutant/lib/mutant/integration.rb

79 lines
1.6 KiB
Ruby
Raw Normal View History

2012-11-22 00:10:50 +01:00
module Mutant
2014-06-28 23:04:18 +00:00
# Abstract base class mutant test framework integrations
class Integration
include AbstractType, Adamantium::Flat, Concord.new(:config)
# Setup integration
#
2016-01-10 18:44:01 +00:00
# Integrations are supposed to define a constant under
# Mutant::Integration named after the capitalized +name+
# parameter.
#
2016-01-10 18:44:01 +00:00
# This avoids having to maintain a mutable registry.
2014-01-18 00:15:42 +01:00
#
2016-01-10 18:44:01 +00:00
# @param kernel [Kernel]
# @param name [String]
2014-01-18 00:15:42 +01:00
#
2016-01-10 18:44:01 +00:00
# @return [Class<Integration>]
def self.setup(kernel, name)
kernel.require("mutant/integration/#{name}")
const_get(name.capitalize)
2014-01-18 00:15:42 +01:00
end
2014-06-28 23:04:18 +00:00
# Perform integration setup
#
2013-01-15 23:46:05 +01:00
# @return [self]
def setup
2013-09-02 22:02:51 +02:00
self
end
# Run a collection of tests
#
# @param [Enumerable<Test>] tests
#
# @return [Result::Test]
abstract_method :call
# Available tests for integration
#
# @return [Enumerable<Test>]
abstract_method :all_tests
private
# Expression parser
#
# @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
# Available tests for integration
#
# @return [Enumerable<Test>]
def all_tests
EMPTY_ARRAY
end
2014-01-18 00:15:42 +01: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: '',
passed: true,
2015-01-24 23:12:15 +00:00
runtime: 0.0,
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