Method: Slather::CoverageFile#gcov_data

Defined in:
lib/slather/coverage_file.rb

#gcov_dataObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/slather/coverage_file.rb', line 44

def gcov_data
  @gcov_data ||= begin
    gcov_output = `gcov "#{source_file_pathname}" --object-directory "#{gcno_file_pathname.parent}" --branch-probabilities --branch-counts`
    # Sometimes gcov makes gcov files for Cocoa Touch classes, like NSRange. Ignore and delete later.
    gcov_files_created = gcov_output.scan(/creating '(.+\..+\.gcov)'/)

    gcov_file_name = "./#{source_file_pathname.basename}.gcov"
    if File.exists?(gcov_file_name)
      gcov_data = File.new(gcov_file_name).read
    else
      gcov_data = ""
    end

    gcov_files_created.each { |file| FileUtils.rm_f(file) }
    gcov_data
  end
end