Move test selection out of stategy
This commit is contained in:
parent
99ea641185
commit
19896c4d29
4 changed files with 23 additions and 23 deletions
|
@ -29,5 +29,26 @@ module Mutant
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return tests for mutation
|
||||||
|
#
|
||||||
|
# TODO: This logic is now centralized but still fucked.
|
||||||
|
#
|
||||||
|
# @param [Mutation] mutation
|
||||||
|
#
|
||||||
|
# @return [Enumerable<Test>]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def tests(subject)
|
||||||
|
subject.match_expressions.each do |match_expression|
|
||||||
|
tests = strategy.all_tests.select do |test|
|
||||||
|
match_expression.prefix?(test.expression)
|
||||||
|
end
|
||||||
|
return tests if tests.any?
|
||||||
|
end
|
||||||
|
|
||||||
|
EMPTY_ARRAY
|
||||||
|
end
|
||||||
|
|
||||||
end # Config
|
end # Config
|
||||||
end # Mutant
|
end # Mutant
|
||||||
|
|
|
@ -64,7 +64,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def tests
|
def tests
|
||||||
config.strategy.tests(subject)
|
config.tests(subject)
|
||||||
end
|
end
|
||||||
memoize :tests
|
memoize :tests
|
||||||
|
|
||||||
|
|
|
@ -62,27 +62,6 @@ module Mutant
|
||||||
#
|
#
|
||||||
abstract_method :all_tests
|
abstract_method :all_tests
|
||||||
|
|
||||||
# Return tests for mutation
|
|
||||||
#
|
|
||||||
# TODO: This logic is now centralized but still fucked.
|
|
||||||
#
|
|
||||||
# @param [Mutation] mutation
|
|
||||||
#
|
|
||||||
# @return [Enumerable<Test>]
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
def tests(subject)
|
|
||||||
subject.match_expressions.each do |match_expression|
|
|
||||||
tests = all_tests.select do |test|
|
|
||||||
match_expression.prefix?(test.expression)
|
|
||||||
end
|
|
||||||
return tests if tests.any?
|
|
||||||
end
|
|
||||||
|
|
||||||
EMPTY_ARRAY
|
|
||||||
end
|
|
||||||
|
|
||||||
# Null strategy that never kills a mutation
|
# Null strategy that never kills a mutation
|
||||||
class Null < self
|
class Null < self
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ describe Mutant::Runner::Subject, '#success?' do
|
||||||
let(:tests) { [double('test a'), double('test b')] }
|
let(:tests) { [double('test a'), double('test b')] }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
expect(strategy).to receive(:tests).with(mutation_subject).and_return(tests)
|
expect(config).to receive(:tests).with(mutation_subject).and_return(tests)
|
||||||
expect(Mutant::Runner).to receive(:run).with(config, mutation_a, tests).and_return(runner_a)
|
expect(Mutant::Runner).to receive(:run).with(config, mutation_a, tests).and_return(runner_a)
|
||||||
expect(Mutant::Runner).to receive(:run).with(config, mutation_b, tests).and_return(runner_b)
|
expect(Mutant::Runner).to receive(:run).with(config, mutation_b, tests).and_return(runner_b)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue