Module: Henitai::Integration::MutantRunSupport
Overview
Framework-agnostic orchestration for running a single mutant in a child process and turning the captured child output into a ScenarioExecutionResult.
The framework-specific test invocation is delegated to #run_tests, which including classes must implement.
Instance Method Summary collapse
- #build_result(wait_result, log_paths) ⇒ Object
- #mutant_log_name(mutant) ⇒ Object
- #run_in_child(mutant:, test_files:, log_paths:) ⇒ Object
- #run_mutant(mutant:, test_files:, timeout:) ⇒ Object
- #scenario_log_paths(name) ⇒ Object
- #spawn_mutant(mutant:, test_files:) ⇒ Object
Instance Method Details
#build_result(wait_result, log_paths) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/henitai/integration/mutant_run_support.rb', line 32 def build_result(wait_result, log_paths) stdout = scenario_log_support.read_log_file(log_paths[:stdout_path]) stderr = scenario_log_support.read_log_file(log_paths[:stderr_path]) scenario_log_support.write_combined_log(log_paths[:log_path], stdout, stderr) ScenarioExecutionResult.build( wait_result:, stdout:, stderr:, log_path: log_paths[:log_path] ) end |
#mutant_log_name(mutant) ⇒ Object
57 58 59 |
# File 'lib/henitai/integration/mutant_run_support.rb', line 57 def mutant_log_name(mutant) "mutant-#{mutant.id}" end |
#run_in_child(mutant:, test_files:, log_paths:) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/henitai/integration/mutant_run_support.rb', line 45 def run_in_child(mutant:, test_files:, log_paths:) Thread.report_on_exception = false with_subprocess_env do suppress_simplecov! suppress_coverage! install_debug_timeout_trap if debug_child? with_non_interactive_stdin do run_child_activation_and_tests(mutant:, test_files:, log_paths:) end end end |
#run_mutant(mutant:, test_files:, timeout:) ⇒ Object
18 19 20 |
# File 'lib/henitai/integration/mutant_run_support.rb', line 18 def run_mutant(mutant:, test_files:, timeout:) RspecProcessRunner.new.run_mutant(self, mutant:, test_files:, timeout:) end |
#scenario_log_paths(name) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/henitai/integration/mutant_run_support.rb', line 22 def scenario_log_paths(name) reports_dir = ENV.fetch("HENITAI_REPORTS_DIR", "reports") log_dir = File.join(reports_dir, "mutation-logs") { stdout_path: File.join(log_dir, "#{name}.stdout.log"), stderr_path: File.join(log_dir, "#{name}.stderr.log"), log_path: File.join(log_dir, "#{name}.log") } end |
#spawn_mutant(mutant:, test_files:) ⇒ Object
13 14 15 16 |
# File 'lib/henitai/integration/mutant_run_support.rb', line 13 def spawn_mutant(mutant:, test_files:) log_paths = scenario_log_paths(mutant_log_name(mutant)) RspecProcessRunner.new.spawn_mutant(self, mutant:, test_files:, log_paths:) end |