Module: Yolo::Tools::Ios::Coverage

Defined in:
lib/yolo/tools/ios/coverage.rb

Overview

Runs test coverage calcuations using gcovr and outputs reports

Author:

  • Alex Fish

Class Method Summary collapse

Class Method Details

.calculate(build_path = "", output_dir = "") ⇒ type

Runs gcovr and outputs reports to a defined location

Parameters:

  • build_path (defaults to: "")

    “” [String] The path to the build directory containing the .gcno compiler files

  • output_dir (defaults to: "")

    “” [String] Folder destination to output the report file too

Returns:

  • (type)
    description


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/yolo/tools/ios/coverage.rb', line 16

def self.calculate(build_path = "", output_dir = "")
  error_formatter = Yolo::Formatters::ErrorFormatter.new
  if build_path.length == 0 or output_dir.length == 0
    error_formatter.coverage_directory_error
    return
  end

  IO.popen("cd #{build_path} && gcovr --xml > #{output_dir}/coverage.xml") do |io|
    begin
      while line = io.readline
        puts line
      end
    rescue EOFError
      puts "Error while executing"
    end
  end
  $?.exitstatus if $?
end