lib/xcjobs/xcodebuild.rb in xcjobs-0.0.5 vs lib/xcjobs/xcodebuild.rb in xcjobs-0.0.6
- old
+ new
@@ -15,10 +15,11 @@
attr_accessor :sdk
attr_accessor :configuration
attr_accessor :signing_identity
attr_accessor :provisioning_profile
attr_accessor :build_dir
+ attr_accessor :coverage
attr_accessor :formatter
attr_reader :destinations
attr_reader :provisioning_profile_name
attr_reader :provisioning_profile_uuid
@@ -39,10 +40,25 @@
if @workspace
File.extname(@workspace).empty? ? "#{@workspace}.xcworkspace" : @workspace
end
end
+ def coverage=(coverage)
+ @coverage = coverage
+ if coverage
+ add_build_setting('GCC_INSTRUMENT_PROGRAM_FLOW_ARCS', 'YES')
+ add_build_setting('GCC_GENERATE_TEST_COVERAGE_FILES', 'YES')
+ else
+ @build_settings.delete('GCC_INSTRUMENT_PROGRAM_FLOW_ARCS')
+ @build_settings.delete('GCC_GENERATE_TEST_COVERAGE_FILES')
+ end
+ end
+
+ def coverage_enabled
+ @coverage
+ end
+
def before_action(&block)
@before_action = block
end
def after_action(&block)
@@ -65,10 +81,15 @@
private
def run(cmd)
@before_action.call if @before_action
+ if coverage_enabled
+ out, status = Open3.capture2(*(cmd + ['-showBuildSettings']))
+ configuration_temp_dir = out.lines.grep(/\bCONFIGURATION_TEMP_DIR\b/).first.split('=').last.strip
+ end
+
if @formatter
puts (cmd + ['|', @formatter]).join(" ")
else
puts cmd.join(" ")
end
@@ -81,10 +102,14 @@
output << line
end
status = wait_thrs.first.value
if status.success?
+ if coverage_enabled
+ XCJobs::Coverage.run_gcov(configuration_temp_dir)
+ end
+
@after_action.call(output, status) if @after_action
else
fail "xcodebuild failed (exited with status: #{status.exitstatus})"
end
end
@@ -96,9 +121,13 @@
output << line
end
status = wait_thr.value
if status.success?
+ if coverage_enabled
+ XCJobs::Coverage.run_gcov(configuration_temp_dir)
+ end
+
@after_action.call(output, status) if @after_action
else
fail "xcodebuild failed (exited with status: #{status.exitstatus})"
end
end