henitai 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +111 -1
  3. data/README.md +23 -6
  4. data/assets/schema/henitai.schema.json +6 -0
  5. data/lib/henitai/bootstrap_error_message.rb +20 -2
  6. data/lib/henitai/checkpoint_reporter.rb +5 -0
  7. data/lib/henitai/cli/operator_command.rb +10 -3
  8. data/lib/henitai/cli.rb +2 -1
  9. data/lib/henitai/composite_progress_reporter.rb +15 -2
  10. data/lib/henitai/configuration.rb +6 -1
  11. data/lib/henitai/configuration_validator/rules.rb +1 -0
  12. data/lib/henitai/configuration_validator/scalars.rb +13 -0
  13. data/lib/henitai/configuration_validator.rb +2 -1
  14. data/lib/henitai/control_gate.rb +78 -0
  15. data/lib/henitai/control_run.rb +37 -43
  16. data/lib/henitai/coverage_bootstrapper.rb +12 -3
  17. data/lib/henitai/execution_engine/env_scope.rb +3 -3
  18. data/lib/henitai/execution_engine/fork_server_scope.rb +6 -6
  19. data/lib/henitai/execution_engine.rb +74 -99
  20. data/lib/henitai/execution_provenance.rb +67 -0
  21. data/lib/henitai/flaky_detection_baseline.rb +5 -3
  22. data/lib/henitai/fork_server/client.rb +0 -9
  23. data/lib/henitai/fork_server/mutant_runner.rb +14 -45
  24. data/lib/henitai/fork_server.rb +0 -1
  25. data/lib/henitai/history_checkpointer.rb +72 -0
  26. data/lib/henitai/integration/base.rb +6 -14
  27. data/lib/henitai/integration/child_report_store.rb +34 -5
  28. data/lib/henitai/integration/minitest.rb +1 -8
  29. data/lib/henitai/integration/minitest_fail_fast.rb +43 -0
  30. data/lib/henitai/integration/minitest_outcome_reporter.rb +17 -1
  31. data/lib/henitai/integration/minitest_test_runner.rb +16 -4
  32. data/lib/henitai/integration/mutant_run_support.rb +11 -8
  33. data/lib/henitai/integration/rspec_child_runner.rb +12 -7
  34. data/lib/henitai/integration/rspec_file_order.rb +37 -0
  35. data/lib/henitai/integration/rspec_process_runner.rb +0 -19
  36. data/lib/henitai/integration.rb +2 -3
  37. data/lib/henitai/kill_history/store.rb +67 -0
  38. data/lib/henitai/kill_history.rb +85 -0
  39. data/lib/henitai/mutant.rb +5 -0
  40. data/lib/henitai/mutant_history_store/database.rb +61 -0
  41. data/lib/henitai/mutant_history_store/sql.rb +9 -3
  42. data/lib/henitai/mutant_history_store/subject_scans.rb +101 -0
  43. data/lib/henitai/mutant_history_store/verdict_cache.rb +40 -11
  44. data/lib/henitai/mutant_history_store.rb +66 -50
  45. data/lib/henitai/operator.rb +6 -2
  46. data/lib/henitai/operators/equality_identity_operator.rb +2 -2
  47. data/lib/henitai/operators/hash_key_type.rb +11 -1
  48. data/lib/henitai/operators/hash_literal.rb +30 -5
  49. data/lib/henitai/operators/string_literal.rb +17 -4
  50. data/lib/henitai/process_worker_runner.rb +23 -3
  51. data/lib/henitai/reuse_context.rb +4 -2
  52. data/lib/henitai/rspec_outcomes.rb +3 -1
  53. data/lib/henitai/runner.rb +54 -2
  54. data/lib/henitai/runner_dependencies.rb +23 -3
  55. data/lib/henitai/scenario_execution_result.rb +27 -4
  56. data/lib/henitai/signal_deferral.rb +25 -0
  57. data/lib/henitai/slot_scheduler/control_slots.rb +58 -0
  58. data/lib/henitai/slot_scheduler/draining.rb +25 -6
  59. data/lib/henitai/slot_scheduler/retry_policy.rb +13 -1
  60. data/lib/henitai/slot_scheduler.rb +18 -14
  61. data/lib/henitai/test_file_outcomes.rb +15 -1
  62. data/lib/henitai/test_prioritizer.rb +10 -2
  63. data/lib/henitai/version.rb +1 -1
  64. data/lib/henitai.rb +5 -1
  65. data/sig/henitai.rbs +42 -24
  66. metadata +21 -6
  67. data/lib/henitai/flaky_mutant_retrier.rb +0 -43
  68. data/lib/henitai/fork_server/group_terminator.rb +0 -47
