0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 00:17:37 +01:00
mongodb/evergreen/bazel_coverage.sh
Steve McClure e5b772bc36 SERVER-94497: Support code coverage from bazel test targets (#27116)
GitOrigin-RevId: fc4d8d3898d3afbcaa20e7b596e4ed7da7d464b2
2024-09-19 00:53:58 +00:00

41 lines
1.2 KiB
Bash

# TODO (SERVER-94776): Expose a reusable bazel command processor
# Usage:
# bazel_coverage [arguments]
#
# Required environment variables:
# * ${target} - Build target
# * ${args} - Extra command line args to pass to "bazel coverage"
# Needed for evergreen scripts that use evergreen expansions and utility methods.
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)"
. "$DIR/prelude.sh"
cd src
set -o errexit
set -o verbose
# Use `eval` to force evaluation of the environment variables in the echo statement:
eval echo "Execution environment: Args: ${args} Target: ${target}"
source ./evergreen/bazel_RBE_supported.sh
if bazel_rbe_supported; then
LOCAL_ARG=""
else
LOCAL_ARG="--config=local"
fi
# We only support explicitly limited arch for code coverage, so there
# are fewer conditionals here than elsewhere in more general utilities.
BAZEL_BINARY=bazel
# Print command being run to file that can be uploaded
echo "python buildscripts/install_bazel.py" > bazel-invocation.txt
echo "bazel coverage --verbose_failures $LOCAL_ARG ${args} ${target}" >> bazel-invocation.txt
eval $BAZEL_BINARY coverage --verbose_failures $LOCAL_ARG ${args} ${target}
exit $RET