Class: Henitai::Integration::Base
- Inherits:
-
Object
- Object
- Henitai::Integration::Base
- Includes:
- ChildDebugSupport, ChildRuntimeControl
- Defined in:
- lib/henitai/integration/base.rb
Overview
Base class for all integrations. Provides the framework-agnostic child process lifecycle (wait, timeout handling, cleanup) and subprocess environment helpers. Concrete adapters mix in MutantRunSupport and implement #run_tests plus test selection.
Instance Method Summary collapse
- #cleanup_process_group(pid) ⇒ Object
- #per_test_coverage_supported? ⇒ Boolean
- #reap_child(pid) ⇒ Object
-
#run_mutant(mutant:, test_files:, timeout:) ⇒ ScenarioExecutionResult
Run test files in a child process with the mutant active.
-
#select_tests(subject) ⇒ Array<String>
Paths to test files that cover this subject.
-
#spawn_mutant(mutant:, test_files:) ⇒ RspecProcessRunner::ChildHandle
Fork a child process for the mutant without waiting for it to finish.
-
#test_files ⇒ Array<String>
All test files for the configured framework.
- #wait_with_timeout(pid, timeout) ⇒ Object
Instance Method Details
#cleanup_process_group(pid) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/henitai/integration/base.rb', line 75 def cleanup_process_group(pid) grace_period = 2.0 wakeup = Henitai.const_get(:ProcessWakeup).new.install Process.kill(:SIGTERM, -pid) return if wait_nonblocking(pid) wakeup.wait(grace_period) wakeup.drain return if wait_nonblocking(pid) Process.kill(:SIGKILL, -pid) rescue Errno::EPERM cleanup_child_process(pid) rescue Errno::ESRCH nil ensure wakeup&.close end |
#per_test_coverage_supported? ⇒ Boolean
51 52 53 |
# File 'lib/henitai/integration/base.rb', line 51 def per_test_coverage_supported? false end |
#reap_child(pid) ⇒ Object
69 70 71 72 73 |
# File 'lib/henitai/integration/base.rb', line 69 def reap_child(pid) Process.wait(pid) rescue Errno::ECHILD, Errno::ESRCH nil end |
#run_mutant(mutant:, test_files:, timeout:) ⇒ ScenarioExecutionResult
Run test files in a child process with the mutant active.
36 37 38 |
# File 'lib/henitai/integration/base.rb', line 36 def run_mutant(mutant:, test_files:, timeout:) raise NotImplementedError end |
#select_tests(subject) ⇒ Array<String>
Returns paths to test files that cover this subject.
21 22 23 |
# File 'lib/henitai/integration/base.rb', line 21 def select_tests(subject) raise NotImplementedError end |
#spawn_mutant(mutant:, test_files:) ⇒ RspecProcessRunner::ChildHandle
Fork a child process for the mutant without waiting for it to finish. Returns a ChildHandle carrying the OS pid and log file paths. The caller is responsible for waiting and cleanup.
47 48 49 |
# File 'lib/henitai/integration/base.rb', line 47 def spawn_mutant(mutant:, test_files:) raise NotImplementedError end |
#test_files ⇒ Array<String>
Returns all test files for the configured framework.
26 27 28 |
# File 'lib/henitai/integration/base.rb', line 26 def test_files raise NotImplementedError end |
#wait_with_timeout(pid, timeout) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/henitai/integration/base.rb', line 55 def wait_with_timeout(pid, timeout) wakeup = Henitai.const_get(:ProcessWakeup).new.install return Process.last_status if wait_nonblocking(pid) wakeup.wait(timeout) wakeup.drain return Process.last_status if wait_nonblocking(pid) return Process.last_status if wait_nonblocking(pid) handle_timeout(pid) ensure wakeup&.close end |