data/sig/henitai.rbs CHANGED
@@ -198,6 +198,7 @@ module Henitai
198
198
  DEFAULT_MAX_FLAKY_RETRIES: Integer
199
199
  DEFAULT_MAX_LOG_BYTES: Integer
200
200
  DEFAULT_MAX_TIMEOUT: Float
201
+ DEFAULT_SUITE_TIMEOUT: Float
201
202
  DEFAULT_CHECKPOINT_EVERY: Integer
202
203
  DEFAULT_CHECKPOINT_INTERVAL: Float
203
204
  DEFAULT_REPORTS_DIR: String
@@ -220,6 +221,7 @@ module Henitai
220
221
  attr_reader fork_server: bool
221
222
  attr_reader max_log_bytes: Integer
222
223
  attr_reader max_timeout: Float
224
+ attr_reader suite_timeout: Float
223
225
  attr_reader sampling: untyped
224
226
  attr_reader jobs: untyped
225
227
  attr_reader coverage_criteria: Hash[Symbol, untyped]
@@ -260,11 +262,12 @@ module Henitai
260
262
  attr_reader log_path: String
261
263
  attr_reader status_reason: String?
262
264
  attr_reader killing_tests: Array[String]
265
+ attr_reader hanging_test: String?
263
266
 
264
267
  def self.build: (wait_result: untyped, stdout: String?, stderr: String?, log_path: String) -> ScenarioExecutionResult
265
- def self.build_for_mutant: (wait_result: untyped, report: untyped, stdout: String?, stderr: String?, log_path: String) -> ScenarioExecutionResult
268
+ def self.build_for_mutant: (wait_result: untyped, report: untyped, stdout: String?, stderr: String?, log_path: String, ?running_test: String?) -> ScenarioExecutionResult
266
269
  def self.copy_reason: (untyped, untyped) -> String?
267
- def initialize: (status: Symbol, stdout: String?, stderr: String?, log_path: String, ?exit_status: Integer?, ?status_reason: String?, ?killing_tests: Array[String]) -> void
270
+ def initialize: (status: Symbol, stdout: String?, stderr: String?, log_path: String, ?exit_status: Integer?, ?status_reason: String?, ?killing_tests: Array[String], ?hanging_test: String?) -> void
268
271
  def release_output!: () -> self
269
272
  def survived?: () -> bool
270
273
  def killed?: () -> bool
@@ -321,6 +324,7 @@ module Henitai
321
324
  attr_accessor status_reason: String?
322
325
  attr_accessor identity_discriminator: String?
323
326
  attr_accessor from_cache: bool
327
+ attr_accessor retry_cut_short: bool
324
328
  attr_reader precomputed_stable_id: String?
325
329
  attr_reader precomputed_activation: untyped
326
330
  attr_reader precomputed_replacement: String?
@@ -329,6 +333,7 @@ module Henitai
329
333
  def stable_id: () -> String
330
334
  def mutated_source: () -> String
331
335
  def from_cache?: () -> bool
336
+ def retry_cut_short?: () -> bool
332
337
  def killed?: () -> bool
333
338
  def survived?: () -> bool
334
339
  def pending?: () -> bool
@@ -447,7 +452,7 @@ module Henitai
447
452
 
448
453
  class TestPrioritizer
449
454
  def initialize: (?timing_source: untyped?) -> void
450
- def sort: (Array[String], untyped, Hash[untyped, untyped]) -> Array[String]
455
+ def sort: (Array[String], untyped, untyped) -> Array[String]
451
456
 
452
457
  private
453
458
 
@@ -480,7 +485,6 @@ module Henitai
480
485
 
481
486
  def select_tests: (Subject) -> Array[String]
482
487
  def test_files: () -> Array[String]
483
- def run_mutant: (mutant: Mutant, test_files: Array[String], timeout: Float) -> ScenarioExecutionResult
484
488
  def spawn_mutant: (mutant: Mutant, test_files: Array[String]) -> ChildHandle
485
489
  def run_suite: (Array[String], ?timeout: Float) -> ScenarioExecutionResult
486
490
  def per_test_coverage_supported?: () -> bool
@@ -506,7 +510,6 @@ module Henitai
506
510
 
507
511
  module MutantRunSupport
