2014-04-28 15:17:25 -04:00
|
|
|
module Mutant
|
|
|
|
# Abstract base class for test that might kill a mutation
|
|
|
|
class Test
|
2014-06-28 19:04:18 -04:00
|
|
|
include Adamantium::Flat, Concord::Public.new(:integration, :expression)
|
2014-04-28 15:17:25 -04:00
|
|
|
|
2014-05-22 21:47:31 -04:00
|
|
|
# Return test identification
|
|
|
|
#
|
|
|
|
# @return [String]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def identification
|
2014-06-28 19:04:18 -04:00
|
|
|
"#{integration.name}:#{expression.syntax}"
|
2014-05-22 21:47:31 -04:00
|
|
|
end
|
|
|
|
memoize :identification
|
|
|
|
|
2014-10-23 07:37:53 -04:00
|
|
|
# Kill mutation with test under isolation
|
|
|
|
#
|
|
|
|
# @param [Isolation] isolation
|
|
|
|
# @param [Mutation] mutation
|
|
|
|
#
|
|
|
|
# @return [Report::Test]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def kill(isolation, mutation)
|
|
|
|
time = Time.now
|
|
|
|
isolation.call do
|
|
|
|
mutation.insert
|
|
|
|
run
|
|
|
|
end.update(test: self)
|
|
|
|
rescue Isolation::Error => exception
|
|
|
|
Result::Test.new(
|
|
|
|
test: self,
|
|
|
|
mutation: mutation,
|
|
|
|
runtime: Time.now - time,
|
|
|
|
output: exception.message,
|
|
|
|
passed: false
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2014-06-28 18:38:23 -04:00
|
|
|
# Run test, return report
|
|
|
|
#
|
|
|
|
# @return [Report]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def run
|
2014-06-28 19:04:18 -04:00
|
|
|
integration.run(self)
|
2014-06-28 18:38:23 -04:00
|
|
|
end
|
|
|
|
|
2014-04-28 15:17:25 -04:00
|
|
|
end # Test
|
|
|
|
end # Mutant
|