-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathcoverage.sh
More file actions
executable file
·44 lines (33 loc) · 1.34 KB
/
coverage.sh
File metadata and controls
executable file
·44 lines (33 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
set -e
[[ -z "${SRCDIR}" ]] && SRCDIR="${PWD}"
OUTPUT_DIR="${SRCDIR}/coverage_report"
DATA_DIR="${SRCDIR}/bazel-testlogs/"
PROJECT=$(basename "${SRCDIR}")
# This is the target that will be run to generate coverage data. It can be overridden
# by consumer projects that want to run coverage on a different/combined target.
# Command-line arguments take precedence over ${COVERAGE_TARGET}.
if [[ $# -gt 0 ]]; then
COVERAGE_TARGETS=$*
elif [[ -n "${COVERAGE_TARGET}" ]]; then
COVERAGE_TARGETS=${COVERAGE_TARGET}
else
COVERAGE_TARGETS=//test/...
fi
echo "Starting gen_coverage.sh..."
echo " PWD=$(pwd)"
echo " OUTPUT_DIR=${OUTPUT_DIR}"
echo " DATA_DIR=${DATA_DIR}"
echo " TARGETS=${COVERAGE_TARGETS}"
echo "Generating coverage data..."
bazel coverage --config=ci ${COVERAGE_TARGETS} --test_output=errors
rm -rf ${OUTPUT_DIR}
mkdir -p ${OUTPUT_DIR}
BAZEL_OUTPUT_PATH=$(bazel info output_path 2>/dev/null)
COVERAGE_DATA="${BAZEL_OUTPUT_PATH}/_coverage/_coverage_report.dat"
echo "Generating report..."
genhtml --title ${PROJECT} --ignore-errors "source" --output-directory "${OUTPUT_DIR}" "${COVERAGE_DATA}"
tar -zcf ${PROJECT}_coverage.tar.gz ${OUTPUT_DIR}
mv ${PROJECT}_coverage.tar.gz ${OUTPUT_DIR}
echo "HTML coverage report is in ${OUTPUT_DIR}/index.html"
echo "All coverage report files are in ${OUTPUT_DIR}/${PROJECT}_coverage.tar.gz"