Class: Datadog::CI::TestImpactAnalysis::Coverage::Files

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/test_impact_analysis/coverage/files.rb

Overview

Keeps native coverage and custom impacted files together and normalizes them as one set.

Constant Summary collapse

EMPTY_FILES =
[].freeze

Instance Method Summary collapse

Constructor Details

#initialize(coverage, custom_impacted_files = EMPTY_FILES) ⇒ Files

Returns a new instance of Files.



16
17
18
19
20
# File 'lib/datadog/ci/test_impact_analysis/coverage/files.rb', line 16

def initialize(coverage, custom_impacted_files = EMPTY_FILES)
  @coverage = coverage
  @custom_impacted_files = custom_impacted_files
  @normalized_files = nil
end

Instance Method Details

#eachObject



22
23
24
# File 'lib/datadog/ci/test_impact_analysis/coverage/files.rb', line 22

def each
  normalized_files.each { |file| yield file }
end

#inspect_coverageObject

Returns a readable view while preserving the paths supplied by native coverage and the custom impacted-files API. Serialized files are normalized through #each.



33
34
35
36
37
38
39
# File 'lib/datadog/ci/test_impact_analysis/coverage/files.rb', line 33

def inspect_coverage
  coverage = @coverage.dup
  @custom_impacted_files.each do |file|
    coverage[file] = true
  end
  coverage
end

#sizeObject



26
27
28
# File 'lib/datadog/ci/test_impact_analysis/coverage/files.rb', line 26

def size
  normalized_files.size
end