Cleanup killers
This commit is contained in:
parent
2b6470f223
commit
277a29aba5
4 changed files with 36 additions and 91 deletions
|
@ -2,11 +2,41 @@ module Mutant
|
|||
# Abstract base class for mutant killers
|
||||
class Killer
|
||||
include Adamantium::Flat, AbstractType, Equalizer.new(:strategy, :mutation, :killed?)
|
||||
|
||||
# Return strategy
|
||||
#
|
||||
# @return [Strategy]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :strategy
|
||||
|
||||
# Return mutation to kill
|
||||
#
|
||||
# @return [Mutation]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :mutation
|
||||
|
||||
# Initialize killer object
|
||||
#
|
||||
# @param [Strategy] strategy
|
||||
# @param [Mutation] mutation
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize(strategy, mutation)
|
||||
@strategy, @mutation = strategy, mutation
|
||||
run_with_benchmark
|
||||
end
|
||||
|
||||
# Test for kill failure
|
||||
#
|
||||
# @return [true]
|
||||
# when mutant was killed
|
||||
# when killer succeeded
|
||||
#
|
||||
# @return [false]
|
||||
# otherwise
|
||||
|
@ -40,16 +70,6 @@ module Mutant
|
|||
#
|
||||
attr_reader :runtime
|
||||
|
||||
# Return configuration
|
||||
#
|
||||
# @return [Configuration]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def configuration
|
||||
strategy.configuration
|
||||
end
|
||||
|
||||
# Return mutated source
|
||||
#
|
||||
# @return [String]
|
||||
|
@ -60,69 +80,8 @@ module Mutant
|
|||
mutation.source
|
||||
end
|
||||
|
||||
# Return name of killer
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def self.type
|
||||
self::TYPE
|
||||
end
|
||||
|
||||
# Return strategy
|
||||
#
|
||||
# @return [Strategy]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :strategy
|
||||
|
||||
# Return identification
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def identification
|
||||
"#{type}:#{mutation.identification}".freeze
|
||||
end
|
||||
memoize :identification
|
||||
|
||||
# Return mae of killer
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def type
|
||||
self.class.type
|
||||
end
|
||||
|
||||
# Return mutation to kill
|
||||
#
|
||||
# @return [Mutation]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
attr_reader :mutation
|
||||
|
||||
private
|
||||
|
||||
# Initialize killer object
|
||||
#
|
||||
# @param [Mutation] mutation
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def initialize(strategy, mutation)
|
||||
@strategy, @mutation = strategy, mutation
|
||||
|
||||
run_with_benchmark
|
||||
end
|
||||
|
||||
# Run with taking the time
|
||||
#
|
||||
# @return [undefined]
|
||||
|
@ -136,13 +95,13 @@ module Mutant
|
|||
@runtime = end_time - start_time
|
||||
end
|
||||
|
||||
# Run test
|
||||
# Run killer
|
||||
#
|
||||
# @return [true]
|
||||
# returns true when mutant was killed
|
||||
# when mutant was killed
|
||||
#
|
||||
# @return [false]
|
||||
# returns false otherwise
|
||||
# otherwise
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
|
|
|
@ -17,16 +17,6 @@ module Mutant
|
|||
super(strategy, mutation)
|
||||
end
|
||||
|
||||
# Return killer type
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def type
|
||||
@killer.type
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Run killer
|
||||
|
|
|
@ -3,14 +3,12 @@ module Mutant
|
|||
# Runner for rspec tests
|
||||
class Rspec < self
|
||||
|
||||
TYPE = 'rspec'.freeze
|
||||
|
||||
private
|
||||
|
||||
# Run rspec test
|
||||
#
|
||||
# @return [true]
|
||||
# when test is NOT successful and the mutant was killed
|
||||
# when test is NOT successful
|
||||
#
|
||||
# @return [false]
|
||||
# otherwise
|
||||
|
@ -21,7 +19,6 @@ module Mutant
|
|||
mutation.insert
|
||||
!!::RSpec::Core::Runner.run(command_line_arguments, strategy.error_stream, strategy.output_stream).nonzero?
|
||||
end
|
||||
memoize :run
|
||||
|
||||
# Return command line arguments
|
||||
#
|
||||
|
@ -34,6 +31,7 @@ module Mutant
|
|||
--fail-fast
|
||||
) + strategy.spec_files(mutation.subject)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,13 +19,11 @@ module Mutant
|
|||
|
||||
# Killer that is always successful
|
||||
class Success < self
|
||||
TYPE = 'success'.freeze
|
||||
RESULT = true
|
||||
end
|
||||
|
||||
# Killer that always fails
|
||||
class Fail < self
|
||||
TYPE = 'fail'.freeze
|
||||
RESULT = false
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue