Skip to content

Commit d572a29

Browse files
committed
getcov: Lean toward Google shell style guide
1 parent 8d53427 commit d572a29

File tree

1 file changed

+78
-79
lines changed

1 file changed

+78
-79
lines changed

getcov

Lines changed: 78 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,109 +2,108 @@
22
# XcodeCoverage by Jon Reid, http://qualitycoding/about/
33
# Copyright 2014 Jonathan M. Reid. See LICENSE.txt
44

5-
usage()
6-
{
7-
echo "usage: getcov [[[-o output_directory] [-i info_file] [-v]] | [-h]]"
5+
usage() {
6+
echo "usage: getcov [[[-o output_directory] [-i info_file] [-v]] | [-h]]"
87
}
98

10-
remove_old_report()
11-
{
12-
if [ "$verbose" = "1" ]; then
13-
echo "XcodeCoverage: Removing old report"
14-
fi
9+
remove_old_report() {
10+
if [ "$verbose" = "1" ]; then
11+
echo "XcodeCoverage: Removing old report"
12+
fi
1513

16-
pushd "${OUT_DIR}"
17-
if [ -e lcov ]; then
18-
rm -r lcov
19-
fi
20-
popd
14+
pushd "${OUT_DIR}"
15+
if [ -e lcov ]; then
16+
rm -r lcov
17+
fi
18+
popd
2119
}
2220

23-
enter_lcov_dir()
24-
{
25-
cd "${OUT_DIR}"
26-
mkdir lcov
27-
cd lcov
21+
enter_lcov_dir() {
22+
cd "${OUT_DIR}"
23+
mkdir lcov
24+
cd lcov
2825
}
2926

30-
gather_coverage()
31-
{
32-
if [ "$verbose" = "1" ]; then
33-
echo "XcodeCoverage: Gathering coverage"
34-
fi
27+
gather_coverage() {
28+
if [ "$verbose" = "1" ]; then
29+
echo "XcodeCoverage: Gathering coverage"
30+
fi
3531

36-
LCOV --capture --derive-func-data -b "${SRCROOT}" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
32+
LCOV --capture --derive-func-data -b "${SRCROOT}" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
3733
}
3834

39-
exclude_data()
40-
{
41-
LCOV --remove "${LCOV_INFO}" "Developer/SDKs/*" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
42-
LCOV --remove "${LCOV_INFO}" "main.m" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
43-
# Remove other patterns here...
44-
LCOV --remove "${LCOV_INFO}" "include/*" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
45-
LCOV --remove "${LCOV_INFO}" "Classes/External/*" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
35+
exclude_data() {
36+
LCOV --remove "${LCOV_INFO}" "Developer/SDKs/*" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
37+
LCOV --remove "${LCOV_INFO}" "main.m" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
38+
# Remove other patterns here...
39+
LCOV --remove "${LCOV_INFO}" "include/*" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
40+
LCOV --remove "${LCOV_INFO}" "Classes/External/*" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
4641
}
4742

48-
generate_cobertura_xml()
49-
{
50-
python "${DIR}/lcov_cobertura.py" ${LCOV_INFO} --base-dir "${SRCROOT}" --output "coverage.xml"
43+
generate_cobertura_xml() {
44+
python "${scripts}/lcov_cobertura.py" ${LCOV_INFO} --base-dir "${SRCROOT}" --output "coverage.xml"
5145
}
5246

53-
generate_report()
54-
{
55-
if [ "$verbose" = "1" ]; then
56-
echo "XcodeCoverage: Generating report"
57-
fi
47+
generate_report() {
48+
if [ "$verbose" = "1" ]; then
49+
echo "XcodeCoverage: Generating report"
50+
fi
5851

59-
"${LCOV_PATH}/genhtml" --output-directory . "${LCOV_INFO}"
52+
"${LCOV_PATH}/genhtml" --output-directory . "${LCOV_INFO}"
6053

61-
if [ "$show_report" = "1" ]; then
62-
if [ "$verbose" = "1" ]; then
63-
echo "XcodeCoverage: Opening report"
64-
fi
65-
open index.html
54+
if [ "$show_report" = "1" ]; then
55+
if [ "$verbose" = "1" ]; then
56+
echo "XcodeCoverage: Opening report"
6657
fi
58+
open index.html
59+
fi
6760
}
6861

69-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
70-
source ${DIR}/envcov.sh
62+
scripts="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
63+
source "${scripts}/envcov.sh"
7164

7265
OUT_DIR="${BUILT_PRODUCTS_DIR}"
7366
while [ "$1" != "" ]; do
74-
case $1 in
75-
-o ) shift
76-
OUT_DIR=$1
77-
echo "OUT_DIR = ${OUT_DIR}"
78-
;;
79-
-i ) shift
80-
LCOV_INFO=$1
81-
echo "LCOV_INFO = ${LCOV_INFO}"
82-
;;
83-
-v ) verbose=1
84-
echo "Verbose"
85-
;;
86-
-s | --show ) show_report=1
87-
echo "Show Report"
88-
;;
89-
-h | --help ) usage
90-
echo "Show Help"
91-
exit
92-
;;
93-
* ) usage
94-
exit 1
95-
esac
96-
shift
67+
case $1 in
68+
-o)
69+
shift
70+
OUT_DIR=$1
71+
echo "OUT_DIR = ${OUT_DIR}"
72+
;;
73+
-i)
74+
shift
75+
LCOV_INFO=$1
76+
echo "LCOV_INFO = ${LCOV_INFO}"
77+
;;
78+
-v)
79+
verbose=1
80+
echo "Verbose"
81+
;;
82+
-s | --show )
83+
show_report=1
84+
echo "Show Report"
85+
;;
86+
-h | --help )
87+
usage
88+
echo "Show Help"
89+
exit
90+
;;
91+
*)
92+
usage
93+
exit 1
94+
esac
95+
shift
9796
done
9897

99-
if [ "$verbose" = "1" ]; then
100-
echo "XcodeCoverage: Environment"
101-
echo "LCOV_INFO : ${LCOV_INFO}"
102-
echo "DIR : ${DIR}"
103-
echo "BUILD_DIR : ${BUILT_PRODUCTS_DIR}"
104-
echo "SRCROOT : ${SRCROOT}"
105-
echo "OBJ_DIR : ${OBJ_DIR}"
106-
echo "LCOV_PATH : ${LCOV_PATH}"
107-
echo "OUT_DIR : ${OUT_DIR}"
98+
if [ "$verbose" = "1" ]; then
99+
echo "XcodeCoverage: Environment"
100+
echo "scripts : ${scripts}"
101+
echo "LCOV_INFO : ${LCOV_INFO}"
102+
echo "BUILD_DIR : ${BUILT_PRODUCTS_DIR}"
103+
echo "SRCROOT : ${SRCROOT}"
104+
echo "OBJ_DIR : ${OBJ_DIR}"
105+
echo "LCOV_PATH : ${LCOV_PATH}"
106+
echo "OUT_DIR : ${OUT_DIR}"
108107
fi
109108

110109
remove_old_report

0 commit comments

Comments
 (0)