508
512
  def spawn_mutant: (mutant: Mutant, test_files: Array[String]) -> ChildHandle
509
- def run_mutant: (mutant: Mutant, test_files: Array[String], timeout: Float) -> ScenarioExecutionResult
510
513
  def scenario_log_paths: (String) -> Hash[Symbol, String]
511
514
  def build_result: (untyped, Hash[Symbol, String]) -> ScenarioExecutionResult
512
515
  def run_in_child: (mutant: Mutant, test_files: Array[String], log_paths: Hash[Symbol, String]) -> Integer
@@ -561,7 +564,6 @@ module Henitai
561
564
  end
562
565
 
563
566
  class RspecProcessRunner
564
- def run_mutant: (Base, mutant: Mutant, test_files: Array[String], timeout: Float) -> ScenarioExecutionResult
565
567
  def run_suite: (Base, Array[String], timeout: Float) -> ScenarioExecutionResult
566
568
  def spawn_mutant: (Base, mutant: Mutant, test_files: Array[String], log_paths: Hash[Symbol, String]) -> ChildHandle
567
569
  end
@@ -608,7 +610,6 @@ module Henitai
608
610
 
609
611
  def test_files: () -> Array[String]
610
612
  def per_test_coverage_supported?: () -> bool
611
- def run_mutant: (mutant: Mutant, test_files: Array[String], timeout: Float) -> ScenarioExecutionResult
612
613
  def spawn_mutant: (mutant: Mutant, test_files: Array[String]) -> ChildHandle
613
614
  def run_in_child: (mutant: Mutant, test_files: Array[String], log_paths: Hash[Symbol, String]) -> Integer
614
615
  def run_suite: (Array[String], ?timeout: Float) -> ScenarioExecutionResult
@@ -648,11 +649,27 @@ module Henitai
648
649
  def self.legacy_stable_id: (Mutant) -> String
649
650
  end
650
651
 
652
+ class HistoryCheckpointer
653
+ attr_reader committed: Integer
654
+ def initialize: (history_store: untyped, config: untyped, run_id: String, ?version: String, ?clock: untyped, ?warner: untyped) -> void
655
+ def progress: (untyped, **untyped) -> void
656
+ def flush: () -> void
657
+ end
658
+
659
+ class ExecutionProvenance
660
+ UNCAPTURED: untyped
661
+ def self.capture: (Array[String], ?root: String) -> ExecutionProvenance
662
+ def self.stat_of: (String) -> Array[Integer]?
663
+ def initialize: (stats: Hash[String, Array[Integer]?], dependencies: Array[String], root: String) -> void
664
+ def intact?: (Array[String]) -> bool
665
+ end
666
+
651
667
  class MutantHistoryStore
652
668
  attr_reader path: String
653
669
 
654
- def initialize: (path: String, ?per_test_coverage: PerTestCoverage?, ?reuse_context: ReuseContext?) -> void
655
- def record: (untyped, version: String, ?recorded_at: Time) -> void
670
+ def initialize: (path: String, ?per_test_coverage: PerTestCoverage?, ?reuse_context: ReuseContext?, ?provenance: untyped) -> void
671
+ def record: (untyped, version: String, ?recorded_at: Time, ?run_id: String?) -> void
672
+ def checkpoint: (Array[untyped], version: String, run_id: String, ?recorded_at: Time) -> Integer
656
673
  def verdict_for: (String) -> Hash[Symbol, untyped]?
657
674
  def killed_verdict_for: (String) -> Hash[Symbol, untyped]?
658
675
  def trend_report: () -> Hash[Symbol, untyped]
@@ -862,17 +879,15 @@ module Henitai
862
879
  end
863
880
 
864
881
  class ExecutionEngine
882
+ def initialize: (?runtime: untyped, ?wakeup: untyped) -> void
865
883
  def run: (Array[Mutant], untyped, untyped, ?progress_reporter: untyped) -> Array[Mutant]
866
884
 
867
885
  private
868
886
 
869
887
  def execute: (Array[Mutant], untyped, untyped, untyped?) -> Array[Mutant]
870
888
  def with_worker_slot: () { () -> untyped } -> untyped
871
- def parallel_execution?: (untyped, Array[Mutant]) -> bool
872
889
  def worker_count: (untyped) -> Integer
873
- def run_linear: (Array[Mutant], untyped, untyped, untyped?, untyped) -> void
874
- def run_parallel: (Array[Mutant], untyped, untyped, untyped?) -> void
875
- def process_mutant: (Mutant, untyped, untyped, untyped?, ?untyped) -> void
890
+ def run_workers: (Array[Mutant], untyped, untyped, untyped?, untyped) -> untyped
876
891
  def prioritized_tests_for: (Mutant, untyped, untyped) -> Array[String]
