Class: Henitai::CoverageFormatter
- Inherits:
-
Object
- Object
- Henitai::CoverageFormatter
- Defined in:
- lib/henitai/coverage_formatter.rb
Overview
Collects per-test coverage data for static filtering heuristics.
Constant Summary collapse
- REPORT_DIR_ENV =
"HENITAI_REPORTS_DIR"- REPORT_FILE_NAME =
"henitai_per_test.json"
Instance Method Summary collapse
- #dump_summary(_summary) ⇒ Object
- #example_finished(notification) ⇒ Object
-
#initialize(_output) ⇒ CoverageFormatter
constructor
A new instance of CoverageFormatter.
Constructor Details
#initialize(_output) ⇒ CoverageFormatter
Returns a new instance of CoverageFormatter.
13 14 15 16 17 18 19 |
# File 'lib/henitai/coverage_formatter.rb', line 13 def initialize(_output) @coverage_by_test = Hash.new do |hash, test_file| hash[test_file] = Hash.new { |nested, source_file| nested[source_file] = [] } end @previous_snapshot = {} @warned_missing_coverage = false end |
Instance Method Details
#dump_summary(_summary) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/henitai/coverage_formatter.rb', line 34 def dump_summary(_summary) return if @coverage_by_test.empty? FileUtils.mkdir_p(File.dirname(report_path)) File.write(report_path, JSON.pretty_generate(serializable_report)) end |
#example_finished(notification) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/henitai/coverage_formatter.rb', line 21 def example_finished(notification) snapshot = current_snapshot return warn_missing_coverage unless snapshot test_file = notification.example.[:file_path] new_lines(snapshot).each do |source_file, lines| @coverage_by_test[test_file][source_file].concat(lines) @coverage_by_test[test_file][source_file].uniq! @coverage_by_test[test_file][source_file].sort! end @previous_snapshot = snapshot end |