Class: ActiveMutator::BaselineDelta
- Inherits:
-
Object
- Object
- ActiveMutator::BaselineDelta
- Defined in:
- lib/active_mutator/baseline_delta.rb
Overview
Decides how to refresh a stale coverage cache: surgically (re-run only affected spec files / examples) or fully (the safe fallback). Rules per the v1.1 spec's delta table; anything ambiguous prefers full.
Defined Under Namespace
Classes: Delta
Constant Summary collapse
- FULL =
Delta.new(full: true, rerun_spec_files: [], rerun_example_ids: [], drop_example_ids: [], drop_source_files: [])
Class Method Summary collapse
Class Method Details
.compute(old_digests:, new_digests:, coverage_map:, root:) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/active_mutator/baseline_delta.rb', line 14 def self.compute(old_digests:, new_digests:, coverage_map:, root:) changed = (old_digests.keys | new_digests.keys) .reject { |k| old_digests[k] == new_digests[k] } return FULL if changed.any? { |k| full_trigger?(k) } rerun_spec_files = [] rerun_example_ids = [] drop_example_ids = [] drop_source_files = [] changed.each do |rel| added = !old_digests.key?(rel) deleted = !new_digests.key?(rel) if rel.start_with?("spec/") owned = coverage_map.examples_for_spec_file(rel) if deleted # A deleted spec file with no records is support-like: other spec # files may require it, and partial re-runs would explode. Full. return FULL if owned.empty? drop_example_ids.concat(owned) elsif !added && owned.empty? return FULL # pre-existing spec file owning no examples: support-like else rerun_spec_files << rel end else abs = File.join(root, rel) drop_source_files << abs if deleted rerun_example_ids.concat(coverage_map.examples_covering_file(abs)) unless added end end Delta.new(full: false, rerun_spec_files: rerun_spec_files.uniq.sort, rerun_example_ids: rerun_example_ids.uniq.sort, drop_example_ids: drop_example_ids.uniq.sort, drop_source_files: drop_source_files.uniq.sort) end |
.full_trigger?(rel) ⇒ Boolean
53 54 55 |
# File 'lib/active_mutator/baseline_delta.rb', line 53 def self.full_trigger?(rel) rel.start_with?("spec/support/") || !rel.end_with?(".rb") end |