diff --git a/CHANGES.md b/CHANGES.md index 1518fa5..3e8c393 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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_ diff --git a/README.md b/README.md index 918b6b0..1dff3d5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/getcov b/getcov index 8bdacf5..dedcc36 100755 --- a/getcov +++ b/getcov @@ -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() { @@ -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() {