877
892
  def test_prioritizer: (untyped) -> TestPrioritizer
878
893
  def timing_source: (untyped) -> untyped
@@ -1207,7 +1222,10 @@ module Henitai
1207
1222
  def reuse_context: () -> ReuseContext
1208
1223
  def reuse_filter: () -> IncrementalFilter
1209
1224
  def history_store: () -> untyped
1210
- def progress_reporter: (full_run: bool) -> untyped
1225
+ def capture_provenance: (Array[String]) -> ExecutionProvenance
1226
+ def execution_provenance: () -> untyped
1227
+ def progress_reporter: (full_run: bool, ?history_checkpointer: untyped) -> untyped
1228
+ def history_checkpointer: (run_id: String) -> HistoryCheckpointer?
1211
1229
  def source_provider: () -> ^(String) -> String
1212
1230
  end
1213
1231
 
@@ -1262,7 +1280,12 @@ module Henitai
1262
1280
  def integration: () -> untyped
1263
1281
  def operators: () -> untyped
1264
1282
  def progress_reporter: () -> untyped?
1283
+ def history_checkpointer: () -> HistoryCheckpointer?
1284
+ def run_id: () -> String
1285
+ def save_interrupted_progress: () -> void
1286
+ def flush_progress: () -> void
1265
1287
  def history_store: () -> untyped
1288
+ def full_mutant_set?: () -> bool
1266
1289
  def per_test_coverage: () -> PerTestCoverage
1267
1290
  def reuse_filter: () -> IncrementalFilter
1268
1291
  def source_selection_coverage: () -> PerTestCoverage
@@ -1277,6 +1300,7 @@ module Henitai
1277
1300
  def build_result_object: (Array[Mutant], Time, Time) -> Result
1278
1301
  def pipeline_mutants: () -> Array[Mutant]
1279
1302
  def apply_incremental_filter: (Array[Mutant]) -> Array[Mutant]
1303
+ def capture_provenance: () -> ExecutionProvenance
1280
1304
  def dry_run_result: (Array[Mutant], Time, Time) -> Result
1281
1305
  def source_provider: () -> ^(String) -> String
1282
1306
  def persist_history: (Result, Time) -> void
@@ -1373,7 +1397,8 @@ module Henitai
1373
1397
  def self.report_path: (String) -> String
1374
1398
  def self.default_report_path: () -> String
1375
1399
  def self.load: (String) -> TestFileOutcomes
1376
- def initialize: () -> void
1400
+ def initialize: (?on_started: ^(String) -> untyped?) -> void
1401
+ def started: (String) -> void
1377
1402
  def record: (String, failed: bool) -> void
1378
1403
  def record_unattributed_failure: () -> void
1379
1404
  def unattributed_failures?: () -> bool
@@ -1397,25 +1422,18 @@ module Henitai
1397
1422
  end
1398
1423
 
1399
1424
  class FlakyDetectionBaseline
1400
- def initialize: (reports_dir: String) -> void
1425
+ def initialize: (reports_dir: String, ?timeout: Numeric) -> void
1401
1426
  def run: (integration: untyped, test_files: Array[String]) -> FlakyTestRegistry
1402
1427
  end
1403
1428
 
1404
1429
  module BootstrapErrorMessage
1405
1430
  GENERIC: String
1406
1431
 
1407
- def self.build: (untyped) -> String
1432
+ def self.build: (untyped, ?timeout: Numeric?) -> String
1408
1433
  end
1409
1434
 
1410
1435
  class FlakyRetryDecision
1411
1436
  def initialize: (flaky_tests: FlakyTestRegistry, max_retries: Integer) -> void
1412
1437
  def retry?: (status: Symbol, killing_tests: Array[String], attempts: Integer) -> bool
1413
1438
  end
1414
-
1415
- class FlakyMutantRetrier
1416
- attr_reader retried_count: Integer
1417
-
1418
- def initialize: (flaky_tests: FlakyTestRegistry, max_retries: Integer) -> void
1419
- def run: (mutant: Mutant, integration: untyped, test_files: Array[String], timeout: Float) -> untyped
1420
- end
1421
1439
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: henitai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Otten
@@ -47,16 +47,22 @@ dependencies:
47
47
  name: simplecov
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - "~>"
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0.22'
53
+ - - "<"
54
+ - !ruby/object:Gem::Version
55
+ version: '2'
53
56
  type: :runtime
54
57
  prerelease: false
55
58
  version_requirements: !ruby/object:Gem::Requirement
56
59
  requirements:
57
- - - "~>"
60
+ - - ">="
58
61
  - !ruby/object:Gem::Version
59
62
  version: '0.22'
63
+ - - "<"
64
+ - !ruby/object:Gem::Version
65
+ version: '2'
60
66
  - !ruby/object:Gem::Dependency
61
67
  name: sqlite3
62
68
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +139,7 @@ files:
133
139
  - lib/henitai/configuration_validator/rules.rb
134
140
  - lib/henitai/configuration_validator/scalars.rb
135
141
  - lib/henitai/constant_path.rb
142
+ - lib/henitai/control_gate.rb
136
143
  - lib/henitai/control_run.rb
137
144
  - lib/henitai/coverage_bootstrapper.rb
138
145
  - lib/henitai/coverage_formatter.rb
@@ -146,15 +153,14 @@ files:
146
153
  - lib/henitai/execution_engine.rb
147
154
  - lib/henitai/execution_engine/env_scope.rb
148
155
  - lib/henitai/execution_engine/fork_server_scope.rb
156
+ - lib/henitai/execution_provenance.rb
149
157
  - lib/henitai/fidelity_check.rb
150
158
  - lib/henitai/flaky_detection_baseline.rb
151
- - lib/henitai/flaky_mutant_retrier.rb
152
159
  - lib/henitai/flaky_retry_decision.rb
153
160
  - lib/henitai/flaky_test_registry.rb
154
161
  - lib/henitai/fork_server.rb
155
162
  - lib/henitai/fork_server/client.rb
156
163
  - lib/henitai/fork_server/group_killer.rb
157
- - lib/henitai/fork_server/group_terminator.rb
158
164
  - lib/henitai/fork_server/launcher.rb
159
165
  - lib/henitai/fork_server/mutant_runner.rb
160
166
  - lib/henitai/fork_server/protocol.rb
@@ -165,6 +171,7 @@ files:
165
171
  - lib/henitai/fork_server/status.rb
166
172
  - lib/henitai/generated_artifacts.rb
167
173
  - lib/henitai/git_diff_analyzer.rb
174
+ - lib/henitai/history_checkpointer.rb
168
175
  - lib/henitai/incremental_filter.rb
169
176
  - lib/henitai/inherited_fd_registry.rb
170
177
  - lib/henitai/integration.rb
@@ -178,6 +185,7 @@ files:
178
185
  - lib/henitai/integration/loaded_features.rb
179
186
  - lib/henitai/integration/minitest.rb
180
187
  - lib/henitai/integration/minitest_autorun.rb
188
+ - lib/henitai/integration/minitest_fail_fast.rb
181
189
  - lib/henitai/integration/minitest_load_path.rb
182
190
  - lib/henitai/integration/minitest_outcome_reporter.rb
183
191
  - lib/henitai/integration/minitest_preload.rb
@@ -187,10 +195,13 @@ files:
187
195
  - lib/henitai/integration/mutant_run_support.rb
188
196
  - lib/henitai/integration/rails_environment_preloader.rb
189
197
  - lib/henitai/integration/rspec_child_runner.rb
198
+ - lib/henitai/integration/rspec_file_order.rb
190
199
  - lib/henitai/integration/rspec_preload.rb
191
200
  - lib/henitai/integration/rspec_process_runner.rb
192
201
  - lib/henitai/integration/rspec_test_selection.rb
193
202
  - lib/henitai/integration/scenario_log_support.rb
203
+ - lib/henitai/kill_history.rb
204
+ - lib/henitai/kill_history/store.rb
194
205
  - lib/henitai/minitest_coverage_hook.rb
195
206
  - lib/henitai/minitest_coverage_reporter.rb
196
207
  - lib/henitai/minitest_result_file.rb
@@ -205,7 +216,9 @@ files:
205
216
  - lib/henitai/mutant/replacement.rb
206
217
  - lib/henitai/mutant_generator.rb
207
218
  - lib/henitai/mutant_history_store.rb
219
+ - lib/henitai/mutant_history_store/database.rb
208
220
  - lib/henitai/mutant_history_store/sql.rb
221
+ - lib/henitai/mutant_history_store/subject_scans.rb
209
222
  - lib/henitai/mutant_history_store/verdict_cache.rb
