Class: GitlabQuality::TestTooling::CodeCoverage::TestMap
- Inherits:
-
Object
- Object
- GitlabQuality::TestTooling::CodeCoverage::TestMap
- Defined in:
- lib/gitlab_quality/test_tooling/code_coverage/test_map.rb
Constant Summary collapse
- SEPARATOR =
'/'- MARKER =
1
Instance Method Summary collapse
-
#initialize(compact_map) ⇒ TestMap
constructor
A new instance of TestMap.
-
#source_to_tests ⇒ Hash<String, Array<String>>
Source files mapped to all test files testing them.
-
#test_to_sources ⇒ Hash<String, Array<String>>
Test files mapped to all source files tested by them.
Constructor Details
#initialize(compact_map) ⇒ TestMap
Returns a new instance of TestMap.
38 39 40 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/test_map.rb', line 38 def initialize(compact_map) @compact_map = compact_map end |
Instance Method Details
#source_to_tests ⇒ Hash<String, Array<String>>
Returns Source files mapped to all test files testing them.
52 53 54 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/test_map.rb', line 52 def source_to_tests @source_to_tests ||= @compact_map.transform_values { |tree| traverse(tree).to_a.uniq } end |
#test_to_sources ⇒ Hash<String, Array<String>>
Returns Test files mapped to all source files tested by them.
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/test_map.rb', line 66 def test_to_sources @test_to_sources ||= begin test_to_sources = Hash.new { |hash, key| hash[key] = [] } @compact_map.each do |source_file, tree| traverse(tree).to_a.each do |test_file| test_to_sources[test_file] << source_file end end test_to_sources end end |