-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
Copy pathbazel_test.sh
43 lines (31 loc) · 1.11 KB
/
bazel_test.sh
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
# Usage:
# bazel_test [arguments]
#
# Required environment variables:
# * ${target} - Test target
# * ${args} - Extra command line args to pass to "bazel test"
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)"
. "$DIR/prelude.sh"
cd src
set -o errexit
set -o verbose
activate_venv
# Use `eval` to force evaluation of the environment variables in the echo statement:
eval echo "Execution environment: Args: ${args} Target: ${target}"
source ./evergreen/bazel_utility_functions.sh
BAZEL_BINARY=$(bazel_get_binary_path)
# Print command being run to file that can be uploaded
echo "python buildscripts/install_bazel.py" > bazel-invocation.txt
echo "bazel test ${args} ${target}" >> bazel-invocation.txt
set +e
# use eval since some flags have quotes-in-quotes that are otherwise misinterpreted
eval $BAZEL_BINARY test ${args} ${target}
ret=$?
set -e
# For a target //path:test, the undeclared test outputs are in
# bazel-testlogs/path/test/test.outputs/outputs.zip
outputs=bazel-testlogs/$(sed "s|//||;s|:|/|" <<< ${target})/test.outputs/outputs.zip
if [ -f $outputs ]; then
unzip $outputs -d ../
fi
exit $ret