Skip to content

Commit fa1393d

Browse files
committed
getcov: Add -x arg for generating Cobertura XML. Lean toward style guide.
1 parent bcb2d66 commit fa1393d

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![XcodeCoverage](http://qualitycoding.org/jrwp/wp-content/uploads/2014/03/XcodeCoverage.png)
22

3-
These scripts provide a simple way to generate HTML reports of the code coverage of your Xcode project.
3+
These scripts provide a simple way to generate HTML reports of the code coverage of your Xcode project.
44

55

66
Xcode Project Setup

getcov

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,29 @@
33
# Copyright 2014 Jonathan M. Reid. See LICENSE.txt
44

55
usage() {
6-
echo "usage: getcov [[[-o output_directory] [-i info_file] [-v]] | [-h]]"
6+
echo "usage: getcov [[-s] [-x] [-o output_dir] [-i info_file] [-v]] | [-h]]"
77
}
88

99
main() {
1010
scripts="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1111
source "${scripts}/envcov.sh"
1212

1313
LCOV_INFO=Coverage.info
14-
OUT_DIR="${BUILT_PRODUCTS_DIR}"
14+
output_dir="${BUILT_PRODUCTS_DIR}"
1515
while [ "$1" != "" ]; do
1616
case $1 in
17+
-s|--show)
18+
show_html=1
19+
echo "Show HTML Report"
20+
;;
21+
-x|--xml)
22+
generate_xml=1
23+
echo "Generate Cobertura XML"
24+
;;
1725
-o)
1826
shift
19-
OUT_DIR=$1
20-
echo "OUT_DIR = ${OUT_DIR}"
27+
output_dir=$1
28+
echo "output_dir = ${output_dir}"
2129
;;
2230
-i)
2331
shift
@@ -28,10 +36,6 @@ main() {
2836
verbose=1
2937
echo "Verbose"
3038
;;
31-
-s|--show)
32-
show_report=1
33-
echo "Show Report"
34-
;;
3539
-h|--help)
3640
usage
3741
echo "Show Help"
@@ -52,39 +56,43 @@ main() {
5256
enter_lcov_dir
5357
gather_coverage
5458
exclude_data
55-
generate_cobertura_xml
59+
60+
if [ "$generate_xml" = "1" ]; then
61+
generate_cobertura_xml
62+
fi
63+
5664
generate_html_report
5765

58-
if [ "$show_report" = "1" ]; then
66+
if [ "$show_html" = "1" ]; then
5967
show_html_report
6068
fi
6169
}
6270

6371
report_values() {
6472
echo "XcodeCoverage: Environment"
65-
echo "scripts : ${scripts}"
66-
echo "LCOV_INFO : ${LCOV_INFO}"
67-
echo "BUILD_DIR : ${BUILT_PRODUCTS_DIR}"
68-
echo "SRCROOT : ${SRCROOT}"
69-
echo "OBJ_DIR : ${OBJ_DIR}"
70-
echo "LCOV_PATH : ${LCOV_PATH}"
71-
echo "OUT_DIR : ${OUT_DIR}"
73+
echo "scripts : ${scripts}"
74+
echo "output_dir : ${output_dir}"
75+
echo "LCOV_INFO : ${LCOV_INFO}"
76+
echo "BUILD_DIR : ${BUILT_PRODUCTS_DIR}"
77+
echo "SRCROOT : ${SRCROOT}"
78+
echo "OBJ_DIR : ${OBJ_DIR}"
79+
echo "LCOV_PATH : ${LCOV_PATH}"
7280
}
7381

7482
remove_old_report() {
7583
if [ "$verbose" = "1" ]; then
7684
echo "XcodeCoverage: Removing old report"
7785
fi
7886

79-
pushd "${OUT_DIR}"
87+
pushd "${output_dir}"
8088
if [ -e lcov ]; then
8189
rm -r lcov
8290
fi
8391
popd
8492
}
8593

8694
enter_lcov_dir() {
87-
cd "${OUT_DIR}"
95+
cd "${output_dir}"
8896
mkdir lcov
8997
cd lcov
9098
}

0 commit comments

Comments
 (0)