Skip to content

Update ignore mechanism to use a file rather than altering the script #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Dec 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 1.3.0
-------------
_12 August 2015_

* Update to look for an `.xcodecoverageignore` file in `SRCROOT` instead of needing to manually update the `getcov` script to specify which files to ignore - a specification which would get overwritten if you were using CocoaPods and ran `pod update`. _Thanks to: Ellen Shapiro_

Version 1.2.2
-------------
_22 Mar 2015_
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,22 @@ If you make changes to your production code, you should clear out all build arti
* Set script to `source XcodeCoverage/run_code_coverage_post.sh` for standard installation. For CocoaPods installation, use `source Pods/XcodeCoverage/run_code_coverage_post.sh`


Modification
============
Excluding Files From Coverage
=============================

If you are using the standard installation, you can modify `exclude_data()` in `getcov` to specify which files to exclude, such as third-party libraries.
If there are files or folders which you want to have the coverage generator ignore (for instance, third-party libraries not installed via CocoaPods or machine-generated files), add an `.xcodecoverageignore` file to your `SRCROOT`.

Each line should be a different file or group of files which should be excluded for code coverage purposes. You can use `SRCROOT` relative paths as well as the `*` character to indicate everything below a certain directory should be excluded.

Example contents of an `.xcodecoverageignore` file:

```
${SRCROOT}/TestedProject/Machine Files/*
${SRCROOT}/TestedProject/Third-Party/SingleFile.m
${SRCROOT}/TestedProject/Categories/UIImage+IgnoreMe.{h,m}
```

Note: If you were using a version of XcodeCoverage prior to 1.3, you will need to move the list of files and folders you wish to ignore to the `.xcodecoverageignore` file. The current setup will prevent your customized list from being overwritten when there is an update to this project.


Credits
Expand Down
9 changes: 8 additions & 1 deletion getcov
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ report_values() {
echo "SRCROOT : ${SRCROOT}"
echo "OBJ_DIR : ${OBJ_DIR}"
echo "LCOV_PATH : ${LCOV_PATH}"
echo "IGNORED : ${XCODECOV_IGNORED_PATHS}"
}

remove_old_report() {
Expand Down Expand Up @@ -112,7 +113,13 @@ exclude_data() {

LCOV --remove "${LCOV_INFO}" "Developer/SDKs/*" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
LCOV --remove "${LCOV_INFO}" "main.m" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
# Remove other patterns here...

#Remove anything the .xcodecoverageignore file has specified should be ignored.
(cat "${SRCROOT}/.xcodecoverageignore"; echo) | while read IGNORE_THIS; do
#use eval to expand any of the variables and then pass them to the shell - this allows
#use of wildcards in the variables.
eval LCOV --remove "${LCOV_INFO}" "${IGNORE_THIS}" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
done
}

generate_cobertura_xml() {
Expand Down