Class: Henitai::SurvivorRerunStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/henitai/survivor_rerun_strategy.rb

Overview

Survivor-rerun fast path for Runner.

When --survivors-from is given, this collaborator loads the prior report and either:

* builds stub Mutants directly from +activation-recipes.json+ (the recipe
  fast path, bypassing source parsing and mutant generation), or
* filters a freshly generated mutant list down to the prior survivors.

In both cases it records #survivor_stats (matched/unmatched counts and the drift warning) for the Runner to attach to its Result.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(survivors_from:, config:, git_diff_analyzer:) ⇒ SurvivorRerunStrategy

Returns a new instance of SurvivorRerunStrategy.



18
19
20
21
22
23
# File 'lib/henitai/survivor_rerun_strategy.rb', line 18

def initialize(survivors_from:, config:, git_diff_analyzer:)
  @survivors_from = survivors_from
  @config = config
  @git_diff_analyzer = git_diff_analyzer
  @survivor_stats = nil
end

Instance Attribute Details

#survivor_statsObject (readonly)

Returns the value of attribute survivor_stats.



16
17
18
# File 'lib/henitai/survivor_rerun_strategy.rb', line 16

def survivor_stats
  @survivor_stats
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/henitai/survivor_rerun_strategy.rb', line 25

def active?
  !@survivors_from.nil?
end

#apply_selection(mutants) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/henitai/survivor_rerun_strategy.rb', line 40

def apply_selection(mutants)
  dirty_worktree_files = dirty_worktree_changed_files
  loaded   = load_survivor_report
  selector = SurvivorSelector.new(survivor_ids: loaded.survivor_ids)
  selected = selector.select(mutants)
  finalize_survivor_split(
    selector,
    selected,
    test_filter(
      loaded,
      dirty_source_files: dirty_source_files?(dirty_worktree_files, git_sha: loaded.git_sha)
    ).apply(selected)
  )
end

#try_recipe_runObject

Attempts to run survivors directly from pre-computed activation recipes, bypassing source parsing and mutant generation entirely. Returns the mutant array on success, or nil if recipes are unavailable.



32
33
34
35
36
37
38
# File 'lib/henitai/survivor_rerun_strategy.rb', line 32

def try_recipe_run
  dirty_worktree_files = dirty_worktree_changed_files
  loaded = load_survivor_report
  return nil unless recipe_fast_path_safe?(loaded, dirty_worktree_files)

  run_from_recipes(loaded, dirty_worktree_files)
end