Class: Evilution::Runner::MutationExecutor::Strategy::Parallel

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/runner/mutation_executor/strategy/parallel.rb

Instance Method Summary collapse

Constructor Details

#initialize(cache:, isolator:, packer:, pipeline:, notifier:, pool_factory:, config:, diagnostics: nil) ⇒ Parallel

Returns a new instance of Parallel.



8
9
10
11
12
13
14
15
16
17
# File 'lib/evilution/runner/mutation_executor/strategy/parallel.rb', line 8

def initialize(cache:, isolator:, packer:, pipeline:, notifier:, pool_factory:, config:, diagnostics: nil)
  @cache = cache
  @isolator = isolator
  @packer = packer
  @pipeline = pipeline
  @notifier = notifier
  @pool_factory = pool_factory
  @diagnostics = diagnostics
  @config = config
end

Instance Method Details

#call(mutations, baseline_result:, integration:) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/evilution/runner/mutation_executor/strategy/parallel.rb', line 19

def call(mutations, baseline_result:, integration:)
  @notifier.start(mutations.length)
  pool = @pool_factory.call
  state = { results: [], truncated: false, completed: 0 }
  all_worker_stats = []

  mutations.each_slice(@config.jobs) do |batch|
    break if state[:truncated]

    batch_results = run_batch(batch, pool, integration)
    all_worker_stats.concat(pool.worker_stats)
    process_batch(batch_results, baseline_result, state)
  end

  @diagnostics.log_worker_stats(@diagnostics.aggregate_worker_stats(all_worker_stats)) if @diagnostics
  @notifier.finish
  [state[:results], state[:truncated]]
end