Skip to content

Commit 0d2afd7

Browse files
Merge pull request #8 from designatednerd/master
Add ability to ignore everything listed in a specified file.
2 parents 317ae0e + 42ec5aa commit 0d2afd7

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 1.3.0
2+
-------------
3+
_12 August 2015_
4+
5+
* 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_
6+
17
Version 1.2.2
28
-------------
39
_22 Mar 2015_

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,22 @@ If you make changes to your production code, you should clear out all build arti
8181
* 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`
8282

8383

84-
Modification
85-
============
84+
Excluding Files From Coverage
85+
=============================
8686

87-
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.
87+
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`.
88+
89+
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.
90+
91+
Example contents of an `.xcodecoverageignore` file:
92+
93+
```
94+
${SRCROOT}/TestedProject/Machine Files/*
95+
${SRCROOT}/TestedProject/Third-Party/SingleFile.m
96+
${SRCROOT}/TestedProject/Categories/UIImage+IgnoreMe.{h,m}
97+
```
98+
99+
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.
88100

89101

90102
Credits

getcov

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ report_values() {
7777
echo "SRCROOT : ${SRCROOT}"
7878
echo "OBJ_DIR : ${OBJ_DIR}"
7979
echo "LCOV_PATH : ${LCOV_PATH}"
80+
echo "IGNORED : ${XCODECOV_IGNORED_PATHS}"
8081
}
8182

8283
remove_old_report() {
@@ -112,7 +113,13 @@ exclude_data() {
112113

113114
LCOV --remove "${LCOV_INFO}" "Developer/SDKs/*" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
114115
LCOV --remove "${LCOV_INFO}" "main.m" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
115-
# Remove other patterns here...
116+
117+
#Remove anything the .xcodecoverageignore file has specified should be ignored.
118+
(cat "${SRCROOT}/.xcodecoverageignore"; echo) | while read IGNORE_THIS; do
119+
#use eval to expand any of the variables and then pass them to the shell - this allows
120+
#use of wildcards in the variables.
121+
eval LCOV --remove "${LCOV_INFO}" "${IGNORE_THIS}" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
122+
done
116123
}
117124

118125
generate_cobertura_xml() {

0 commit comments

Comments
 (0)