Class: Henitai::SurvivorTestFilter
- Inherits:
-
Object
- Object
- Henitai::SurvivorTestFilter
- Defined in:
- lib/henitai/survivor_test_filter.rb
Overview
Splits a matched survivor set into stable and pending subsets by consulting a git diff against the covering tests from the prior report.
A survivor is stable (can skip re-execution) when:
- it has covering test data in the prior report, AND
- none of those test files appear in the diff between the prior run's
git_sha and the current HEAD.
A survivor is pending (must execute) when:
- git_sha is nil (no anchor → conservative), OR
- its coveredBy data is absent or empty, OR
- at least one covering test file changed.
On any git error the filter conservatively treats all survivors as pending.
Instance Method Summary collapse
-
#apply(mutants) ⇒ Hash<Symbol, Array<Mutant>>
{ stable: […], pending: […] }.
-
#initialize(coverage_map:, git_sha:, dirty_source_files: false, worktree_changed_files: [], diff_analyzer: GitDiffAnalyzer.new) ⇒ SurvivorTestFilter
constructor
A new instance of SurvivorTestFilter.
Constructor Details
#initialize(coverage_map:, git_sha:, dirty_source_files: false, worktree_changed_files: [], diff_analyzer: GitDiffAnalyzer.new) ⇒ SurvivorTestFilter
Returns a new instance of SurvivorTestFilter.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/henitai/survivor_test_filter.rb', line 25 def initialize( coverage_map:, git_sha:, dirty_source_files: false, worktree_changed_files: [], diff_analyzer: GitDiffAnalyzer.new ) @coverage_map = coverage_map @git_sha = git_sha @dirty_source_files = dirty_source_files @worktree_changed_files = Array(worktree_changed_files) @diff_analyzer = diff_analyzer end |
Instance Method Details
#apply(mutants) ⇒ Hash<Symbol, Array<Mutant>>
Returns { stable: […], pending: […] }.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/henitai/survivor_test_filter.rb', line 41 def apply(mutants) return { stable: [], pending: mutants } if @dirty_source_files return { stable: [], pending: mutants } if @git_sha.nil? changed = changed_test_files return { stable: [], pending: mutants } if changed.nil? mutants.each_with_object({ stable: [], pending: [] }) do |mutant, result| bucket = stable_survivor?(mutant, changed) ? :stable : :pending result[bucket] << mutant end end |