Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bazel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ then log back in and it should start working.
The latest coverage report for master is available
[here](https://s3.amazonaws.com/lyft-envoy/coverage/report-master/coverage.html).

It's also possible to specialize the coverage build to a single test target. This is useful
when doing things like exploring the coverage of a fuzzer over its corpus. This can be done with
the `COVERAGE_TARGET` and `VALIDATE_COVERAGE` environment variables, e.g.:

```
COVERAGE_TARGET=//test/common/common:base64_fuzz_test VALIDATE_COVERAGE=false test/run_envoy_bazel_coverage.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if we do coverage target for something like foo/bar:all or foo/bar/... ?
I'd assume the tests would run but the copy would still fail. Worth fixing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not right now, since the coverage story is going to be replaced soon enough with bazel coverage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Soon enough" you say.... so can I quote you on that?

```

# Cleaning the build and test artifacts

`bazel clean` will nuke all the build/test artifacts from the Bazel cache for
Expand Down
24 changes: 14 additions & 10 deletions test/run_envoy_bazel_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set -e
[[ -z "${BAZEL_COVERAGE}" ]] && BAZEL_COVERAGE=bazel
[[ -z "${GCOVR}" ]] && GCOVR=gcovr
[[ -z "${WORKSPACE}" ]] && WORKSPACE=envoy
[[ -z "${VALIDATE_COVERAGE}" ]] && VALIDATE_COVERAGE=true

# This is the target that will be run to generate coverage data. It can be overriden by consumer
# projects that want to run coverage on a different/combined target.
Expand Down Expand Up @@ -56,7 +57,7 @@ COVERAGE_SUMMARY="${COVERAGE_DIR}/coverage_summary.txt"
pushd "${GCOVR_DIR}"
for f in $(find -L bazel-out/ -name "*.gcno")
do
cp --parents "$f" bazel-out/k8-dbg/bin/test/coverage/coverage_tests.runfiles/"${WORKSPACE}"
cp --parents "$f" bazel-out/k8-dbg/bin/"${COVERAGE_TARGET/:/\/}".runfiles/"${WORKSPACE}"
done
popd

Expand All @@ -76,13 +77,16 @@ rm "${SRCDIR}"/test/coverage/BUILD

[[ -z "${ENVOY_COVERAGE_DIR}" ]] || rsync -av "${COVERAGE_DIR}"/ "${ENVOY_COVERAGE_DIR}"

COVERAGE_VALUE=$(grep -Po 'lines: \K(\d|\.)*' "${COVERAGE_SUMMARY}")
COVERAGE_THRESHOLD=98.0
COVERAGE_FAILED=$(echo "${COVERAGE_VALUE}<${COVERAGE_THRESHOLD}" | bc)
if test ${COVERAGE_FAILED} -eq 1; then
echo Code coverage ${COVERAGE_VALUE} is lower than limit of ${COVERAGE_THRESHOLD}
exit 1
else
echo Code coverage ${COVERAGE_VALUE} is good and higher than limit of ${COVERAGE_THRESHOLD}
if [ "$VALIDATE_COVERAGE" == "true" ]
then
COVERAGE_VALUE=$(grep -Po 'lines: \K(\d|\.)*' "${COVERAGE_SUMMARY}")
COVERAGE_THRESHOLD=98.0
COVERAGE_FAILED=$(echo "${COVERAGE_VALUE}<${COVERAGE_THRESHOLD}" | bc)
if test ${COVERAGE_FAILED} -eq 1; then
echo Code coverage ${COVERAGE_VALUE} is lower than limit of ${COVERAGE_THRESHOLD}
exit 1
else
echo Code coverage ${COVERAGE_VALUE} is good and higher than limit of ${COVERAGE_THRESHOLD}
fi
echo "HTML coverage report is in ${COVERAGE_DIR}/coverage.html"
fi
echo "HTML coverage report is in ${COVERAGE_DIR}/coverage.html"