Class: Henitai::RunnerDependencies

Inherits:
Object
  • Object
show all
Defined in:
lib/henitai/runner_dependencies.rb,
sig/henitai.rbs

Overview

The collaborators Runner drives, built on first use.

Extracted so each one can be asserted on directly — several are chosen by configuration (the integration adapter, the operator set, which progress reporters are composed) and that choice had no test seam while it lived behind private readers on Runner.

Memoization is not an optimisation here, it is a correctness requirement for #per_test_coverage and #history_store: the incremental filter proves survivor reuse against the same live coverage map the history store records its intersection set from. Two instances would be two snapshots.

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ RunnerDependencies

Returns a new instance of RunnerDependencies.

Parameters:

  • config: (Object)


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

def initialize(config:)
  @config = config
end

Instance Method Details

#coverage_bootstrapperCoverageBootstrapper



25
# File 'lib/henitai/runner_dependencies.rb', line 25

def coverage_bootstrapper = @coverage_bootstrapper ||= CoverageBootstrapper.new

#execution_engineObject

Returns:

  • (Object)


24
# File 'lib/henitai/runner_dependencies.rb', line 24

def execution_engine = @execution_engine ||= ExecutionEngine.new

#git_diff_analyzerObject

Returns:

  • (Object)


21
# File 'lib/henitai/runner_dependencies.rb', line 21

def git_diff_analyzer = @git_diff_analyzer ||= GitDiffAnalyzer.new

#history_storeObject

Returns:

  • (Object)


39
40
41
42
43
44
# File 'lib/henitai/runner_dependencies.rb', line 39

def history_store
  @history_store ||= MutantHistoryStore.new(
    path: File.join(@config.reports_dir, Henitai::HISTORY_STORE_FILENAME),
    per_test_coverage: per_test_coverage
  )
end

#integrationObject

Returns:

  • (Object)


27
28
29
# File 'lib/henitai/runner_dependencies.rb', line 27

def integration
  @integration ||= Integration.for(@config.integration).new
end

#mutant_generatorObject

Returns:

  • (Object)


22
# File 'lib/henitai/runner_dependencies.rb', line 22

def mutant_generator = @mutant_generator ||= MutantGenerator.new

#operatorsArray[Operator]

Returns:



31
32
33
# File 'lib/henitai/runner_dependencies.rb', line 31

def operators
  @operators ||= Operator.for_set(@config.operators)
end

#per_test_coveragePerTestCoverage

Returns:



35
36
37
# File 'lib/henitai/runner_dependencies.rb', line 35

def per_test_coverage
  @per_test_coverage ||= PerTestCoverage.new(reports_dir: @config.reports_dir)
end

#progress_reporter(full_run:) ⇒ Object

Fans progress out to the terminal reporter (when enabled) and the checkpoint writer (when enabled and a file report is configured), so a long run persists partial results incrementally.

Deliberately not memoized: full_run? is a property of the invocation, not of the dependency set, and a cached reporter would silently keep the first answer.

Parameters:

  • full_run: (Boolean)

Returns:

  • (Object)


53
54
55
# File 'lib/henitai/runner_dependencies.rb', line 53

def progress_reporter(full_run:)
  CompositeProgressReporter.for(config: @config, source_provider: source_provider, full_run: full_run)
end

#source_provider^(String) -> String

Reads each source file once and caches it per path, so Result consumes source content while performing no disk IO of its own. Unreadable files (recipe stubs with synthetic locations, say) answer "" rather than aborting the run.

Not memoized: each call gets its own cache, scoped to one reporter's lifetime rather than shared across the process.

Returns:

  • (^(String) -> String)


64
65
66
67
68
69
70
71
72
73
# File 'lib/henitai/runner_dependencies.rb', line 64

def source_provider
  cache = {} # : Hash[String, String]
  lambda do |file|
    cache[file] ||= begin
      File.read(file)
    rescue StandardError
      ""
    end
  end
end

#static_filterObject

Returns:

  • (Object)


23
# File 'lib/henitai/runner_dependencies.rb', line 23

def static_filter = @static_filter ||= StaticFilter.new

#subject_resolverObject

Returns:

  • (Object)


20
# File 'lib/henitai/runner_dependencies.rb', line 20

def subject_resolver = @subject_resolver ||= SubjectResolver.new