Change runner to use queue parallel interface
* This should make the use of --fail-fast flag more deterministic.
This commit is contained in:
parent
5a30fb3969
commit
9e333f40f9
2 changed files with 45 additions and 22 deletions
|
@ -1,6 +1,7 @@
|
|||
# v0.6.4 2014-10-xx
|
||||
|
||||
* Do not buffer report prints, speedup large report generation.
|
||||
* Fix some cases where --fail-fast semantics stopped far to late.
|
||||
|
||||
# v0.6.3 2014-09-22
|
||||
|
||||
|
|
|
@ -12,19 +12,21 @@ module Mutant
|
|||
def initialize(env)
|
||||
super
|
||||
|
||||
@collector = Collector.new(env)
|
||||
@mutex = Mutex.new
|
||||
@mutations = env.mutations.dup
|
||||
@collector = Collector.new(env)
|
||||
@mutex = Mutex.new
|
||||
@mutations = env.mutations.dup
|
||||
@index = 0
|
||||
@continue = true
|
||||
|
||||
config.integration.setup
|
||||
|
||||
config.reporter.start(env)
|
||||
reporter.start(env)
|
||||
|
||||
run
|
||||
|
||||
@result = @collector.result.update(done: true)
|
||||
|
||||
config.reporter.report(result)
|
||||
reporter.report(result)
|
||||
end
|
||||
|
||||
# Return result
|
||||
|
@ -45,7 +47,7 @@ module Mutant
|
|||
#
|
||||
def run
|
||||
Parallel.map(
|
||||
@mutations,
|
||||
method(:next),
|
||||
in_threads: config.jobs,
|
||||
finish: method(:finish),
|
||||
start: method(:start),
|
||||
|
@ -53,6 +55,28 @@ module Mutant
|
|||
)
|
||||
end
|
||||
|
||||
# Return next mutation or stop
|
||||
#
|
||||
# @return [Mutation]
|
||||
# in case there is a next mutation
|
||||
#
|
||||
# @return [Parallel::Stop]
|
||||
# in case there is no next mutation or runner should stop early
|
||||
#
|
||||
#
|
||||
# @api private
|
||||
def next
|
||||
@mutex.synchronize do
|
||||
mutation = @mutations.at(@index)
|
||||
if @continue && mutation
|
||||
@index += 1
|
||||
mutation
|
||||
else
|
||||
Parallel::Stop
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Handle started mutation
|
||||
#
|
||||
# @param [Mutation] mutation
|
||||
|
@ -100,22 +124,10 @@ module Mutant
|
|||
#
|
||||
def process_result(result)
|
||||
@collector.finish(result)
|
||||
config.reporter.progress(@collector)
|
||||
handle_exit(result)
|
||||
end
|
||||
|
||||
# Handle exit if needed
|
||||
#
|
||||
# @param [Result::Mutation] result
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def handle_exit(result)
|
||||
return if !config.fail_fast || result.success?
|
||||
|
||||
@mutations.clear
|
||||
reporter.progress(@collector)
|
||||
if !result.success? && config.fail_fast
|
||||
@continue = false
|
||||
end
|
||||
end
|
||||
|
||||
# Run mutation
|
||||
|
@ -183,5 +195,15 @@ module Mutant
|
|||
)
|
||||
end
|
||||
|
||||
# Return reporter
|
||||
#
|
||||
# @return [Reporter]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def reporter
|
||||
config.reporter
|
||||
end
|
||||
|
||||
end # Runner
|
||||
end # Mutant
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue