From 1f7ba129a572b403fefaf0757c4a4af18e788679 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Wed, 14 Feb 2024 01:41:25 +0000 Subject: [PATCH] Change to process warmup in parallel abstraction * This will benefit all future parallel clients, not just the mutation runner. --- lib/mutant/mutation/runner.rb | 2 -- lib/mutant/parallel.rb | 5 ++++- scripts/devloop.sh | 2 +- spec/unit/mutant/mutation/runner_spec.rb | 10 ---------- spec/unit/mutant/parallel_spec.rb | 15 ++++++++++++++- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/mutant/mutation/runner.rb b/lib/mutant/mutation/runner.rb index 032615798..701274f22 100644 --- a/lib/mutant/mutation/runner.rb +++ b/lib/mutant/mutation/runner.rb @@ -15,8 +15,6 @@ def self.call(env) def self.run_mutation_analysis(env) reporter = reporter(env) - env.world.process_warmup - env .record(:analysis) { run_driver(reporter, async_driver(env)) } .tap { |result| env.record(:report) { reporter.report(result) } } diff --git a/lib/mutant/parallel.rb b/lib/mutant/parallel.rb index ccec145a4..60761bf38 100644 --- a/lib/mutant/parallel.rb +++ b/lib/mutant/parallel.rb @@ -10,7 +10,10 @@ module Parallel # # @return [Driver] def self.async(world, config) - shared = shared_state(world, config) + shared = shared_state(world, config) + + world.process_warmup + workers = workers(world, config, shared) Driver.new( diff --git a/scripts/devloop.sh b/scripts/devloop.sh index e17dfda4c..e4db067db 100755 --- a/scripts/devloop.sh +++ b/scripts/devloop.sh @@ -1,5 +1,5 @@ while inotifywait lib/**/*.rb meta/**/*.rb spec/**/*.rb Gemfile Gemfile.shared mutant.gemspec; do - bundle exec rspec spec/unit -fd --fail-fast --order default \ + bundle exec rspec spec/unit -fd --fail-fast --order defined \ && bundle exec mutant run --since main --fail-fast --zombie -- 'Mutant*' \ && bundle exec rubocop done diff --git a/spec/unit/mutant/mutation/runner_spec.rb b/spec/unit/mutant/mutation/runner_spec.rb index 972eac2a9..40345a74c 100644 --- a/spec/unit/mutant/mutation/runner_spec.rb +++ b/spec/unit/mutant/mutation/runner_spec.rb @@ -72,11 +72,6 @@ def apply selector: :start, arguments: [env] }, - { - receiver: world, - selector: :process_warmup, - arguments: [] - }, { receiver: env, selector: :record, @@ -154,11 +149,6 @@ def apply selector: :start, arguments: [env] }, - { - receiver: world, - selector: :process_warmup, - arguments: [] - }, { receiver: env, selector: :record, diff --git a/spec/unit/mutant/parallel_spec.rb b/spec/unit/mutant/parallel_spec.rb index dbe270050..ba6284ece 100644 --- a/spec/unit/mutant/parallel_spec.rb +++ b/spec/unit/mutant/parallel_spec.rb @@ -18,7 +18,15 @@ def apply let(:var_running) { instance_double(Mutant::Variable::MVar, :running) } let(:var_sink) { instance_double(Mutant::Variable::IVar, :sink) } let(:var_source) { instance_double(Mutant::Variable::IVar, :source) } - let(:world) { fake_world } + + let(:world) do + instance_double( + Mutant::World, + condition_variable: class_double(ConditionVariable), + mutex: class_double(Mutex), + thread: class_double(Thread) + ) + end let(:worker_a) do instance_double(described_class::Worker, :a, index: 0) @@ -109,6 +117,11 @@ def thread(name, thread, worker) mvar(var_running, value: 2), ivar(var_sink, value: sink), ivar(var_source, value: source), + { + receiver: world, + selector: :process_warmup, + arguments: [] + }, worker(0, 'parallel-process-0', worker_a), worker(1, 'parallel-process-1', worker_b), *thread('parallel-thread-0', thread_a, worker_a),