Class: Henitai::CoverageReportReader
- Inherits:
-
Object
- Object
- Henitai::CoverageReportReader
- Defined in:
- lib/henitai/coverage_report_reader.rb,
sig/henitai.rbs
Overview
Reads coverage report formats used by Henitai.
Constant Summary collapse
- DEFAULT_COVERAGE_REPORT_PATH =
"coverage/.resultset.json"- DEFAULT_PER_TEST_COVERAGE_REPORT_PATH =
"coverage/henitai_per_test.json"
Instance Method Summary collapse
- #coverage_lines_by_file(path = DEFAULT_COVERAGE_REPORT_PATH) ⇒ Hash[String, Array[Integer]]
-
#durations_by_test(path = DEFAULT_PER_TEST_COVERAGE_REPORT_PATH) ⇒ Hash[String, Float]
Wall-clock seconds per test file, from reports whose entries carry a "duration" field.
- #test_lines_by_file(path = DEFAULT_PER_TEST_COVERAGE_REPORT_PATH) ⇒ Hash[String, Hash[String, Array[Integer]]]
Instance Method Details
#coverage_lines_by_file(path = DEFAULT_COVERAGE_REPORT_PATH) ⇒ Hash[String, Array[Integer]]
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/henitai/coverage_report_reader.rb', line 11 def coverage_lines_by_file(path = DEFAULT_COVERAGE_REPORT_PATH) return {} unless File.exist?(path) coverage = Hash.new { |hash, key| hash[key] = [] } JSON.parse(File.read(path)).each_value do |result| result.fetch("coverage", {}).each do |file, file_coverage| coverage[normalize_path(file)].concat(covered_lines(file_coverage)) end end coverage.transform_values(&:uniq).transform_values(&:sort) end |
#durations_by_test(path = DEFAULT_PER_TEST_COVERAGE_REPORT_PATH) ⇒ Hash[String, Float]
Wall-clock seconds per test file, from reports whose entries carry a "duration" field. Legacy reports (plain source-map entries) yield {}.
32 33 34 35 36 37 38 |
# File 'lib/henitai/coverage_report_reader.rb', line 32 def durations_by_test(path = DEFAULT_PER_TEST_COVERAGE_REPORT_PATH) per_test_report(path).filter_map do |test_file, entry| next unless wrapped_entry?(entry) && entry.key?("duration") [test_file, entry.fetch("duration").to_f] end.to_h end |
#test_lines_by_file(path = DEFAULT_PER_TEST_COVERAGE_REPORT_PATH) ⇒ Hash[String, Hash[String, Array[Integer]]]
24 25 26 27 28 |
# File 'lib/henitai/coverage_report_reader.rb', line 24 def test_lines_by_file(path = DEFAULT_PER_TEST_COVERAGE_REPORT_PATH) per_test_report(path).transform_values do |entry| normalize_test_coverage(unwrap_coverage(entry)) end end |