210
223
  - lib/henitai/mutant_identity.rb
211
224
  - lib/henitai/mutant_verdict.rb
@@ -254,8 +267,10 @@ files:
254
267
  - lib/henitai/runner_dependencies.rb
255
268
  - lib/henitai/sampling_strategy.rb
256
269
  - lib/henitai/scenario_execution_result.rb
270
+ - lib/henitai/signal_deferral.rb
257
271
  - lib/henitai/signature_line.rb
258
272
  - lib/henitai/slot_scheduler.rb
273
+ - lib/henitai/slot_scheduler/control_slots.rb
259
274
  - lib/henitai/slot_scheduler/drain_verdict.rb
260
275
  - lib/henitai/slot_scheduler/draining.rb
261
276
  - lib/henitai/slot_scheduler/process_control.rb
@@ -295,7 +310,7 @@ metadata:
295
310
  changelog_uri: https://github.com/martinotten/henitai/blob/main/CHANGELOG.md
296
311
  documentation_uri: https://github.com/martinotten/henitai/blob/main/README.md
297
312
  homepage_uri: https://github.com/martinotten/henitai
298
- source_code_uri: https://github.com/martinotten/henitai/tree/v0.6.0
313
+ source_code_uri: https://github.com/martinotten/henitai/tree/v0.7.0
299
314
  rubygems_mfa_required: 'true'
300
315
  rdoc_options: []
301
316
  require_paths:
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Henitai
4
- # Re-runs a mutant whose kill is attributable only to known-flaky test files.
5
- #
6
- # Survivors are never retried: a retry could only turn a survivor into a
7
- # kill, which would inflate the score. A kill is retried only when every
8
- # killing test file is in the flaky set, up to `max_retries` times.
9
- class FlakyMutantRetrier
10
- attr_reader :retried_count
11
-
12
- def initialize(flaky_tests:, max_retries:)
13
- @decision = FlakyRetryDecision.new(flaky_tests: flaky_tests, max_retries: max_retries)
14
- @retried_count = 0
15
- @mutex = Mutex.new
16
- end
17
-
18
- def run(mutant:, integration:, test_files:, timeout:)
19
- result = integration.run_mutant(mutant: mutant, test_files: test_files, timeout: timeout)
20
- attempts = 0
21
- while @decision.retry?(**decision_input(result, attempts))
22
- attempts += 1
23
- result = integration.run_mutant(mutant: mutant, test_files: test_files, timeout: timeout)
24
- end
25
- @mutex.synchronize { @retried_count += 1 } if attempts.positive?
26
- result
27
- end
28
-
29
- private
30
-
31
- def decision_input(result, attempts)
32
- {
33
- status: status_of(result),
34
- killing_tests: result.respond_to?(:killing_tests) ? result.killing_tests : [],
35
- attempts: attempts
36
- }
37
- end
38
-
39
- def status_of(result)
40
- result.is_a?(Symbol) ? result : result.status
41
- end
42
- end
43
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Henitai
4
- module ForkServer
5
- # Stops a mutant process of the fork server and everything it started.
6
- #
7
- # The process is the server's child, not ours: waiting on it raises
8
- # ECHILD, so liveness is probed with signal 0 instead.
9
- class GroupTerminator
10
- GRACE_SECONDS = 2.0
11
- KILL_SECONDS = 1.0
12
- POLL_SECONDS = 0.02
13
-
14
- def initialize(killer: GroupKiller, clock: Process.method(:clock_gettime), pauser: Kernel.method(:sleep))
15
- @killer = killer
16
- @clock = clock
17
- @pauser = pauser
18
- end
19
-
20
- # @param leader [Boolean] false when the process already ended and only
21
- # members of its group are left
22
- def terminate(pid, leader: true)
23
- @killer.kill(pid, :SIGTERM, leader:)
24
- return if gone_within?(pid, GRACE_SECONDS, leader)
25
-
26
- @killer.kill(pid, :SIGKILL, leader:)
27
- gone_within?(pid, KILL_SECONDS, leader)
28
- end
29
-
30
- private
31
-
32
- def gone_within?(pid, seconds, leader)
33
- deadline = now + seconds
34
- while @killer.alive?(pid, leader:)
35
- return false if now >= deadline
36
-
37
- @pauser.call(POLL_SECONDS)
38
- end
39
- true
40
- end
41
-
42
- def now
43
- @clock.call(Process::CLOCK_MONOTONIC)
44
- end
45
- end
46
- end
47
- end