2014-06-30 13:06:57 +00:00
|
|
|
module Mutant
|
|
|
|
# Abstract base class for mutant environments
|
|
|
|
class Env
|
2015-09-04 20:20:56 +00:00
|
|
|
include Adamantium::Flat, Anima.new(
|
2014-12-22 14:42:20 +00:00
|
|
|
:actor_env,
|
2015-11-15 20:13:48 +00:00
|
|
|
:config,
|
2015-06-29 02:10:04 +00:00
|
|
|
:integration,
|
2015-11-15 20:13:48 +00:00
|
|
|
:matchable_scopes,
|
|
|
|
:mutations,
|
|
|
|
:parser,
|
2014-12-22 15:42:21 +00:00
|
|
|
:selector,
|
2015-11-15 20:13:48 +00:00
|
|
|
:subjects
|
2014-12-22 14:42:20 +00:00
|
|
|
)
|
2014-06-30 13:06:57 +00:00
|
|
|
|
2014-10-23 11:37:53 +00:00
|
|
|
SEMANTICS_MESSAGE =
|
|
|
|
"Fix your lib to follow normal ruby semantics!\n" \
|
|
|
|
'{Module,Class}#name should return resolvable constant name as String or nil'.freeze
|
|
|
|
|
2014-12-09 00:10:31 +00:00
|
|
|
# Kill mutation
|
|
|
|
#
|
|
|
|
# @param [Mutation] mutation
|
|
|
|
#
|
|
|
|
# @return [Result::Mutation]
|
2014-12-22 16:21:51 +00:00
|
|
|
def kill(mutation)
|
2014-12-22 15:42:21 +00:00
|
|
|
test_result = run_mutation_tests(mutation)
|
2014-12-09 00:10:31 +00:00
|
|
|
Result::Mutation.new(
|
|
|
|
mutation: mutation,
|
|
|
|
test_result: test_result
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-12-22 15:42:21 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
# Kill mutation under isolation with integration
|
|
|
|
#
|
|
|
|
# @param [Isolation] isolation
|
|
|
|
# @param [Integration] integration
|
|
|
|
#
|
|
|
|
# @return [Result::Test]
|
|
|
|
#
|
|
|
|
# rubocop:disable MethodLength
|
|
|
|
def run_mutation_tests(mutation)
|
|
|
|
start = Time.now
|
|
|
|
tests = selector.call(mutation.subject)
|
|
|
|
|
|
|
|
config.isolation.call do
|
2015-11-21 22:02:51 +00:00
|
|
|
mutation.insert(config.kernel)
|
2015-06-29 02:10:04 +00:00
|
|
|
integration.call(tests)
|
2014-12-22 17:54:18 +00:00
|
|
|
end
|
2014-12-22 15:42:21 +00:00
|
|
|
rescue Isolation::Error => error
|
|
|
|
Result::Test.new(
|
|
|
|
output: error.message,
|
2015-11-15 20:13:48 +00:00
|
|
|
passed: false,
|
2014-12-22 15:42:21 +00:00
|
|
|
runtime: Time.now - start,
|
2015-11-15 20:13:48 +00:00
|
|
|
tests: tests
|
2014-12-22 15:42:21 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-07-03 21:16:12 +00:00
|
|
|
end # Env
|
2014-06-30 13:06:57 +00:00
|
|
|
end # Mutant
|