Use visit_collection in runner to restore --fail-fast behavior
This commit is contained in:
parent
4b7efe5f5c
commit
c1b389c28f
5 changed files with 38 additions and 11 deletions
|
@ -48,9 +48,9 @@ module Mutant
|
|||
#
|
||||
# @api private
|
||||
#
|
||||
def self.run(config, object)
|
||||
def self.run(config, object, *arguments)
|
||||
handler = lookup(object.class)
|
||||
handler.new(config, object)
|
||||
handler.new(config, object, *arguments)
|
||||
end
|
||||
|
||||
# Return config
|
||||
|
@ -153,10 +153,10 @@ module Mutant
|
|||
#
|
||||
# @api private
|
||||
#
|
||||
def visit_collection(input)
|
||||
def visit_collection(input, *arguments)
|
||||
collection = []
|
||||
input.each do |object|
|
||||
runner = visit(object)
|
||||
runner = visit(object, *arguments)
|
||||
collection << runner
|
||||
@stop = runner.stop?
|
||||
break if @stop
|
||||
|
@ -172,8 +172,8 @@ module Mutant
|
|||
#
|
||||
# @api private
|
||||
#
|
||||
def visit(object)
|
||||
Runner.run(config, object)
|
||||
def visit(object, *arguments)
|
||||
Runner.run(config, object, *arguments)
|
||||
end
|
||||
|
||||
end # Runner
|
||||
|
|
|
@ -37,6 +37,7 @@ module Mutant
|
|||
def initialize(config, mutation, tests)
|
||||
@mutation, @tests = mutation, tests
|
||||
super(config)
|
||||
@stop = config.fail_fast && !success?
|
||||
end
|
||||
|
||||
# Test if mutation was handeled successfully
|
||||
|
|
|
@ -74,9 +74,7 @@ module Mutant
|
|||
def run
|
||||
progress(subject)
|
||||
tests = config.strategy.tests(subject)
|
||||
@mutations = subject.mutations.map do |mutation|
|
||||
Runner::Mutation.new(config, mutation, tests)
|
||||
end
|
||||
@mutations = visit_collection(subject.mutations, tests)
|
||||
progress(self)
|
||||
end
|
||||
|
||||
|
|
|
@ -42,6 +42,34 @@ describe Mutant::Runner::Mutation do
|
|||
strategy.stub(killers: killers)
|
||||
end
|
||||
|
||||
describe '#stop?' do
|
||||
subject { object.stop? }
|
||||
|
||||
context 'when fail fast is false' do
|
||||
it { should be(false) }
|
||||
end
|
||||
|
||||
context 'when fail fast is true' do
|
||||
let(:fail_fast) { true }
|
||||
|
||||
context 'when all killers are successful' do
|
||||
it { should be(false) }
|
||||
end
|
||||
|
||||
context 'when one killer is NOT successful' do
|
||||
let(:success_b) { false }
|
||||
it { should be(false) }
|
||||
end
|
||||
|
||||
context 'when all killer are NOT successful' do
|
||||
let(:success_b) { false }
|
||||
let(:success_a) { false }
|
||||
|
||||
it { should be(true) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#success?' do
|
||||
subject { object.success? }
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ describe Mutant::Runner::Subject, '#success?' do
|
|||
|
||||
before do
|
||||
expect(strategy).to receive(:tests).with(mutation_subject).and_return(tests)
|
||||
expect(Mutant::Runner::Mutation).to receive(:new).with(config, mutation_a, tests).and_return(runner_a)
|
||||
expect(Mutant::Runner::Mutation).to receive(:new).with(config, mutation_b, tests).and_return(runner_b)
|
||||
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)
|
||||
end
|
||||
|
||||
context 'with failing mutations' do
|
||||
|
|
Loading…
Add table
Reference in a new issue