diff --git a/site/en/reference/test-encyclopedia.md b/site/en/reference/test-encyclopedia.md index ffbd719317b140..4872c25c634569 100644 --- a/site/en/reference/test-encyclopedia.md +++ b/site/en/reference/test-encyclopedia.md @@ -452,6 +452,11 @@ The initial environment block shall be composed as follows: class="external">JUnit test result schema. optional + + BAZEL_TEST + Signifies test executable is being driven by bazel test + required + The environment may contain additional entries. Tests should not depend on the diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh index 182507fcdb57e0..1cc73137d75653 100755 --- a/tools/test/test-setup.sh +++ b/tools/test/test-setup.sh @@ -37,6 +37,11 @@ function is_absolute { # root. EXEC_ROOT="$PWD" +# Declare that the executable is running in a `bazel test` environment +# This allows test frameworks to enable output to the unprefixed environment variable +# For example, if `BAZEL_TEST` and `XML_OUTPUT_FILE` are defined, write JUnit output +export BAZEL_TEST=1 + # Bazel sets some environment vars to relative paths to improve caching and # support remote execution, where the absolute path may not be known to Bazel. # Convert them to absolute paths here before running the actual test.