Class: ActiveMutator::Baseline

Inherits:
Object
  • Object
show all
Defined in:
lib/active_mutator/baseline.rb

Overview

Runs the host suite once, instrumented, in a subprocess. Produces and caches the CoverageMap. Invalidation is coarse: any digest change in app,lib,spec/**/*.rb triggers a full re-run.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, cache_dir: File.join(root, ".active_mutator")) ⇒ Baseline

Returns a new instance of Baseline.



10
11
12
13
14
# File 'lib/active_mutator/baseline.rb', line 10

def initialize(root:, cache_dir: File.join(root, ".active_mutator"))
  @root = root
  @cache_dir = cache_dir
  @out_path = File.join(cache_dir, "coverage.json")
end

Instance Attribute Details

#last_refreshObject (readonly)

Returns the value of attribute last_refresh.



16
17
18
# File 'lib/active_mutator/baseline.rb', line 16

def last_refresh
  @last_refresh
end

Instance Method Details

#coverage_map(force: false) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_mutator/baseline.rb', line 18

def coverage_map(force: false)
  digests = current_digests
  if !force && File.exist?(@out_path)
    map = CoverageMap.load(@out_path)
    if map.fresh?(digests)
      @last_refresh = :cached
      return map
    end
    if map.version == 2
      delta = BaselineDelta.compute(old_digests: stored_digests(map), new_digests: digests,
                                    coverage_map: map, root: @root)
      unless delta.full?
        run_partial!(delta)
        stamp_digests(digests)
        @last_refresh = :partial
        return CoverageMap.load(@out_path)
      end
    end
  end
  run_baseline!
  stamp_digests(digests)
  @last_refresh = :full
  CoverageMap.load(@out_path)
end