Skip to content

Instantly share code, notes, and snippets.

@dlongmuir
Last active December 23, 2015 23:59
Show Gist options
  • Save dlongmuir/6714184 to your computer and use it in GitHub Desktop.
Save dlongmuir/6714184 to your computer and use it in GitHub Desktop.
Get code coverage on Xcode5. Hacky but pragmatic.
#! /usr/bin/env ruby
workspace_name = %x[ls].split.find{ |file_name| file_name.include? 'xcworkspace' }
project_name = workspace_name.split('.')[0]
pwd = %x[pwd].strip
settings = %x[xcodebuild -workspace #{workspace_name} -showBuildSettings -scheme #{project_name}]
%x[xcodebuild -workspace #{workspace_name} test -scheme #{project_name} -destination OS=6.1,name=iPad -configuration Debug]
if $? == 0
full_build_root = settings[/BUILD_ROOT = (.*)/].split[2]
full_build_root[/(.*)\/Build\/Products/]
root_for_gcovr = $1
%x[cp -R #{project_name} #{root_for_gcovr}]
%x[cd \"#{root_for_gcovr}\"; gcovr -r #{pwd} --exclude '.*Tests.*' --exclude '.*libs.*' --exclude '.*main.m' --exclude '.*ExternalFrameworks.*' --exclude '.*Spec.*' --html --html-details -o coverage.html]
%x[open \"#{root_for_gcovr}/coverage.html\"]
end
#! /bin/bash
# poor replacement for autotest but works
kicker -c -e ./coverage.rb .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment