Class: Henitai::CoverageBootstrapper

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

Overview

Ensures coverage data exists before the mutation pipeline starts.

Instance Method Summary collapse

Constructor Details

#initialize(static_filter: StaticFilter.new) ⇒ CoverageBootstrapper

Returns a new instance of CoverageBootstrapper.



6
7
8
# File 'lib/henitai/coverage_bootstrapper.rb', line 6

def initialize(static_filter: StaticFilter.new)
  @static_filter = static_filter
end

Instance Method Details

#ensure!(source_files:, config:, integration:, test_files: nil) ⇒ Object

Runs the test suite to collect coverage, unless a fresh report already exists.

Parameters:

  • source_files (Array<String>)

    lib files whose coverage must be present

  • config (Configuration)
  • integration (Integration::Base)
  • test_files (Array<String>, nil) (defaults to: nil)

    test files to run; defaults to all files reported by the integration when nil

Raises:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/henitai/coverage_bootstrapper.rb', line 18

def ensure!(source_files:, config:, integration:, test_files: nil)
  return if source_files.empty?

  # Skip the bootstrap only when the coverage artifacts are both newer than
  # all watched files and actually cover the configured sources. A fresh
  # but irrelevant report (e.g. from a different working directory) must
  # still trigger a re-bootstrap rather than silently proceeding with no
  # usable coverage.
  unless coverage_ready?(source_files, config, integration, test_files)
    bootstrap_coverage(integration, config, test_files)
  end

  return if coverage_available?(source_files, config, test_files)

  raise CoverageError,
        "Coverage data is unavailable for the configured source files"
end