Skip to content

Commit

Permalink
Add "--input-format" parameter in "slather setup" too, so it can enab…
Browse files Browse the repository at this point in the history
…le CLANG_ENABLE_CODE_COVERAGE instead of GCC_GENERATE_TEST_COVERAGE_FILES

+ Print explicit error when missing parameter for "slather setup"

TODO: improve Xcodeproj gem so my new Xcodeproj::XCScheme implementation also allows to set codeCoverageEnabled = YES in every xcscheme
  • Loading branch information
AliSoftware committed Sep 21, 2015
1 parent 4d0199a commit d079453
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 8 additions & 1 deletion bin/slather
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,15 @@ Clamp do

parameter "[xcodeproj]", "Path to the xcodeproj", :attribute_name => :xcodeproj_path

option ["--input-format"], "INPUT_FORMAT", "Input format (gcov, profdata)"

def execute
project = Slather::Project.open(xcodeproj_path)
xcodeproj_path_to_open = xcodeproj_path || Slather::Project.yml["xcodeproj"]
unless xcodeproj_path_to_open
raise StandardError, "Must provide an xcodeproj through .slather.yml"
end
project = Slather::Project.open(xcodeproj_path_to_open)
project.input_format = input_format
project.setup_for_coverage
project.save
end
Expand Down
13 changes: 10 additions & 3 deletions lib/slather/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
module Xcodeproj
class Project

def slather_setup_for_coverage
def slather_setup_for_coverage(input_format = "gcov")
build_configurations.each do |build_configuration|
build_configuration.build_settings["GCC_INSTRUMENT_PROGRAM_FLOW_ARCS"] = "YES"
build_configuration.build_settings["GCC_GENERATE_TEST_COVERAGE_FILES"] = "YES"
if input_format == "profdata"
build_configuration.build_settings["CLANG_ENABLE_CODE_COVERAGE"] = "YES"
# @todo also activate codeCoverageEnabled = "YES" in every xcscheme's TestAction
else
build_configuration.build_settings["GCC_GENERATE_TEST_COVERAGE_FILES"] = "YES"
end
end
end

Expand All @@ -22,7 +27,9 @@ class Project < Xcodeproj::Project

attr_accessor :build_directory, :ignore_list, :ci_service, :coverage_service, :coverage_access_token, :source_directory, :output_directory, :xcodeproj, :show_html, :input_format, :scheme

alias_method :setup_for_coverage, :slather_setup_for_coverage
def setup_for_coverage
slather_setup_for_coverage(self.input_format)
end

def self.open(xcodeproj)
proj = super
Expand Down

0 comments on commit d079453

Please sign in to comment.