Skip to content
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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do absolute paths work or do paths have to be relative to SRCROOT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't have to be - the actual .xcodecoverageignore file has to be relative to SRCROOT, but you can put whatever you damn well please in the file itself.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also be able to use the * for file pattern matching, yes?
e.g. put _*.m to exclude mogenerator files

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should definitely be doable, but I haven't tested it.


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any interest in allowing for comments (lines starting with #?) in the ignore file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but for right now it just does nada if it can't find the given file, so #comments are effectively ignored.

Might be nice to add that in the future though.

#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